*** id: 3af3ecb6-c979-420c-896f-774b936967f0 title: playTTS slug: /node/reference/voice/call/play-tts description: playTTS method for the Call class. max-toc-depth: 3 ---------------- [callplayback-events]: /docs/server-sdk/v4/node/reference/voice/call-playback#events [callplayback-onstarted]: /docs/server-sdk/v4/node/reference/voice/call-playback#onstarted [callplayback]: /docs/server-sdk/v4/node/reference/voice/call-playback [ssml]: https://cloud.google.com/text-to-speech/docs/ssml [supported-voices-languages]: /docs/platform/voice/tts ### playTTS * **playTTS**(`params`): `Promise`\<[`CallPlayback`][callplayback]> Plays text-to-speech. #### Parameters Object containing the parameters for playing text-to-speech. Text to play. SSML may be entered as a string wrapped in `` tags. See our [supported voices and languages][supported-voices-languages] documentation for usage and supported tags. Language of the text in ISO 639-1 (language name) + ISO 3166 (country code). Supported languages can be found [here][supported-voices-languages]. Gender of the voice. Voice to use (takes precedence over `gender`). Supported voices can be found [here][supported-voices-languages]. Volume value between -40dB and +40dB where 0 is unchanged. Callback to listen for events. List of playback events can be found [here][callplayback-events]. Example event: [`onStarted`][callplayback-onstarted]. #### Returns `Promise`\<[`CallPlayback`][callplayback]> A promise that resolves to a [`CallPlayback`][callplayback] object that you can use to view the current state and results of the `play` session. #### Examples In this example, we dial a phone number and play a TTS message. Once the TTS message is finished playing, we hangup the call. ```js import { SignalWire } from "@signalwire/realtime-api"; const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" }) const voiceClient = client.voice; // Listen for incoming calls await voiceClient.listen({ topics: ["office"], onCallReceived: async (call) => { console.log("Call received"); // Answer the call call.answer(); // Play TTS on the call await call.playTTS({ text: "Hello, this is a test call from SignalWire", listen: { onStarted: () => console.log("TTS started"), onFailed: () => console.log("TTS failed"), onUpdated: (tts) => console.log("TTS state:", tts.state), onEnded: () => { console.log("TTS ended"); // Hangup the call call.hangup(); } } }).onStarted(); } }); ``` In this example, we are using [SSML][ssml] to play a TTS message. Once the TTS message is finished playing, we hangup the call. ```js import { SignalWire } from "@signalwire/realtime-api"; const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" }) const voiceClient = client.voice; // Listen for incoming calls await voiceClient.listen({ topics: ["office"], onCallReceived: async (call) => { console.log("Call received"); // Answer the call call.answer(); // Play TTS on the call using SSML. Listens for playback events. Ends the call after the TTS is finished playing. await call.playTTS({ text: ` Here are SSML samples. I can pause . I can speak in cardinals. Your number is 10. Or I can speak in ordinals. You are 10 in line. Or I can even speak in digits. The digits for ten are 10. I can also substitute phrases, like the W3C. Finally, I can speak a paragraph with two sentences.

This is sentence one.This is sentence two.

`, voice: "polly.Joey", listen: { onStarted: () => console.log("TTS started"), onFailed: () => console.log("TTS failed"), onUpdated: (tts) => console.log("TTS state:", tts.state), onEnded: () => { console.log("TTS ended"); call.hangup(); } } }).onStarted(); } }); ```