Skip to content

TextToSpeech

With the TextToSpeech API you can make your rooomAssistant speak. You can choose between different voices and languages. The provider is Web Speech API by default. You can change the provider to Google Cloud Text-to-Speech. This is a paid service and you need to create an account and add your credentials to the Digital Assistant.

tts.providers

Returns a list of available provider names.

GET tts.providers(): Promise<array>
js
api.tts.providers().then(console.log)
// ['google', 'web-speech-api']

tts.provider

Set the provider. The provider object has the following properties:

  • name: The name of the provider. Possible values are google and web-speech-api.
  • apiKey: The API key for the provider. Only required for the google provider.
  • gender: the gender of the voice. Possible values are male and female.
  • language: the language of the voice. Possible values are en-US, en-GB, de-DE, ...
  • voice: the name of the voice. Possible values are en-US-Wavenet-A, en-US-Wavenet-B, ...
GET | SET tts.provider(provider?: Object): Promise<Object>
js
api.tts.provider({
    name: 'google',
    apiKey: 'my-secret-api-key',
    gender: 'male',
    language: 'en-US',
    voice: 'en-US-Wavenet-A'
})
js
actions: [{ name: 'tts.provider', arg: { ... } }]

tts.language

The language of the voice. Possible values are en-US, de-DE or even simpler en, de, ...

If you don't set the language, the current user language will be returned.

GET | SET tts.language(language?: string): Promise<string>
js
api.tts.language('en-US')
js
actions: [{ name: 'tts.language', arg: 'en-US' }]

tts.gender

Set or Get the current gender of the voice. Possible values are male and female. If no gender is set, the current gender will be returned.

GET | SET tts.gender(gender?: string): Promise<string>
js
api.tts.gender('female')
js
actions: [{ name: 'tts.gender', arg: 'female'}]

tts.voice

Set or Get the current voice. Possible values are en-US-Wavenet-A, en-US-Wavenet-B, ...

GET | SET tts.voice(voice?: string): Promise<string>
js
api.tts.voice('en-US-Wavenet-A')
js
actions: [{ name: 'tts.voice', arg: 'en-US-Wavenet-A' }]

tts.voices

Returns a list of available voices.

GET tts.voices(): Promise<string[]>
js
api.tts.voices().then(console.log)
// ['en-US-Wavenet-A', 'en-US-Wavenet-B', ...]

tts.speak

Speak the given text.

GET tts.speak(text: string): Promise<void>
js
api.tts.speak('Hello World').then(() => console.log('done'))
js
actions: [{ name: 'tts.speak', arg: 'Hello World' }]