Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Text-to-Speech


(warning)

Legal notice

<Say> and Text-to-Speech (TTS), including the <Say> TwiML verb and API, uses artificial intelligence or machine learning technologies. By enabling or using any features or functionalities within Programmable Voice that Twilio identifies as using artificial intelligence or machine learning technology, you acknowledge and agree to certain terms. Your use of these features or functionalities is subject to the terms of the Predictive and Generative AI or ML Features Addendum(link takes you to an external page).

Availability of voices

Some features and voices, including third-party voices, in <Say> and Text-to-Speech may be available as alpha, beta, not generally available, limited release, or preview (collectively "Beta"), and information contained in this document might change. This means that some features might change before the product becomes Generally Available. The Twilio Service Level Agreement(link takes you to an external page) doesn't cover Beta products.

Use of third-party voices

Third-party voices might change without prior notice. Although Twilio provides access to these third-party voices, the third-party vendors control and update these voices. These changes include, but are not limited to, new models that affect how voices sound or the removal of voices from their offering with or without alternative or automatic redirections. To learn about third-party voice functionality, see the Text-to-Speech documentation for Google(link takes you to an external page) or Amazon(link takes you to an external page).

Text-to-Speech (TTS) converts text into a human-sounding voice. To turn traditional human-to-human interactions into seamless, machine-to-human interactions, developers and business users use TTS. This replaces recording audio files with human voices for call playback. To respond to events in your app, TTS generates prompts from raw text, delivering information over a phone call with greater efficiency.


Get Started with Text-to-Speech

get-started-with-text-to-speech page anchor

Twilio synthesizes speech from your text in real time and speaks the speech in any call. You can use TTS in TwiML and Twilio Studio.

TwiMLTwilio Studio

To provide plain text that Twilio converts to synthesized speech, use the <Say> verb.

(information)

TwiML Hello World example

When Twilio executes the following TwiML during a call, the caller hears "Hello world!" in the default voice and language of the Twilio Account. You configure the default values in the Twilio Console.

1
<Response>
2
<Say>Hello world!</Say>
3
</Response>

To modify the language, accent, and voice of the synthesized speech, use the language and voice attributes of the <Say> verb.

(information)

Amazon Polly Johanna voice and American English language example

The following TwiML uses Amazon Polly's "Joanna" voice and American English:

1
<Response>
2
<Say language="en-US" voice="Polly.Joanna">Hello. I am Joanna and I speak American English!</Say>
3
</Response>

<Say> offers different options for voices. Each option offers its own supported set of languages and genders. To customize your app to your needs and preferences, use the Text-to-Speech capabilities.

To start using Text-to-Speech, complete the following steps:

  1. Configure your account-wide text-to-speech Settings(link takes you to an external page) in the Twilio Console.
  2. Define TTS instructions in a TwiML document with <Say>.

You can choose from four types of Twilio Text-to-Speech: Basic, Standard, Neural and Generative. These types differ in their support of technologies, languages, locales(link takes you to an external page), and quality of conversation.

Basic voices

basic-voices page anchor

These voices help you learn Text-to-Speech capabilities using <Say>. Don't use these voices for production apps. These voices lack enough human-like qualities for voice call conversation. Due to their limited purpose, these voices support few languages. Twilio provides these voices at no additional cost.

These voices use standard technology in synthesized speech. They produce natural-sounding lifelike voices but might have limited human speech patterns and inflections. These voices speak using Amazon Polly(link takes you to an external page) and Google Standard(link takes you to an external page) voices.

These voices use enhanced technology in synthesized speech. They produce higher-quality and more natural-sounding voices than Standard voices. These voices speak using Amazon Polly Neural(link takes you to an external page) and Google WaveNet(link takes you to an external page) and Neural2(link takes you to an external page) voices.

