playTTS
playTTS
- playTTS(
params):Promise<CallPlayback>- See CallPlayback for more details.
Plays text-to-speech.
Parameters
| Name | Type | Description |
|---|---|---|
params | Object | - |
params.gender? | "male" | "female" | Gender of the voice. Defaults to female. |
params.language? | string | Language of the text in ISO 639-1 (language name) + ISO 3166 (country code). Defaults to en-US.Supported languages can be found here |
params.text | string | Text to play. SSML may be entered as a string wrapped in <speak> tags. See our supported voices and languages documentation for usage and supported tags. |
params.voice? | string | Voice to use (takes precedence on gender).Supported voices can be found here |
params.volume? | number | Volume value between -40dB and +40dB where 0 is unchanged. Default is 0. |
Returns
Promise<CallPlayback> - See CallPlayback for more details.
Examples
1 const playback = await call.playTTS({ text: "Welcome to SignalWire!" }); 2 await playback.ended();
Using SSML:
1 const playback = await call.playTTS({ 2 text: `<speak> 3 Here are <say-as interpret-as="characters">SSML</say-as> samples. 4 I can pause <break time="3s"/>. 5 I can speak in cardinals. Your number is <say-as interpret-as="cardinal">10</say-as>. 6 Or I can speak in ordinals. You are <say-as interpret-as="ordinal">10</say-as> in line. 7 Or I can even speak in digits. The digits for ten are <say-as interpret-as="characters">10</say-as>. 8 I can also substitute phrases, like the <sub alias="World Wide Web Consortium">W3C</sub>. 9 Finally, I can speak a paragraph with two sentences. 10 <p><s>This is sentence one.</s><s>This is sentence two.</s></p> 11 </speak> 12 `, 13 voice: "polly.Joey", 14 }); 15 await playback.ended();