File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
Code-Sleep-Python/speech-to-text Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change 11import speech_recognition as sr
22
33r = sr .Recognizer ()
4+ flag = 1
5+ while flag = 1 :
6+
7+ with sr .Microphone () as source :
8+ print ("Say something... " )
9+ audio = r .listen (source )
410
5- with sr .Microphone () as source :
6- print ("Say something... " )
7- audio = r .listen (source )
8-
9- try :
10- print ("Google thinks you said: {}" .format (r .recognize_google (audio )))
11- except sr .UnkownValueError :
12- print ("Couldn't understand" )
13- except sr .RequestError as e :
14- print ("Couldn't request results; {}" .format (e ))
11+ try :
12+ print ("Google thinks you said: {}" .format (r .recognize_google (audio )))
13+ flag = 0
14+ except sr .UnkownValueError :
15+ print ("Couldn't understand your voice. Please speak again." )
16+ except sr .RequestError as e :
17+ print ("Couldn't request results. Please speak again.; {}" .format (e ))
You can’t perform that action at this time.
0 commit comments