Last active
February 5, 2017 05:56
-
-
Save ranman/0d228dbf4a26be5359c6150e18320363 to your computer and use it in GitHub Desktop.
polly stream
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 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