How to convert speech to text in python?
We are living in an age of machines and it is very necessary that we use the simplest way to give commands to the machine. By converting speech into text we save our time as we don’t need to type.
This is also known as speech recognition.
Speech Recognition is a process which converts speech into text and that is understood by the machine. In python there is a library by which we can make the machine to recognize human speech.
Speech recognition saves our time by speaking instead of typing.
For converting speech into text we have to install two libraries of python.
- Speech Recognition library
- PyAudio
PyAudio is a library which helps us to record our audio and then send it to speech Recognition library and then it converts it into text
First we’ll see how to download PyAudio.
- Go to the command prompt.
- Run the following syntax.
Now we have to install Speech Recognition library
- Go to the command prompt.
- Run the following syntax
pip install SpeechRecognition
Now we can easily import it in python and use it.
syntax:-
import speech_recognition or import speech_recognition as sr
Now we can use it in our program.
Now we can record our audio with help of PyAudio and convert it into text with the help of speech recognition.
This is all about converting speech into text in python.