Created
November 15, 2023 00:13
-
-
Save cmatskas/bbe15a32f91d57418e5d04f9a1a820fd to your computer and use it in GitHub Desktop.
amazon_polly_python
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
import boto3 | |
import os | |
audiofile = 'speech.mp3' | |
polly_client = boto3.client('polly') | |
response = polly_client.synthesize_speech(VoiceId='Joanna', | |
OutputFormat='mp3', | |
Text = 'This is a sample text to be synthesized.', | |
Engine = 'neural') | |
file = open(audiofile, 'wb') | |
file.write(response['AudioStream'].read()) | |
file.close() | |
os.system("afplay speech.mp3") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment