I am trying a speech-to-text program . I have written this code but it is not showing any output and also not showing any error. It is not reading my speech. Can't find any solution to it. Please help.
import speech_recognition as sr
import webbrowser as wb
r1 = sr.Recognizer()
r2 = sr.Recognizer()
with sr.Microphone() as source:
print('Say Hello')
print('Speak')
audio = r2.listen(source)
if 'Hello' in r1.recognize_google(audio):
r1 = sr.Recognizer()
url = 'https://www.google.com/'
with sr.Microphone() as source:
print('search')
audio = r1.listen(source)
try:
get = r1.recognize_google(audio)
print(get)
wb.get().open_new(url + get)
except sr.UnknownValueError:
print('Not recognised')
except sr.RequestError as e:
print('try again'.format(e))