Skip to content

Instantly share code, notes, and snippets.

@redavis22
Forked from ranman/polly_demo.py
Created February 5, 2017 05:56
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 redavis22/10270880ba6ba97cfe4da077e446820a to your computer and use it in GitHub Desktop.
Save redavis22/10270880ba6ba97cfe4da077e446820a to your computer and use it in GitHub Desktop.
polly stream
import pyaudio
import boto3
polly = boto3.client('polly')
p = pyaudio.PyAudio()
resp = polly.synthesize_speech(Text="HELLO WORLD!", TextType="text", OutputFormat="pcm", VoiceId="Justin")
stream = p.open(format=p.get_format_from_width(width=2), channels=1, rate=16000, output=True)
stream.write(resp['AudioStream'].read())
stream.stop_stream()
stream.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment