synesthesiam / rhasspy

Rhasspy voice assistant for offline home automation
https://rhasspy.readthedocs.io
MIT License
950 stars 101 forks source link

"Invalid Sample Rate" error from PyAudioRecorder #111

Closed yukdumboobumm closed 4 years ago

yukdumboobumm commented 4 years ago
Traceback (most recent call last):
  File "/usr/share/rhasspy/rhasspy/audio_recorder.py", line 205, in to_recording
    frames_per_buffer=self.frames_per_buffer,
  File "/usr/local/lib/python3.6/dist-packages/pyaudio.py", line 750, in open
    stream = Stream(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
OSError: [Errno -9997] Invalid sample rate
[DEBUG:199527] PyAudioRecorder: started -> recording

Profile:

{
    "intent": {
        "remote": {
            "url": "http://192.168.50.2:12101/api/text-to-intent"
        },
        "system": "remote"
    },
    "microphone": {
        "pyaudio": {
            "device": "2"
        }
    },
    "sounds": {
        "aplay": {
            "device": "default:CARD=seeed2micvoicec"
        }
    },
    "speech_to_text": {
        "remote": {
            "url": "http://192.168.50.2:12101/api/speech-to-text"
        },
        "system": "remote"
    },
    "text_to_speech": {
        "system": "picotts"
    },
    "wake": {
        "snowboy": {
            "model": "snowboy/computer.pmdl",
            "sensitivity": "0.4"
        },
        "system": "snowboy"
    }
}

Wake-word properly wakes the system, but once recording starts the system throws the error and won't recover without a restart.

synesthesiam commented 4 years ago

I notice that you have "default:CARD=seeed2micvoicec" listed as your sounds.aplay.device. That seems odd, since this should be an output device. My guess is that when Rhasspy tries to play the wake-up beep, it produces an error because of this.

yukdumboobumm commented 4 years ago

Thanks for the quick response. Rhasspy will play beep_hi and beep_lo on wake, so I'm not certain that's the issue (FWIW the 2-mic hat also has a 3.5mm audio out that's driving my external speaker).

In any event, your comment gave me the idea to remove the onboard alsa interface. After editing config.txt and rebooting, all is good in the world.

In case anyone else has this issue, I added the following lines to /boot/config.txt:

##turn off onboard alsa interface
dtparam=audio=off
##Added by SEEED installer
dtoverlay=i2s-mmap
dtoverlay=seeed-2mic-voicecard

But I'm not sure why it worked...