I am trying to test the Python Speech Recognition library for speech recognition and go to text, however when I run the program the cursor stays blinking and does not advance, no errors come out, I have to press Ctrl + C to interrupt it
This is my code, is a only example
import speech_recognition as sr
r = sr.Recognizer()
mic = sr.Microphone(device_index=0)
with mic as source:
print('Di algo: ')
audio = r.listen(source)
try:
text = r.recognize_google(audio, language="es-EC")
print('Tu dijiste:', text)
except:
print('No puedo escucharte')
But it does nothing and doesn't even give me an error or return the exception message stays like this
PS C:\Users\dell\Documents\Cuarentena\Pruebas de reconocimiento de voz> & C:/Users/dell/AppData/Local/Programs/Python/Python38/python.exe "c:/Users/dell/Documents/Cuarentena/Pruebas de reconocimiento de voz/prueba1.py"
Di algo:
|
when i interrupt the program i get this:
File "c:/Users/kathy/Documents/Cuarentena/Pruebas de reconocimiento de voz/prueba1.py", line 9, in <module>
audio = r.listen(source)
File "C:\Users\kathy\AppData\Local\Programs\Python\Python38\lib\site-packages\speech_recognition\__init__.py", line 652, in listen
buffer = source.stream.read(source.CHUNK)
File "C:\Users\kathy\AppData\Local\Programs\Python\Python38\lib\site-packages\speech_recognition\__init__.py", line 161, in read
return self.pyaudio_stream.read(size, exception_on_overflow=False)
File "C:\Users\kathy\AppData\Local\Programs\Python\Python38\lib\site-packages\pyaudio.py", line 608, in read
return pa.read_stream(self._stream, num_frames, exception_on_overflow)
KeyboardInterrupt