Hello, Alex!
The record.py script at https://github.com/OpenAcousticDevices/Application-Notes/blob/master/Using_the_AudioMoth_USB_Microphone_Firmware_and_Hardware/record.py is not running. I have tried to fix it with no results. This is the error I get:
Expression 'paInvalidSampleRate' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2048
Expression 'PaAlsaStreamComponent_InitialConfigure( &self->capture, inParams, self->primeBuffers, hwParamsCapture, &realSr )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2718
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2842
Traceback (most recent call last):
File "/home/pi/record.py", line 29, in <module>
stream = audio.open(format=audio_format, rate=sample_rate, channels=number_of_channels, input_device_index=device_index, input=True, frames_per_buffer=chunk_size)
File "/home/pi/.local/lib/python3.9/site-packages/pyaudio/__init__.py", line 639, in open
stream = PyAudio.Stream(self, *args, **kwargs)
File "/home/pi/.local/lib/python3.9/site-packages/pyaudio/__init__.py", line 441, in __init__
self._stream = pa.open(**arguments)
OSError: [Errno -9997] Invalid sample rate
Could you have a look? Any advice is appreciated!
Thanks!
Antonio.
Make sure the sample rate specified in the script matches the sample rate that the AudioMoth USB Microphone is configured to use - normally 384kHz if left at default. The command line AudioMoth Live and arecord applications will resample if the requested sample rate doesn't match the hardware sample rate, but pyaudio doesn't seem to support this - it just reads raw data from the hardware device.