How to convert speech to text in python using pyaudio module not using speech recognition how | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

How to convert speech to text in python using pyaudio module not using speech recognition how

Plz help me i just want to make a speech to text but when i run the speechrecognition module in python than he say me "please install pyaudio python binding first but i already install pyaudio and port audio also please developers help me please

21st Apr 2020, 1:00 PM
Asad Khan
Asad Khan - avatar
1 Answer
+ 1
# Python program to translate # speech to text and text to speech import speech_recognition as sr import pyttsx3 # Initialize the recognizer r = sr.Recognizer() # Function to convert text to # speech def SpeakText(command): # Initialize the engine engine = pyttsx3.init() engine.say(command) engine.runAndWait() # Loop infinitely for user to # speak while(1): # Exception handling to handle # exceptions at the runtime try: # use the microphone as source for input. with sr.Microphone() as source2: # wait for a second to let the recognizer # adjust the energy threshold based on # the surrounding noise level r.adjust_for_ambient_noise(source2, duration=0.2) #listens for the user's input audio2 = r.listen(source2) # Using ggogle to recognize audio MyText = r.recognize_google(audio2) MyText = MyText.lower() print("Did you say "+MyText) SpeakText(MyText) except sr.RequestError as e: print("Could not request results; {0}".format(e)) except sr.UnknownValueError: print("unknown error occured")
17th May 2020, 7:12 AM
Prabhat
Prabhat - avatar