These voices use the generative AI technology. They produce human-like voices with apparent emotional engagement and context awareness. These voices interpret the text-input and adjust their speech. These synthetic voices sound like human voices. This makes these voices the best option for Conversational AI apps and Virtual Agents(link takes you to an external page). These voices speak using Amazon Polly Generative(link takes you to an external page) and Google Chirp3-HD(link takes you to an external page) voices.

(new)

Public Beta

Twilio provide generative voices as a Public Beta product. The information in this page might change. Some features might change before declaring the product as Generally Available. The Twilio Service Level Agreement(link takes you to an external page) doesn't cover Public Beta products.


Available voices and languages

available-voices-and-languages page anchor

Twilio supports a large range of languages and locale variants.

The format of the voice attribute depends on the TwiML verb as shown in the following table:

TwiML verbVoice value formatExample
<Say>{Provider}.{Voice}Polly.Joanna-Generative
<ConversationRelay>{Voice}Joanna-Generative

The following table lists all voices available for each language and locale.

Language (Locale)Language codeTypeGenderProviderVoice

Afrikaans (South Africa)

af-ZA

Standard

Female

Google

af-ZA-Standard-A

Arabic (Gulf)

ar-AE

Neural

Female

Polly

Hala-Neural *

Arabic (Gulf)

ar-AE

Neural

Male

Polly

Zayd-Neural *

Arabic (Standard)

ar-XA

Generative

Female

Google

ar-XA-Chirp3-HD-Aoede

Arabic (Standard)

ar-XA

Generative

Male

Google

ar-XA-Chirp3-HD-Charon

Arabic (Standard)

ar-XA

Generative

Male

Google

ar-XA-Chirp3-HD-Fenrir

Arabic (Standard)

ar-XA

Generative

Female

Google

ar-XA-Chirp3-HD-Kore

Arabic (Standard)

ar-XA

Generative

Female

Google

ar-XA-Chirp3-HD-Leda

Arabic (Standard)

ar-XA

Generative

Male

Google

ar-XA-Chirp3-HD-Orus

Arabic (Standard)

ar-XA

Generative

Male

Google

ar-XA-Chirp3-HD-Puck

Arabic (Standard)

ar-XA

Generative

Female

Google

ar-XA-Chirp3-HD-Zephyr

Arabic (Standard)

ar-XA

Standard

Female

Google

ar-XA-Standard-A

Arabic (Standard)

ar-XA

Standard

Male

Google

ar-XA-Standard-B

Arabic (Standard)

ar-XA

Standard

Male

Google

ar-XA-Standard-C

The preceding table identifies bilingual voices with (*) in the Voice column. Only Amazon Polly supports this for a limited number of voices. To learn more about the bilingual voices, see the Amazon Polly documentation(link takes you to an external page).

To test the different voices, go to the Text-to-Speech page(link takes you to an external page) in the Twilio Console.


Configure Text-to-Speech

configure-text-to-speech page anchor
(information)

Limited to <Say> and <Pay><Prompt>

The TTS Settings described in this section only apply to the <Say> TwiML verb and the <Pay> <Prompt> TwiML noun.

Text-to-Speech capabilities in <ConversationRelay> have their own settings and defaults for the voice attribute, which depends on the Provider and Language used.

Define a default voice and language

define-a-default-voice-and-language page anchor

To define the default voice and language for your account, go to the Text-to-Speech page(link takes you to an external page) in the Twilio Console.

  • When you don't set language or voice attributes in your <Say> TwiML verb, it uses the default values.
  • When you select Default in Studio, it uses the default values.
(information)

Text-to-Speech Default Settings example

Consider that you set the Your default provider to Basic and set the Default voice to Man, en-US as your Default Settings.

When executing the following TwiML with these TTS settings, Twilio uses the Man voice and the en-US (American English) accent and pronunciation:

1
<Response>
2
<Say>Hello. I am a man!</Say>
3
</Response>

Map a voice to a language

map-a-voice-to-a-language page anchor

