I have tried for numbers from 1 to 10 and it works well but i need it to work with all the numbers and it is not feasible to write the code for each number. I also need it to work in sentences too which is not happening in my code. Help me out guys, please.... This is my code....
import speech_recognition as sr
import time
t = ['one','two','three','four','five','six','seven','eight','nine','ten']
r = sr.Recognizer()
with sr.Microphone() as source:
print('Speak anything: ')
audio = r.listen(source)
try:
text = r.recognize_google(audio)
print('You said : {} '.format(text))
time.sleep(1)
for i in range(0,10):
if (t[i] == text):
print('/n',i)
except:
print('Sorry could not recogonize your voice')