6. Add Native C Extensions
In this step you'll modify your Dockerfile and requirements.txt to add one more
dependency for the pyttsx speech-to-text synth. You'll also add one more Python module
and the corresponding native library libespeak. Your app will call the new module
to run the synth.
Edit the project files
requirements.txt
Add another dependency for the pyttsx speech-to-text synthesizer.
Dockerfile
Modify your Dockerfile to install the libespeak-dev binaries
synth.py
Add this file, which uses pyttsx to generate a sound file:
main.py
Use the pyttsx speech-to-text package to read out the fortune messages.
- import tempfile
- call synth.Synth()
- return an audio file speaking the fortune
Test and deploy
Run locally
$ gcloud preview app run ./app.yaml
And visit http://localhost:8080/. Reload the page a few times, then try http://localhost:8080/messages.
Deploy to the cloud
$ gcloud preview app deploy ./app.yaml
Point your browser at your appspot address (http://<your-ap-id>.appspot.com/).
Reload the page a few times, then try http://<your-ap-id>.appspot.com/messages.
Next
Finally, let's take a peek at the VM underlying your app.