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.
GETtts.providers(): Promise<array>
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 aregoogle
andweb-speech-api
.apiKey:
The API key for the provider. Only required for thegoogle
provider.gender:
the gender of the voice. Possible values aremale
andfemale
.language:
the language of the voice. Possible values areen-US
,en-GB
,de-DE
, ...voice:
the name of the voice. Possible values areen-US-Wavenet-A
,en-US-Wavenet-B
, ...
tts.provider(provider?: Object): Promise<Object>
api.tts.provider({
name: 'google',
apiKey: 'my-secret-api-key',
gender: 'male',
language: 'en-US',
voice: 'en-US-Wavenet-A'
})
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 | SETtts.language(language?: string): Promise<string>
api.tts.language('en-US')
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.
tts.gender(gender?: string): Promise<string>
api.tts.gender('female')
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
, ...
tts.voice(voice?: string): Promise<string>
api.tts.voice('en-US-Wavenet-A')
actions: [{ name: 'tts.voice', arg: 'en-US-Wavenet-A' }]
tts.voices
Returns a list of available voices.
GETtts.voices(): Promise<string[]>
api.tts.voices().then(console.log)
// ['en-US-Wavenet-A', 'en-US-Wavenet-B', ...]
tts.speak
Speak the given text.
GETtts.speak(text: string): Promise<void>
api.tts.speak('Hello World').then(() => console.log('done'))
actions: [{ name: 'tts.speak', arg: 'Hello World' }]