Skip to main content
Polly

Text to Speech

1. Create a Polly Audio object​

Call Construct Polly Audio. It returns a Polly Audio object, which is a sound wave that the speech is written to. Store it in a variable.

2. Synthesize the speech​

Call Synthesize Speech with:

FieldValue
Polly AudioThe object from Construct Polly Audio.
TextThe text to speak, or SSML if Text Type is ssml.
Text Typetext or ssml.
Voice IdThe voice, for example Joanna. Use Describe Voices to list the voices for a language.
Enginestandard or neural. Neural voices sound more natural, but not all voices have them.
Language CodeOnly needed for voices that speak more than one language.
Output Formatpcm for audio, json for speech marks.
Sample Rate16000 (High) or 8000 (Low).
warning

The node fails with You must provide a valid PollyAudio Object, don't forget to call ConstructPollyAudio if Polly Audio is empty and the output format is pcm.

3. Play it​

When the callback reports success, the Polly Audio in the result has the speech. Play it with Play Sound 2D, Spawn Sound at Location or an Audio Component, like any other sound. Get Duration returns its length in seconds.

When you no longer need the sound, call Destroy Polly Audio.

Speech marks​

Speech marks tell you when each word, sentence or viseme starts in the audio. Use them for subtitles or lip sync.

Call Synthesize Speech a second time with the same text and voice, Output Format json, and the Speech Mark Types you want, for example word and viseme. The result has the marks in Json String, one JSON object per line:

{"time":6,"type":"word","start":0,"end":5,"value":"Hello"}

time is in milliseconds from the start of the audio.

SSML​

With Text Type ssml you can control the speech:

<speak>Welcome back. <break time="500ms"/> You have <emphasis>three</emphasis> new quests.</speak>

See Supported SSML tags in the AWS documentation.