Twilio updates the offered Text-to-Speech voices on a regular basis. To access the latest voices without needing to review and change your code, use the Language Mapping feature. Your app only needs the language and the text. Twilio selects and uses the corresponding voice. Update these at any time from the Twilio Console. On the Text-to-Speech page(link takes you to an external page) in the Twilio Console, you can set a voice for every locale.

To set a voice for a locale, complete the following steps.

  1. Go to the Text-to-Speech page(link takes you to an external page) in the Twilio Console.
  2. Under the Current Language Mapping heading, choose the language and locale you wish to configure.
    In this example, choose English (British) (en-GB). The Test & Configure Voices By Language modal displays.
  3. From the dropdown menus, select the Provider and Voice you wish to use.
    In this example, choose Amazon Polly and Emma.
  4. Click Save.
  5. Repeat these steps for other language and voice pairing you want to use.

With these mappings set, you can specify the language without specifying the voice when using the <Say> TwiML verb in your app.

(information)

Set language without voice example

Consider that you configured English (British) (en-GB) to use Amazon Polly Emma voice.

In the following TwiML example, Twilio uses the Amazon Polly Emma voice when executing <Say> with the language attribute set to en-GB. This didn't require a voice attribute.

1
<Response>
2
<Say language="en-GB">Hello. I am Emma!</Say>
3
</Response>

Override default settings

override-default-settings page anchor
(information)

Limited to <Say> and <Pay><Prompt>

The TTS Settings described in this section only apply to the <Say> TwiML verb and the <Pay> <Prompt> TwiML noun.

Text-to-Speech capabilities in <ConversationRelay> have their own settings and defaults for the voice attribute, which depends on the Provider and Language used.

To override default voice settings configured in the Twilio Console, change the <Say> voice attribute.

(information)

Change the voice for a specific call example

Consider that you set the default Text-to-Speech voice to Amazon Polly Salli in your account. You want to use Amazon Polly Joanna for a specific call. To use the Amazon Polly Joanna voice for a specific call, set the <Say> voice attribute to Polly.Joanna.

In the following TwiML example when executing <Say>, Twilio uses the Amazon Polly Joanna voice instead of Amazon Polly Salli voice.

1
<Response>
2
<Say voice="Polly.Joanna">Hello. I am Joanna!</Say>
3
</Response>

To override a Language Mapping's defaults, add the voice attribute.

(information)

Override default language mapping for a specific call

Consider that you set the language mapping for English (British) (en-GB) to Amazon Polly Emma in your account. You want to use Amazon Polly Joanna for a specific call. To use the Amazon Polly Joanna voice for a specific call, set the <Say> voice attribute to Polly.Joanna.

<Say> using Amazon Polly Joanna

say-using-amazon-polly-joanna page anchor
1
<Response>
2
<Say language="en-GB" voice="Polly.Joanna">Hello. I am Joanna!</Say>
3
</Response>

Override default languages

override-default-languages page anchor

To override any default language settings configured in the Twilio Console, use the <Say> verb language attribute.

(information)

Language override example

Consider that you set your account's default Text-to-Speech Language to English (US) (en-US). To use German for a specific call, set the language attribute to de-DE.

In the following TwiML example, Twilio uses German (de-DE) language instead of English (US) (en-US) language when executing <Say>.

1
<Response>
2
<Say language="de-DE">Hallo. Ich spreche Deutsch!</Say>
3
</Response>

Speech Synthesis Markup Language

speech-synthesis-markup-language page anchor

To fine-tune synthesized speech, use Speech Synthesis Markup Language (SSML)(link takes you to an external page) tags. With SSML, you can specify where pauses should be, provide pronunciations for acronyms, abbreviations, dates and times, and increase or decrease the speed of spoken text. Basic voices don't support SSML.

Twilio-supported SSML tags

twilio-supported-ssml-tags page anchor

Twilio supports a subset of SSML tags in TwiML.

SSML support might differ between Text-to-Speech providers, be limited to specific voices, or both. Review the provider-specific SSML documentation and test your app. Use of SSML tags that a Text-to-Speech provider or voice doesn't support might result in error and fail the <Say> instruction.

