Using Amazon Polly to Synthesize Lifelike Speech - Part 2
This is the second part of the tutorial on how to use Amazon Polly for lifelike speech synthesis in Python.
In the first video we discussed pre-requisites for those who would be coding along. This video is all about coding though.
One thing that I forgot to mention in the first part is that we'll also going to need pygame to play or actually speak the message. So, if you don't have it, open up a terminal or command shell and do:
pip install pygame
Here's the rationale behind the code:
- create a variable that will send a request for speech synthesis
- the variable includes: the text that will be spoken, the format of the response (mp3), and the VoiceId
- our variable holds the response, which is quite intricate
- from the response, we're only interested in the 'AudioStream' part of it
- we take that 'AudioStream' and write it as .mp3 file using the write-binary ('wb') option
- we use pygame's mixer to play the file
- once it's finished, we delete the file - for a clean exit
Please watch the video for a walk-through the code. Then, you can download the code from my github and use it deliberately (I'd appreciate if you link back though).
Here's the first part:
To stay in touch with me, follow @cristi
Cristi Vlad, Self-Experimenter and Author
@cristi wow thats great to hear its way too informative upvoted and followed
you can check me out and upvote if you like
https://steemit.com/technology/@diverse-thinker/a-house-in-a-day-wonders-of-materials