Skip to content

Instantly share code, notes, and snippets.

@cmatskas
Created November 15, 2023 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmatskas/bbe15a32f91d57418e5d04f9a1a820fd to your computer and use it in GitHub Desktop.
Save cmatskas/bbe15a32f91d57418e5d04f9a1a820fd to your computer and use it in GitHub Desktop.
amazon_polly_python
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