Currently supported methods:
- Google from SpeechRecognition
- Sphinx from SpeechRecognition
- Houndify from SpeechRecognition
- Wit from SpeechRecognition
- DeepSpeech by Mozilla
Run:
python3 stt_wrapper.py # use default STT method
python3 stt_wrapper.py deepspeech # specify STT method
the script will try to find a file called output.wav
in the audio
directory. If it doesn't exist, it will record audio and save it as output.wav
. It will then transcribe the audio file using the specified method, or the default method (Google from SpeechRecognition) if no argument is provided.
Here's how you can use this Speech-to-Text wrapper from a script:
from stt_wrapper import generate_text
filename = "output.wav"
for method in ['google', 'sphinx', 'deepspeech']:
text = generate_text(filename, method=method)
print("--> {}: {}".format(method, text))
python3 tts_pyttsx3.py
python3 tts_mozilla.py
python3 -m pip install --user -r requirements.txt
PyAudio
sudo apt-get install -y portaudio19-dev python-pyaudio python3-pyaudio
python3 -m pip install pyaudio
PocketSphinx
sudo apt-get install python-all-dev python-pip build-essential swig git libpulse-dev libasound2-dev
python3 -m pip install pocketsphinx
DeepSpeech
# Download pre-trained English model and extract
curl -LO https://github.com/mozilla/DeepSpeech/releases/download/v0.6.1/deepspeech-0.6.1-models.tar.gz
tar xvf deepspeech-0.6.1-models.tar.gz
TTS
git clone https://github.com/mozilla/TTS.git
cd TTS & python setup.py develop --user