I will introduce the recognition online (with wifi) and the recognition offline (without wifi) respectively.
ubuntu 18.04 python3
Use google. Install the environment with the following command.
python
pip3 install SpeechRecognition --user
sudo apt-get install portaudio19-dev
sudo apt-get install python-pyaudio python3-pyaudio
pip3 install pyaudio
Operation check
google_test.py
import speech_recognition as sr
# get audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
r.adjust_for_ambient_noise(source)
print("Speak:")
audio = r.listen(source)
try:
print("-----------detect!----------\n",r.recognize_google(audio))
except sr.UnknownValueError:
print("Could not understand audio")
except sr.RequestError as e:
print("Could not request results; {0}".format(e))
I think the accuracy is relatively good
Use pocketsphinx. Install the environment with the following command.
python
sudo apt-get install -y python python-dev python-pip build-essential swig git libpulse-dev
sudo apt-get install libasound2-dev
git clone https://github.com/cmusphinx/pocketsphinx-python.git
sudo pip install pocketsphinx
Operation check
pocket_test.py
from pocketsphinx import LiveSpeech
for phrase in LiveSpeech():
print("-----------detect!----------\n",phrase)
If the characters are output, it is successful.
"https://pypi.org/project/pocketsphinx/" Please refer to the various sample codes on this page.
You can improve the accuracy by creating your own dictionary and limiting the sentences that can be recognized. I will show you how to make your own dictionary at a later date. 2020/8/16: Updated about original dictionary ↓ "https://qiita.com/hir-osechi/items/7d1b100c721f34896a90"
Recommended Posts