Skip to content

Instantly share code, notes, and snippets.

Created March 13, 2019 07:54
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Describe and play all available AWS Polly voices
#!/usr/bin/env python3
# - describe and play all AWS Polly voices
# Author Michael Ludvig
import boto3
from audio_helper import play_audio_stream
polly = boto3.client('polly')
response = polly.describe_voices() # Optional param: LanguageCode='en-US'
voices = response['Voices']
print("AWS Polly currently supports {} voices".format(len(voices)))
for voice in voices:
text = "Hi, my name is {Name} and I speak {LanguageName}".format(**voice)
ssml_text = '''<speak>
Hi, my name is
<lang xml:lang="{LanguageCode}">{Name}</lang>
and I speak {LanguageName}.
response = polly.synthesize_speech(OutputFormat='ogg_vorbis',
LanguageCode='en-GB', VoiceId=voice['Id'],
TextType='ssml', Text=ssml_text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment