0.0.4 • Published 4 years ago

amai-sdk v0.0.4

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

WIP: Not for using at this moment.

Amai TTS SDK

Tools designed to make complex, machine learning things easy to understand and implement for apps developers.

Alt text

What can I do with that?

  • Teach your applications to speak with a human voice in different emotional colors and languages
  • Give your users an unforgettable voice UX with adaptive audio player
  • Add TTS functionality to your web service in 5 lines of code

For other programming languages, you should use

Installation

yarn add amai-sdk

or

npm install --save amai-sdk

Basic browser example

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.
// As a result, the synthesized sentence "I love amai!",
// will be played in the audio player in your browser!
stream.addText('I love amai!')

Synthesis example

Stream is an entity to which you can add text and listen to. Technically it's an Apple HLS format, VLC for example. This allows you to listen synthesis result in any player that supports this format. Streams may not have unique names.

import sdk, { synthesis } from 'amai-sdk'

const stream = await synthesis.createStream('streamName')
const stream1 = await synthesis.getStream('streamName')
const stream2 = await synthesis.getOrCreateStream('streamName')

console.log(stream.id === stream1.id && stream.id === stream2.id)
// true

stream.addText('I love amai.')
// this is the alias for
synthesis.addText('streamName', text)
//or
sdk.synthesis.addText('streamName', text)

Authorization

To implement a more free limit, authorization is required.

Free limit - 10 000 symbols. You can use an api without setting a key within the free limit.

Currently, the easiest way to get the API key is to write in telegram @maxbaluev or email at m@amai.io.

import sdk from 'amai-sdk'

sdk.key = 'YourApiKey'
// Now you can make authorized requests.

await sdk.synthesis.createStream('streamName')

or you can authorize at any nested import

import sdk, { synthesis } from 'amai-sdk'

synthesis.key = 'YourApiKey'
// Now you can make authorized requests.

//When you install the key on any SDK import - it is automatically installed on all instances
console.log(sdk.key === synthesis.key)
//true

Specificity of usage

  • 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.
  • If you do not set an api key, a temporary key with a free limit will be automatically generated and set before the first call to the api server.

Users management

In order to control the use of API resources, a mechanism for managing user keys has been implemented.

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 suite
  • npm start: Run npm run build in watch mode
  • npm run test:watch: Run test suite in interactive watch mode
  • npm run test:prod: Run linting and generate coverage
  • npm run build: Generate bundles and typings, create docs
  • npm run lint: Lints code
  • npm 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
  • Migrate from travis CI to gitlab CI