Speech Recognition in Hindi using Python
We can use Python for Speech Recognition, it is mostly used to recognize English words. However, in this article, we are going to use Python so that it can also recognize Hindi words with the help of the Speech Recognition module.
- Speech Recognition Module: It is a library with the help of which Python can recognize the command given. We have to use pip for Speech Recognition.
pip install SpeechRecognition
- PyAudio Module: It is a set of Python bindings for PortAudio, a cross-platform C++ library interfacing with audio drivers. We need to also install Pyaudio as the Speech Recognition module is dependent on it.
pip install PyAudio
If the above command doesn’t work in windows then use the below commands in the windows command prompt:
pip install pipwin
pipwin install pyaudio
We will use Google Speech Recognition API for letting the software understand Hindi. We will assign language as hn-IN.
Below is the complete Python program to take input commands in Hindi and to recognize them:
speech_recognition as sr
with sr.Microphone() as source:
"the query is printed='"
Exception as e:
"Say that again sir"