There are some ready-made speech recognition packages in PyPI. These include:
apiai
google-cloud-speech
pocketsphinx
SpeechRcognition
watson-developer-cloud
wit
Some software packages (such as wit and apiai) provide some Built-in capabilities beyond basic speech recognition, such as natural language processing to identify speaker intent. Other software packages, such as Google Cloud Speech, focus on speech-to-text conversion.
Among them, SpeechRecognition stands out for its ease of use.
Recognizing speech requires audio input, and retrieving audio input in SpeechRecognition is very simple. It does not require building a script to access the microphone and process the audio file from scratch. It only takes a few minutes to automatically complete the retrieval and run.
But there was a connection timeout problem when installing the relevant voice package through the command: pip3 install SpeechRecognition.
The core of SpeechRecognition is the recognizer class.
The main purpose of the Recognizer API is to recognize speech. Each API has a variety of settings and functions to recognize the speech of the audio source, namely:
recognize_bing(): Microsoft Bing Speech
recognize_google(): Google Web Speech API
recognize_google_cloud(): Google Cloud Speech - requires installation of the google-cloud-speech package
recognize_houndify(): Houndify by SoundHound
recognize_ibm(): IBM Speech to Text
recognize_sphinx() : CMU Sphinx - requires installingPocketSphinx
recognize_wit(): Wit.ai
Of the above seven, only recognition_sphinx() can work offline with the CMU Sphinx engine, the other six need to be connected to the Internet.
So I chose to use recognition_sphinx() for speech recognition.
When using pip3 install PocketSphinx to download related libraries, the following problems occurred:
I checked a lot of information, but the installation still failed! ! !
You should use sudo apt install python-pocketsphinx
before using pip3 install PocketSphinx
. Then use pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple PocketSphinx
This command should install successfully. If it still fails, you can use the command sudo apt-get install python python-all-dev python-pip build-essential swig git libpulse-dev libasound2-dev
. Generally this problem occurs due to lack of relevant dependencies!
The above is the detailed content of How to install PocketSphinx under Linux. For more information, please follow other related articles on the PHP Chinese website!