Invalid Sample Rate

Hi.

I’m in the process of trying to set up Rhasspy, and I’ve run into a problem when I train it on my profile:

Traceback (most recent call last):
File “/usr/share/rhasspy/rhasspy/audio_recorder.py”, line 170, in to_recording
frames_per_buffer=self.frames_per_buffer,
File “/usr/share/rhasspy/.venv/lib/python3.7/site-packages/pyaudio.py”, line 750, in open
stream = Stream(self, *args, **kwargs)
File “/usr/share/rhasspy/.venv/lib/python3.7/site-packages/pyaudio.py”, line 441, in init
self._stream = pa.open(**arguments)
OSError: [Errno -9997] Invalid sample rate

My environment is:

  • Raspberry Pi 4B, running Raspbian Buster
  • Installed into Docker
  • Python 3.7.3
  • Porcupine wake handling

I assume this error springs from PyAudio or ALSA. When I originally encountered the same error message, earlier in the setup, I edited my .asoundrc and alsa.conf files, and that all seemed fine, the error went away. After that, I was able to get pvporcupine_mic and the Python SpeechRecognition commands to work ok. Everything seemed fine until I tried the training, when the error returned.

This is my currnent profile:

{
“sounds”: {
“system”: “dummy”
},
“text_to_speech”: {
“system”: “dummy”
},
“wake”: {
“porcupine”: {
“keyword_path”: “porcupine/picovoice_raspberry-pi.ppn”
},
“system”: “porcupine”
}
}

My best guess is that editing the .asoundrc and alsa.conf files doesn’t mean the new settings are available to Rhasspy, inside its Docker environment.

I can provide more diagnostics if there’s anything useful I’ve missed. I’ll stress that for much of the setup process, I’ve simply tried to follow the online instructions by rote, as there’s much I’m unfamiliar with, so please bear with me if I’ve missed something obvious, or if I don’t immediately grasp the technicalities of a response here.

Cheers
John

I’ve now re-installed Rhasspy in a Python virtual environment, but I’m running into the same (or very similar) error as before. So that appears to rule out a Docker-related problem.

I’m assuming the issue is somwhere between the microphone (as it’s a “sample rate” error) and Rhasspy. I’ve tried the microphone with the Porcupine wake-word utility, I’ve recorded spoken messages, and I’ve tried it with a Google speech recognition function, so I know the mike is working. This is the error I get from the virtual environment when I click Rhasspy’s Train button:

[ERROR:41290] PyAudioRecorder: to_recording
Traceback (most recent call last):
File “/home/jd/rhasspy/rhasspy/audio_recorder.py”, line 170, in to_recording
frames_per_buffer=self.frames_per_buffer,
File “/home/jd/rhasspy/.venv/lib/python3.7/site-packages/pyaudio.py”, line 750, in open
stream = Stream(self, *args, **kwargs)
File “/home/jd/rhasspy/.venv/lib/python3.7/site-packages/pyaudio.py”, line 441, in init
self.stream = pa.open(**arguments)
OSError: [Errno -9997] Invalid sample rate
[INFO:41278] quart.serving: 192.168.1.81:58252 POST /api/train 1.1 500 17 109233
[ERROR:41264] main: Training failed:
Traceback (most recent call last):
File “/home/jd/rhasspy/.venv/lib/python3.7/site-packages/quart/app.py”, line 1471, in full_dispatch_request
result = await self.dispatch_request(request_context)
File “/home/jd/rhasspy/.venv/lib/python3.7/site-packages/quart/app.py”, line 1519, in dispatch_request
return await handler(**request
.view_args)
File “app.py”, line 640, in api_train
raise Exception(f"Training failed: {result.reason}")
Exception: Training failed:

Can anyone suggest where I might go from here?

Cheers
John