0.0.0 • Published 5 years ago

@amai-io/amai-sdk v0.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

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 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
  • Move to github standalone repo
  • Migrate from travis CI to gitlab CI