Fiz a instalação dos pacotes, tudo certinho, o código abaixo
import speech_recognition as sp
micro = sp.Recognizer()
with sp.Microphone() as source:
print("Às Suas Ordens")
audio = micro.listen(source)
try:
print("Você disse que" + micro.recognize_google(audio,language="pt-BR"))
except sp.UnknownValueError:
print("Não entendi o que você disse")
except sp.RequestError as e:
print("Estou tendo problemas para achar resultados no Google Speech Recognition service; {0}".format(e))
Porém, ao rodar, dá o erro abaixo, podem me ajudar?
PS C:\Users\bruno.souza\Documents\Python\Agrinho> & C:/Users/bruno.souza/AppData/Local/Programs/Python/Python311/python.exe c:/Users/bruno.souza/Documents/Python/Agrinho/audios/agrinho.py
Às Suas Ordens
Traceback (most recent call last):
File "c:\Users\bruno.souza\Documents\Python\Agrinho\audios\agrinho.py", line 7, in <module>
audio = micro.listen(source)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\bruno.souza\AppData\Local\Programs\Python\Python311\Lib\site-packages\speech_recognition\__init__.py", line 465, in listen
assert source.stream is not None, "Audio source must be entered before listening, see documentation for ``AudioSource``; are you using ``source`` outside of a ``with`` statement?"
^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Audio source must be entered before listening, see documentation for ``AudioSource``; are you using ``source`` outside of a ``with`` statement?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\bruno.souza\Documents\Python\Agrinho\audios\agrinho.py", line 5, in <module>
with sp.Microphone() as source:
File "C:\Users\bruno.souza\AppData\Local\Programs\Python\Python311\Lib\site-packages\speech_recognition\__init__.py", line 189, in __exit__
self.stream.close()
^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'close'
PS C:\Users\bruno.souza\Documents\Python\Agrinho>