Synthesizing speech with a custom voice
To use a custom voice, specify its ID as the VoiceId in a
SynthesizeSpeech, StartSpeechSynthesisTask, or
StartSpeechSynthesisStream request. Set Engine to
generative. The voice must be in active status.
To synthesize speech, you must have the permission for the operation that you call:
polly:SynthesizeSpeech, polly:StartSpeechSynthesisTask, or
polly:StartSpeechSynthesisStream.
In the console, you can synthesize speech on the Text-to-Speech tab or on the voice details page. You can also use the AWS CLI.
Custom voices support the same output formats, sample rates, and SSML tags as the
other voices of the generative engine. For more information, see Generative voices. The
<phoneme> tag works with custom voices in English, French, Italian,
German, and Spanish.
The same text can sound slightly different from one request to the next. For fixed prompts, such as phone greetings, synthesize the audio once, review it, and store the file.
In the AWS SDKs, the VoiceId enumeration contains only the voices that
Amazon Polly provides. To use a custom voice, pass its ID as a string. To read the ID from a
response, use the string accessor, for example Voice.idAsString() in the
AWS SDK for Java 2.x.
If the voice uses a customer managed key, you must have the kms:Decrypt permission
on the key. If Amazon Polly can't use the key, the synthesis request fails. For a
StartSpeechSynthesisTask request, the task fails, and
TaskStatusReason describes the problem. For more information, see Disabling or deleting the key of a voice.
Example: Allowing synthesis with one custom voice
Custom voices are IAM resources, so you can scope permissions to a single voice. The
following policy allows a role to synthesize speech with one custom voice and nothing
else. Keep polly:CreateVoice and polly:DeleteVoice in a
separate role that you use to provision voices.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "polly:SynthesizeSpeech", "Resource": "arn:aws:polly:us-east-1:111122223333:voice/vc-9a8fa85dd3" } ] }
A statement that allows polly:SynthesizeSpeech on all resources
("Resource": "*") also covers every custom voice in the account. To write
one rule for a group of voices, use aws:ResourceTag conditions. For more
information, see ABAC with Amazon Polly.