selecting a specific microphone leads to issues
souviktor opened this issue · comments
I am using a USB microphone that supports 44100 and 4800 HZ as sampling rate.
When I use
Get microphone stream
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 16000
RATE = 44100
CHUNK = 4096
audio = pyaudio.PyAudio()
mic_stream = audio.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, frames_per_buffer=CHUNK)
The code works fine, but when I specify the specific mic,
MIC_INDEX = 0
Get microphone stream
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 16000
RATE = 44100
CHUNK = 4096
audio = pyaudio.PyAudio()
mic_stream = audio.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, frames_per_buffer=CHUNK)
mic_stream = audio.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, frames_per_buffer=CHUNK, input_device_index=MIC_INDEX)
I get the following error
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
Model Name | Score | Wakeword Status
--------------------------------------
screen_off | 0.000 | -- #####################################
play_my_messages | 0.000 | --
take_a_selfie | 0.000 | -- #####################################
close_door | 0.000 | --
window_mode | 0.000 | --
selfie_mode | 0.000 | --
open_door | 0.000 | --
Traceback (most recent call last):
File "/home/souvik/localapp/bdd/engine/agent1.py", line 96, in
audio = np.frombuffer(mic_stream.read(CHUNK), dtype=np.int16)
File "/home/souvik/localapp/bdd/localenv/lib/python3.10/site-packages/pyaudio/init.py", line 570, in read
return pa.read_stream(self._stream, num_frames,
OSError: [Errno -9981] Input overflowed
Any pointers on why is this happenning?
pyaudio
can be difficult to setup when you have multiple audio devices. I would recommend testing the script separately without openWakeWord
to ensure that the pyaudio
configuration is working correctly.
Also, note the openWakeWord
only supports 16khz audio.