Text to speech in Python
pythonprogramminglanguage.com
pythonprogramminglanguage.com
Which means it won't work offline or when Google inevitably shuts down the API.
import speech
speech.say('Hola mundo', 'es_ES')
In reverse, to record a sound for three seconds: import sound
r = sound.Recorder('audio.m4a')
r.record(3) # seconds
To recognize it as text: text = speech.recognize('audio.m4a', 'en')[0][0] # sent to Apple serversYou almost never want to use the system Python. Use pyenv[0] to install the version of Python you want, and then create a new virtual environment for each project.
FTA: "Install using pyenv, pipenv or virtualenv.
If you are feeling brave, install with pip:"
I strongly think that if you're going to give advice on how to install, then you'd be better off suggesting:
python3 -m venv speech-venv
./speech-venv/bin/pip install ...
# or activate and use "pip install"I'd rather use standard Python packaging and virtual environments. Conda had a few "funnies", like adding lines to .bashrc interfering with system Python when I tried to use it later (easily fixed and not really a big deal, I just didn't care for it).
A client had some scripts that used it, and from that perspective I guess it saved a little time installing everything but not much. Not enough to have another Python version floating around in my opinion. Easy enough to just use regular Python.
An actual Python TTS engine would have been cool as an introduction to how the algorithms work without needing to learn C++. The performance would always be lacking but that'd not really matter for an introduction.
PyTTSx: cross-platform Python speech synthesis wrapper
https://jugad2.blogspot.in/2013/01/pyttsx-cross-platform-pyt...
Speech synthesis in Python with pyttsx:
https://jugad2.blogspot.in/2014/03/speech-synthesis-in-pytho...
The synthesized voice announcing a train arrival is cool (link in 2nd post above).
import os
os.system("say 'hello world'")