import speech_recognition
sr = speech_recognition.Recognizer()
with speech_recognition.Microphone() as mic:
sr.adjust_for_ambient_noise(source=mic, duration=0.5)
audio = sr.listen(source=mic)
query = sr.recognize_google(audio_data=audio, language='ru-RU').lower()
print(query)
Делаю гс ассистента, но он почему то не распознает голос, микрофон работает везде нормально, если нужно после остановки кода выскакивает ошибка
Traceback (most recent call last):
File "C:\Users\WakbaN\AppData\Roaming\JetBrains\PyCharmCE2023.2\light-edit\cscase.py", line 7, in <module>
audio = sr.listen(source=mic)
File "C:\Users\WakbaN\AppData\Local\Programs\Python\Python38\lib\site-packages\speech_recognition\__init__.py", line 523, in listen
buffer = source.stream.read(source.CHUNK)
File "C:\Users\WakbaN\AppData\Local\Programs\Python\Python38\lib\site-packages\speech_recognition\__init__.py", line 199, in read
return self.pyaudio_stream.read(size, exception_on_overflow=False)
File "C:\Users\WakbaN\AppData\Local\Programs\Python\Python38\lib\site-packages\pyaudio\__init__.py", line 570, in read
return pa.read_stream(self._stream, num_frames,
KeyboardInterrupt
Process finished with exit code -1073741510 (0xC000013A: interrupted by Ctrl+C)