If you don't already have it, install pip for Python 3
Install Google Speech: pip3 install google_speech
Install SoX, with MP3 support.
On Ubuntu and other Debian derivatives: sudo apt-get install sox libsox-fmt-mp3.
Windows users can download binaries on the SoX website, once installed you also need to copy libmad DLL in the directory where you have installed SoX, and to add this directory to your PATH environment variable.
Clone this repository: git clone https://github.com/desbma/GoogleSpeech
Install Google Speech: python3 setup.py install
Install SoX, with MP3 support.
On Ubuntu and other Debian derivatives: sudo apt-get install sox libsox-fmt-mp3.
Windows users can download binaries on the SoX website, once installed you also need to copy libmad DLL in the directory where you have installed SoX, and to add this directory to your PATH environment variable.
Command line usage
Run google_speech -h to get full command line reference.
Examples
Plane stall alarm:
google_speech -l en stall -e delay 0.5 overdrive 20 repeat 5 speed 0.9 gain -5
You can use google_speech from any Python script or module.
Sample code:
from google_speech import Speech
# say "Hello World"
text = "Hello World"
lang = "en"
speech = Speech(text, lang)
speech.play()
# you can also apply audio effects while playing (using SoX)
# see http://sox.sourceforge.net/sox.html#EFFECTS for full effect documentation
sox_effects = ("speed", "1.5")
speech.play(sox_effects)
# save the speech to an MP3 file (no effect is applied)
speech.save("output.mp3")
请发表评论