Skip to content

Instantly share code, notes, and snippets.

Created March 14, 2019 09:37
  • 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?
Basic SSML-enhanced text synthesis
#!/usr/bin/env python3
# - Basic SSML-enhanced text output
# Author Michael Ludvig
# Import play_audio_stream() from
from audio_helper import play_audio_stream
# Boto3 is the AWS SDK for Python
import boto3
# Initialise AWS Polly client
# AWS Credentials will be read from ~/.aws/credentials
polly = boto3.client('polly')
# SSML-enhanced text
ssml_text = '''
Let me tell you a secret.
<break time="1s" />
<amazon:effect name="whispered">Amazon Alexa is my sister!</amazon:effect>
response = polly.synthesize_speech(OutputFormat='ogg_vorbis', VoiceId='Emma',
TextType='ssml', Text=ssml_text)
filename = __file__.replace('.py', '')+'.ogg'
with open(filename, 'wb') as f:
print("Audio written to: %s" % filename)
# Play the returned audio stream - call the function from
Copy link

I found you comment this project

can you please share how did you run it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment