Coders Packet

Speech to Text Conversion using SpeechRecognition Library in Python

By Abhishek Joshi

This project aims at converting the recognized input that is speech from user and converting it into text .

Speech to Text Conversion using SpeechRecognition in Python


1. Pyaudio (0.2.11)

2. Speech Recogniton(3.8.1)


Step 1 : Install Pyaudio 0.2.11

Open pycharm or any python ide and in its terminal enter the following command(Before doing this set the path for your python libraries and script in the environment variables of your system and download external python binaries for windows)

pip install PyAudio 

After entering the following command in your terminal you will get an output which states that PyAudio has been installed.

Step 2 : Install SpeechRecognition 3.8.1

After installing Pyaudio enter the following command in your terminal :

pip install SpeechRecognition

Step 3 : Writing the code for speech conversion to text 

Enter the following code in your python project file 


import speech_recognition as  spr

c = spr.Recognizer()
with spr.Microphone() as source:
print("Please speak out :")
audio = c.listen(source)
text = c.recognize_google(audio)
print("Your input was : {}".format(text))
print("Sorry could not recognize what you said")

all the error before executing the above code.
RESULT : Speech to text conversion has been implemented using the SpeechRecognition Library in Python with the help of the above code that
helps us in taking the input from the source that is the user and after that converting it into text and displaying it as an output.

Download Complete Code


No comments yet