playTTS

View as Markdown

playTTS

  • playTTS(params): Promise<CallPlayback> - See CallPlayback for more details.

Plays text-to-speech.

Parameters

NameTypeDescription
paramsObject-
params.gender?"male" | "female"Gender of the voice. Defaults to female.
params.language?stringLanguage of the text in ISO 639-1 (language name) + ISO 3166 (country code). Defaults to en-US.
Supported languages can be found here
params.textstringText 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?stringVoice to use (takes precedence on gender).
Supported voices can be found here
params.volume?numberVolume value between -40dB and +40dB where 0 is unchanged. Default is 0.

Returns

Promise<CallPlayback> - See CallPlayback for more details.

Examples

1const playback = await call.playTTS({ text: "Welcome to SignalWire!" });
2await playback.ended();

Using SSML:

1const 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});
15await playback.ended();