top of page

Python: Audio to text conversion

This is simple program to convert audio into text. I have used speec_recognition library to do it.

import speech_recognition as sr

r = sr.Recognizer()

with sr.Microphone() as source:

print("Speak Anything :")

audio = r.listen(source)


text = r.recognize_google(audio)

print("You said : {}".format(text))


print("Sorry could not recognize what you said")


Speak Anything : You said : internet is required to access the Google API if there is no internet you will not be able to convert voice into text

to install SpeechRecognition-

one of the dependencies is PyAudio which is not supported after 3.6.

For python verison 3.6+ one needs to download wheel ( and install PyAudio separately.

17 views0 comments


bottom of page