Basic SSML-enhanced text synthesis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# ssml_simple.py - Basic SSML-enhanced text output | |
# Author Michael Ludvig | |
# Import play_audio_stream() from audio_helper.py | |
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 = ''' | |
<speak> | |
Let me tell you a secret. | |
<break time="1s" /> | |
<amazon:effect name="whispered">Amazon Alexa is my sister!</amazon:effect> | |
</speak> | |
''' | |
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: | |
f.write(response['AudioStream'].read()) | |
print("Audio written to: %s" % filename) | |
# Play the returned audio stream - call the function from audio_helper.py | |
play_audio_stream(response['AudioStream']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I found you comment this project
https://gist.github.com/Xophmeister/33e6abe5e055e122f5093f1acbc91793
can you please share how did you run it