(information)

TwiML substitutes SSML <speak> tag

The SSML specification(link takes you to an external page) requires a root element: <speak>. You don't need <speak> inside <Say>. Skip <speak> and insert the rest of the SSML inside <Say>.

The following table lists the SSML tags that Twilio supports. To learn about the use of specific SSML tags, see the provider-specific documentation.

Modify speech speed and volume

modify-speech-speed-and-volume page anchor

To control the volume, rate, and pitch of synthesized speech, use the SSML <prosody> tag.

1
<Response>
2
<Say voice="Polly.Joanna">
3
Prosody can be used to change the way words sound. The following words are
4
<prosody volume="x-loud"> quite a bit louder than the rest of this passage.
5
</prosody> Each morning when I wake up, <prosody rate="x-slow">I speak slowly and
6
deliberately until I have my coffee.</prosody> I can also change the pitch of my voice
7
using prosody. Do you like <prosody pitch="+5%"> speech with a pitch higher,</prosody>
8
or <prosody pitch="-10%"> is a lower pitch preferable?</prosody>
9
</Say>
10
</Response>

To choose how to pronounce a specific category of text, use the SSML <say-as> tag. This ensures that speech pronounces certain text as expected. Without <say-as>, the voice pronounces a phone number like a number.

(information)

Pronunciation differences

Consider the number 4155551212.

Use <say-as>Read asVoice says
NoA numberfour billion, one hundred fifty-five million,
five hundred fifty-one thousand, two hundred twelve
YesA phone numberfour one five, five five five, one two one two
1
<Response>
2
<Say voice="Polly.Joanna">
3
John's phone number is, <say-as interpret-as="telephone">4155551212</say-as>
4
</Say>
5
</Response>

Generate SSML with Twilio SDKs

generate-ssml-with-twilio-sdks page anchor

To generate TwiML with SSML within the <Say> verb, use a Twilio SDK: C#(link takes you to an external page), Go(link takes you to an external page), Java(link takes you to an external page), Node.js(link takes you to an external page), PHP(link takes you to an external page), Python(link takes you to an external page), or Ruby(link takes you to an external page).

This SDK code generates the TwiML with SSML.

Generate SSML with SDKLink to code sample: Generate SSML with SDK
1
const VoiceResponse = require('twilio').twiml.VoiceResponse;
2
3
const response = new VoiceResponse();
4
const say = response.say(
5
{
6
voice: 'Polly.Joanna',
7
},
8
'Hi'
9
);
10
say.break({
11
strength: 'x-weak',
12
time: '100ms',
13
});
14
say.emphasis(
15
{
16
level: 'moderate',
17
},
18
'Words to emphasize'
19
);
20
say.p('Words to speak');
21
say.addText('aaaaaa');
22
say.phoneme(
23
{
24
alphabet: 'x-sampa',
25
ph: 'pɪˈkɑːn',
26
},
27
'Words to speak'
28
);
29
say.addText('bbbbbbb');
30
say.prosody(
31
{
32
pitch: '-10%',
33
rate: '85%',
34
volume: '-6dB',
35
},
36
'Words to speak'
37
);
38
say.s('Words to speak');
39
say.sayAs(
40
{
41
'interpret-as': 'spell-out',
42
role: 'yyyymmdd',
43
},
44
'Words to speak'
45
);
46
say.sub(
47
{
48
alias: 'alias',
49
},
50
'Words to be substituted'
51
);
52
say.w('Words to speak');
53
54
console.log(response.toString());
1
<Response>
2
<Say voice="Polly.Joanna">
3
Hi
4
<break strength="x-weak" time="100ms"/>
5
<emphasis level="moderate">Words to emphasize</emphasis>
6
<p>Words to speak</p>
7
aaaaaa
8
<phoneme alphabet="x-sampa" ph="pɪˈkɑːn">Words to speak</phoneme>
9
bbbbbbb
10
<prosody pitch="-10%" rate="85%" volume="-6dB">Words to speak</prosody>
11
<s>Words to speak</s>
12
<say-as interpret-as="spell-out">Words to speak</say-as>
13
<sub alias="alias">Words to be substituted</sub>
14
<w>Words to speak</w>
15
</Say>
16
</Response>

  • Basic voices can process no more than 4,000 characters.
  • Basic voices don't support SSML tags.

Amazon Polly voice limitations

amazon-polly-voice-limitations page anchor
  • <Say> can't process more than 3,000 characters excluding the SSML tags.
  • <Say> doesn't support Amazon-specific SSML tags. These would include <amazon:auto-breath> or <amazon:effect>.
  • <Say> doesn't support lexicons.
  • SSML support might vary between Polly and Polly Neural voices.
    To review any differences, see the Amazon Polly SSML documentation(link takes you to an external page).

Google voice limitations

google-voice-limitations page anchor
  • <Say> can process no more than 5,000 characters, including SSML, newlines and spaces.
  • As Google includes SSML tags, newlines and spaces in the total character count, they count toward Google billing totals.
  • <Say> doesn't support Google-specific SSML tags. This includes <par> or <seq>.
  • SSML support may vary between Standard, WaveNet and Neural2 voices.
    To review any differences, consult the [Google SSML documentation][].

Basic voices are free of charge. For Standard, Neural, and Generative voice pricing, see Voice pricing(link takes you to an external page). Twilio rounds usage towards the end of call and prices it in blocks of 100 characters. The minimum charge covers 100 characters.


Amazon Polly Text-to-Speech

amazon-polly-text-to-speech page anchor

AI Nutrition Facts

<Say> - Amazon Polly Text-to-Speech

Description
Convert text into a human-sounding voice using speech synthesis technology from Amazon Polly.
Privacy Ladder Level
N/A
Feature is Optional
Yes
Model Type
Generative and Predictive
Base Model
Amazon Polly Text-to-Speech: Standard, Neural and Generative

Trust Ingredients

Base Model Trained with Customer Data
No

The Base Model is not trained using Customer Data.

Customer Data is Shared with Model Vendor
No

Programmable Voice uses the default Base Model provided by the Model Vendor. The Base Model is not trained using customer data.

Training Data Anonymized
N/A

The Base Model is not trained using Customer Data.

Data Deletion
N/A

The Base Model is not trained using Customer Data.

Human in the Loop
Yes

Customers can view text input and listen to the audio output.

Data Retention
30 days

Compliance

Logging & Auditing
Yes

Customers can view text input and listen to the audio output.

Guardrails
Yes

Customers can view text input and listen to the audio output.

Input/Output Consistency
Yes

Customers are responsible for human review.

Other Resources
https://www.twilio.com/docs/voice/twiml/say/text-speech

AI Nutrition Facts

<Say> - Google Text-to-Speech

Description
Convert text into a human-sounding voice using speech synthesis technology from Google.
Privacy Ladder Level
N/A
Feature is Optional
Yes
Model Type
Generative and Predictive
Base Model
Google Text-to-Speech: Standard, WaveNet, Neural2 and Chirp3-HD

Trust Ingredients

Base Model Trained with Customer Data
No

The Base Model is not trained using Customer Data.

Customer Data is Shared with Model Vendor
No

Programmable Voice uses the default Base Model provided by the Model Vendor. The Base Model is not trained using customer data.

Training Data Anonymized
N/A

The Base Model is not trained using Customer Data.

Data Deletion
N/A

The Base Model is not trained using Customer Data.

Human in the Loop
Yes

Customers can view text input and listen to the audio output.

Data Retention
30 days

Compliance

Logging & Auditing
Yes

Customers can view text input and listen to the audio output.

Guardrails
Yes

Customers can view text input and listen to the audio output.

Input/Output Consistency
Yes

Customers are responsible for human review.

Other Resources
https://www.twilio.com/docs/voice/twiml/say/text-speech