0.0.0 • Published 5 years ago
@amai-io/amai-sdk v0.0.0
WIP: Not for using at this moment.
Amai text to speech SDK
What can I do with that?
- Easily teach your applications to speak with a human voice in different emotional colors
- Give your users an unforgettable voice UX with adaptive audio player
- Add TTS functionality to your web service in 5 lines of code
Installation
yarn add amai-sdk
Browser environment
import sdk from 'amai-sdk'
// Create stream
const stream = await sdk.synthesis.createStream('streamName')
// Add stream to player
const player = sdk.player.create(stream)
// Play live stream
player.play()
// Adding text for synthesis and adding the result to the stream,
// as a result, the synthesized words "I love amai!",
// will be played in the audio player in your browser!
stream.addText('I love amai!')
Authorization
In order to implement a more free limit, authorization is required. If you have exceeded the limit, you will receive an audio message substituting the synthesis result and detailed console.log with ways to solve the problem.
Free limit - 10 000 symbols.
import sdk from 'amai-sdk'
sdk.key = 'YourApiKey'
// Now you can make authorized requests.
or you can authorize at any nested import
import { player } from 'amai-sdk'
player.key = 'YourApiKey'
// Now you can make authorized requests.
Speech
Player
Utils
Stream example
import stream from 'amai-sdk/speech/stream'
stream.api = 'YourApiKey'
const stream = await sdk.synthesis.createStream('streamName')
// stream === { id: number: 1, name: 'streamName', url: 'https://amai-generate.s3.eu-central-1.amazonaws.com/c0fc0b05c29c2904.mp3' }
// Return stream json metadata or error
const stream: Stream = await stream.getOrCreate('name')
stream.addText('I love amai.')
The SDK can be built into the client and server code, permission and access control is based on metadata included in the jwt key. SDK is a wrapper over HTTP calls to the REST backend, that makes it easy to work with your own logic.
Speech
- Synthesis
- Recognition(Planned)
Text
- Translation(Planned)
- OCR
- Page(Planned)
- Document(Planned)
- Player(WIP)
- Utils
Advanced example
NPM scripts
npm t
: Run test suitenpm start
: Runnpm run build
in watch modenpm run test:watch
: Run test suite in interactive watch modenpm run test:prod
: Run linting and generate coveragenpm run build
: Generate bundles and typings, create docsnpm run lint
: Lints codenpm run commit
: Commit using conventional commit style (husky will tell you to use it if you haven't :wink:)
Todo test cases
- Can add text only to self streams
Long term todo
- Change demo app to player example
- Move to github standalone repo
- Migrate from travis CI to gitlab CI
0.0.0
5 years ago