Traceback (most recent call last):
File "F:\code\python\cat 2.0\main.py", line 8, in <module>
audio = r.listen(source)
^^^^^^^^^^^^^^^^
File "C:\Users\Тимур\AppData\Local\Programs\Python\Python312\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 "F:\code\python\cat 2.0\main.py", line 6, in <module>
with mic as source:
File "C:\Users\Тимур\AppData\Local\Programs\Python\Python312\Lib\site-packages\speech_recognition\__init__.py", line 189, in __exit__
self.stream.close()
^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'close'
File "F:\code\python\cat 2.0\main.py", line 3, in <module>
mic = sr.Microphone(device_index=9)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Тимур\AppData\Local\Programs\Python\Python312\Lib\site-packages\speech_recognition\__init__.py", line 88, in __init__
assert isinstance(device_info.get("defaultSampleRate"), (float, int)) and device_info["defaultSampleRate"] > 0, "Invalid device info returned from PyAudio: {}".format(device_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Invalid device info returned from PyAudio: {'index': 9, 'structVersion': 2, 'name': '', 'hostApi': 2, 'maxInputChannels': 0, 'maxOutputChannels': 0, 'defaultLowInputLatency': 0.0, 'defaultLowOutputLatency': 0.0, 'defaultHighInputLatency': 0.0, 'defaultHighOutputLatency': 0.0, 'defaultSampleRate': 0.0}
import speech_recognition as sp
mic = sp.Microphone()
list_mic = sp.Microphone.list_microphone_names()
for i in range(0, len(list_mic)):
print(i, list_mic[i])
0 Microsoft Sound Mapper - Input
1 Набор микрофонов (Realtek(R) Au
2 Microsoft Sound Mapper - Output
3 Наушники (Realtek(R) Audio)
4 Динамики (Realtek(R) Audio)
5 Первичный драйвер записи звука
6 Набор микрофонов (Realtek(R) Audio)
7 Первичный звуковой драйвер
8 Динамики (Realtek(R) Audio)
9
10 Динамики (Realtek(R) Audio)
11
12 Стерео микшер (Realtek HD Audio Stereo input)
13 Набор микрофонов 1 (Realtek HD Audio Mic input with SST)
14 Набор микрофонов 2 (Realtek HD Audio Mic input with SST)
15 Speakers 1 (Realtek HD Audio output with SST)
16 Speakers 2 (Realtek HD Audio output with SST)
17 Динамик ПК (Realtek HD Audio output with SST)
18 Headphones 1 (Realtek HD Audio 2nd output with SST)
19 Headphones 2 (Realtek HD Audio 2nd output with SST)
20 Динамик ПК (Realtek HD Audio 2nd output with SST)