sounddevice.PortAudioError: Error opening RawStream: Invalid sample rate [PaErrorCode -9997]
INFO:root:Connecting to embeddedassistant.googleapis.com
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: 2719
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2843
Traceback (most recent call last):
File "/home/pi/env/bin/googlesamples-assistant-pushtotalk", line 8, in <module>
sys.exit(main())
File "/home/pi/env/lib/python3.7/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/home/pi/env/lib/python3.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/home/pi/env/lib/python3.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/pi/env/lib/python3.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/pi/env/lib/python3.7/site-packages/googlesamples/assistant/grpc/pushtotalk.py", line 351, in main
flush_size=audio_flush_size
File "/home/pi/env/lib/python3.7/site-packages/googlesamples/assistant/grpc/audio_helpers.py", line 190, in __init__
blocksize=int(block_size/2), # blocksize is in number of frames.
File "/home/pi/env/lib/python3.7/site-packages/sounddevice.py", line 1345, in __init__
**_remove_self(locals()))
File "/home/pi/env/lib/python3.7/site-packages/sounddevice.py", line 861, in __init__
'Error opening {0}'.format(self.__class__.__name__))
File "/home/pi/env/lib/python3.7/site-packages/sounddevice.py", line 2653, in _check
raise PortAudioError(errormsg, err)
sounddevice.PortAudioError: Error opening RawStream: Invalid sample rate [PaErrorCode -9997]
I keep getting that message everytime i try to run googlesamples-assistant-pushtotalk And i have correctly configured ~/.asoundrc because the speaker and the microphone works when i run speaker-test, arecord and aplay.
This is the ~/.asoundrc file if you need it...
pcm.!default {
type asym
capture.pcm "mic"
playback.pcm "speaker"
}
pcm.mic {
type plug
slave {
pcm "hw:1,0"
}
}
pcm.speaker {
type plug
slave {
pcm "hw:0,0"
}
}
Looks like a sample rate issue between the code and your hardware device.
Hi. Try add "rate" in asound config, like here:
pcm.mic {
type plug
slave {
pcm "hw:1,0"
rate 16000
}
@SrDayne still having the same problem
Try different speach-to-text software. For example, Snowboy. But, I'm on 98% sure, that problem in microfone settings. And when you recorded by arecord, what frequency did you use?
i have the same issue :/ please help
INFO:root:Connecting to embeddedassistant.googleapis.com
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: 2719
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2843
Traceback (most recent call last):
File "/home/pi/env/bin/googlesamples-assistant-pushtotalk", line 8, in
i have the same issue :/ please help
INFO:root:Connecting to embeddedassistant.googleapis.com 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: 2719 Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2843 Traceback (most recent call last): File "/home/pi/env/bin/googlesamples-assistant-pushtotalk", line 8, in sys.exit(main()) File "/home/pi/env/lib/python3.7/site-packages/click/core.py", line 722, in call return self.main(*args, **kwargs) File "/home/pi/env/lib/python3.7/site-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/home/pi/env/lib/python3.7/site-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/pi/env/lib/python3.7/site-packages/click/core.py", line 535, in invoke return callback(*args, **kwargs) File "/home/pi/env/lib/python3.7/site-packages/googlesamples/assistant/grpc/pushtotalk.py", line 351, in main flush_size=audio_flush_size File "/home/pi/env/lib/python3.7/site-packages/googlesamples/assistant/grpc/audio_helpers.py", line 190, in init blocksize=int(block_size/2), # blocksize is in number of frames. File "/home/pi/env/lib/python3.7/site-packages/sounddevice.py", line 1345, in init **_remove_self(locals())) File "/home/pi/env/lib/python3.7/site-packages/sounddevice.py", line 861, in init 'Error opening {0}'.format(self.class.name)) File "/home/pi/env/lib/python3.7/site-packages/sounddevice.py", line 2653, in _check raise PortAudioError(errormsg, err) sounddevice.PortAudioError: Error opening RawStream: Invalid sample rate [PaErrorCode -9997]
Hi. First of all, what is your microfone model? Second, same problem = same solution. Try this, but I'm not sure about correct frequency:
pcm.mic { type plug slave { pcm "hw:1,0" rate 16000 }
I have the same problem, please give me solution this on taskbar, sound mark has x the strange thing is speaker and min are work very well
but when I write down like "googlesamples-assistant-pushtotalk --project-id friday-xxxxx --device-model-id friday-aed12-friday-xxxxxx" error appear like this
I have the same problem, please give me solution this on taskbar, sound mark has x the strange thing is speaker and min are work very well
but when I write down like "googlesamples-assistant-pushtotalk --project-id friday-xxxxx --device-model-id friday-aed12-friday-xxxxxx" error appear like this
Hi. Tell me, please, your hardware model, your os and your .asoundrc config.
I have the same problem, please give me solution this on taskbar, sound mark has x the strange thing is speaker and min are work very well but when I write down like "googlesamples-assistant-pushtotalk --project-id friday-xxxxx --device-model-id friday-aed12-friday-xxxxxx" error appear like this
Hi. Tell me, please, your hardware model, your os and your .asoundrc config. raspberry pi 4 4g , 3.5pi jact connected with speaker and usb Mic and my .asoundrc like below pcm.!default { type asym capture.pcm "mic" playback.pcm "speaker" } pcm.mic { type plug slave { pcm "hw:1,0" } } pcm.speaker { type plug slave { pcm "hw:0,0" } }
I have the same problem, please give me solution this on taskbar, sound mark has x the strange thing is speaker and min are work very well but when I write down like "googlesamples-assistant-pushtotalk --project-id friday-xxxxx --device-model-id friday-aed12-friday-xxxxxx" error appear like this
Hi. Tell me, please, your hardware model, your os and your .asoundrc config. raspberry pi 4 4g , 3.5pi jact connected with speaker and usb Mic and my .asoundrc like below pcm.!default { type asym capture.pcm "mic" playback.pcm "speaker" } pcm.mic { type plug slave { pcm "hw:1,0" } } pcm.speaker { type plug slave { pcm "hw:0,0" } }
Ensure that your microfone support 16kHz frequency of sound. If no, try to find out what frequency it supports.
I have the same problem, please give me solution this on taskbar, sound mark has x the strange thing is speaker and min are work very well but when I write down like "googlesamples-assistant-pushtotalk --project-id friday-xxxxx --device-model-id friday-aed12-friday-xxxxxx" error appear like this
Hi. Tell me, please, your hardware model, your os and your .asoundrc config. raspberry pi 4 4g , 3.5pi jact connected with speaker and usb Mic and my .asoundrc like below pcm.!default { type asym capture.pcm "mic" playback.pcm "speaker" } pcm.mic { type plug slave { pcm "hw:1,0" } } pcm.speaker { type plug slave { pcm "hw:0,0" } }
Ensure that your microfone support 16kHz frequency of sound. If no, try to find out what frequency it supports.
Yes, my mic support to frequency 100-16kHz
and I also insert rate 16000 in .asound
but still have problem.
I have the same problem, please give me solution this on taskbar, sound mark has x the strange thing is speaker and min are work very well but when I write down like "googlesamples-assistant-pushtotalk --project-id friday-xxxxx --device-model-id friday-aed12-friday-xxxxxx" error appear like this
Hi. Tell me, please, your hardware model, your os and your .asoundrc config. raspberry pi 4 4g , 3.5pi jact connected with speaker and usb Mic and my .asoundrc like below pcm.!default { type asym capture.pcm "mic" playback.pcm "speaker" } pcm.mic { type plug slave { pcm "hw:1,0" } } pcm.speaker { type plug slave { pcm "hw:0,0" } }
Ensure that your microfone support 16kHz frequency of sound. If no, try to find out what frequency it supports.
Yes, my mic support to frequency 100-16kHz
and I also insert rate 16000 in .asound
but still have problem.
Problem can be also with speaker. For example, I'm using bluetooth speaker, and when it turned off, assistant gives me the same error. Show your whole error log.
I have the same problem, please give me solution this on taskbar, sound mark has x the strange thing is speaker and min are work very well but when I write down like "googlesamples-assistant-pushtotalk --project-id friday-xxxxx --device-model-id friday-aed12-friday-xxxxxx" error appear like this
Hi. Tell me, please, your hardware model, your os and your .asoundrc config. raspberry pi 4 4g , 3.5pi jact connected with speaker and usb Mic and my .asoundrc like below pcm.!default { type asym capture.pcm "mic" playback.pcm "speaker" } pcm.mic { type plug slave { pcm "hw:1,0" } } pcm.speaker { type plug slave { pcm "hw:0,0" } }
Ensure that your microfone support 16kHz frequency of sound. If no, try to find out what frequency it supports.
Yes, my mic support to frequency 100-16kHz and I also insert rate 16000 in .asound but still have problem.
Problem can be also with speaker. For example, I'm using bluetooth speaker, and when it turned off, assistant gives me the same error. Show your whole error log.
(env) pi@raspberrypi:~ $ googlesamples-assistant-pushtotalk --project-id friday-aed12 --device-model-id friday-aed12-friday-c6hnxt
INFO:root:Connecting to embeddedassistant.googleapis.com
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: 2719
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2843
Traceback (most recent call last):
File "/home/pi/env/bin/googlesamples-assistant-pushtotalk", line 8, in
just add "rate 16000" for output like below pcm.!default { type asym capture.pcm "input" playback.pcm "output" } pcm.input { type plug slave { pcm "hw:1,0" } } pcm.output { type plug slave { pcm "hw:0,0" rate 16000 } } Thanks srdayne
sangdonyeom, I'm glad to hear that:)
I think, we can close this issue?
I'm having the same issue. I cant figure it out. I've tried everything.. Please help me.
Error:
INFO:root:Connecting to embeddedassistant.googleapis.com 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: 2719 Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2843 Traceback (most recent call last): File "/root/env/bin/googlesamples-assistant-pushtotalk", line 8, in <module> sys.exit(main()) File "/root/env/lib/python3.7/site-packages/click/core.py", line 722, in __call__ return self.main(*args, **kwargs) File "/root/env/lib/python3.7/site-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/root/env/lib/python3.7/site-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "/root/env/lib/python3.7/site-packages/click/core.py", line 535, in invoke return callback(*args, **kwargs) File "/root/env/lib/python3.7/site-packages/googlesamples/assistant/grpc/pushtotalk.py", line 351, in main flush_size=audio_flush_size File "/root/env/lib/python3.7/site-packages/googlesamples/assistant/grpc/audio_helpers.py", line 190, in __init__ blocksize=int(block_size/2), # blocksize is in number of frames. File "/root/env/lib/python3.7/site-packages/sounddevice.py", line 1345, in __init__ **_remove_self(locals())) File "/root/env/lib/python3.7/site-packages/sounddevice.py", line 861, in __init__ 'Error opening {0}'.format(self.__class__.__name__)) File "/root/env/lib/python3.7/site-packages/sounddevice.py", line 2653, in _check raise PortAudioError(errormsg, err) sounddevice.PortAudioError: Error opening RawStream: Invalid sample rate [PaErrorCode -9997]
Redblock6YT, show your .audiorc config
Same problem?
Platform: Raspberry Pi 3B+ OS: Raspbian GNU/Linux 9 (stretch) Attempting: Implementing Google Assistant on my RPi per instructions HERE.
All steps up to Step 5 under the heading "Authorizing your Raspberry Pi for the Google Assistant" work smoothly.
The ~/.asoundrc file allows the speaker and microphone testing outlined in the URL above to work properly.
pcm.!default {
type asym
capture.pcm "mic"
playback.pcm "speaker"
}
pcm.speaker {
type plug
slave {
pcm "hw:0,0"
}
}
pcm.mic {
type plug
slave {
pcm "hw:1,0"
}
}
Upon entering this line inside a python environment in the terminal (replacing <projectid> and <deviceid> with my personal specifics),
(env) pi@raspberrypi:~ $ googlesamples-assistant-pushtotalk --project-id <projectid> --device-model-id <deviceid>
I get the following error:
INFO:root:Connecting to embeddedassistant.googleapis.com
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: 2719
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2843
Traceback (most recent call last):
File "/home/pi/env/bin/googlesamples-assistant-pushtotalk", line 8, in <module>
sys.exit(main())
File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/pi/env/lib/python3.5/site-packages/googlesamples/assistant/grpc/pushtotalk.py", line 351, in main
flush_size=audio_flush_size
File "/home/pi/env/lib/python3.5/site-packages/googlesamples/assistant/grpc/audio_helpers.py", line 190, in __init__
blocksize=int(block_size/2), # blocksize is in number of frames.
File "/home/pi/env/lib/python3.5/site-packages/sounddevice.py", line 1345, in __init__
**_remove_self(locals()))
File "/home/pi/env/lib/python3.5/site-packages/sounddevice.py", line 861, in __init__
'Error opening {0}'.format(self.__class__.__name__))
File "/home/pi/env/lib/python3.5/site-packages/sounddevice.py", line 2653, in _check
raise PortAudioError(errormsg, err)
sounddevice.PortAudioError: Error opening RawStream: Invalid sample rate [PaErrorCode -9997]
I have attempted to modify my .asoundrc file by adding the 'rate 16000' bit as described throughout this thread. Not only do I get the same error when running googlesamples-assistant-pushtotalk commands after updating .asoundrc this way, but this also causes failure of the microphone testing procedures that were working before.
Updated ~/.asoundrc file:
pcm.!default {
type asym
capture.pcm "mic"
playback.pcm "speaker"
}
pcm.speaker {
type plug
slave {
pcm "hw:0,0"
}
}
pcm.mic {
type plug
slave {
pcm "hw:1,0"
rate 16000
}
}
Then (not in Python environment now), I run this command:
arecord --format=S16_LE --duration=5 --rate=16000 --file-type=raw out.raw
and get this error:
Recording raw data 'out.raw' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono ALSA lib pcm_params.c:2162:(snd1_pcm_hw_refine_slave) Slave PCM not usable arecord: set_params:1270: Broken configuration for this PCM: no configurations available
hco125, Hi. Looks like this is hardware issue. Show, please, your arecord -l output.
@SrDayne My arecord -l output:
root@raspberrypi:~# arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
My .asoundrc:
pcm.!default { type asym capture.pcm "input" playback.pcm "output" } pcm.input { type plug slave { pcm "hw:1,0" } } pcm.output { type plug slave { pcm "hw:0,0" rate 16000 } }
hco125, Hi. Looks like this is hardware issue. Show, please, your arecord -l output.
SrDayne, thanks! here is my output of arecord -l:
**** List of CAPTURE Hardware Devices ****
card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
hco125, that's very starnge issue. I copied your config and tried to run it on my PI3, but had the same issue. Than I corrected your config like mine, so they looks similar. And had the same issue. I copied both to check them by online compairing and it showed no difference. I don't now what exactly cause the issue but it is definitely in your config. Try mine:
pcm.!default {
type asym
capture.pcm "mic"
playback.pcm "speaker"
}
pcm.mic {
type plug
slave {
pcm "hw:1,0"
rate 48000
}
}
pcm.speaker {
type plug
slave {
pcm "hw:0,0"
}
}
Thanks, sangdonyeom's way works for me.
just add "rate 16000" for output like below
pcm.!default { type asym capture.pcm "input" playback.pcm "output" } pcm.input { type plug slave { pcm "hw:1,0" } } pcm.output { type plug slave { pcm "hw:0,0" > rate 16000 } }
i am give to same error
my is .asoundrc
pcm.!default {
type asym
capture.pcm "mic"
playback.pcm "speaker"
}
pcm.mic {
type plug
slave {
pcm "hw:1,0"
rate 8000
}
}
pcm.speaker {
type plug
slave {
pcm "hw:0,0"
}
}
my error is
--device-model-id turnkey-citadel-243111-raspberry3b+-4rm1uu
INFO:root:Connecting to embeddedassistant.googleapis.com
INFO:root:Using device model turnkey-citadel-243111-raspberry3b+-4rm1uu and device id d95da70e-450e-11eb-baf5-b827eb6f8583
Press Enter to send a new request...
INFO:root:Recording audio request.
Traceback (most recent call last):
File "/home/pi/env/bin/googlesamples-assistant-pushtotalk", line 8, in
Expression 'alsa_snd_pcm_mmap_begin( self->pcm, &areas, &self->offset, numFrames )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3983 Expression 'PaAlsaStreamComponent_RegisterChannels( &self->capture, &self->bufferProcessor, &captureFrames, &xrun )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 4098 Expression 'PaAlsaStream_SetUpBuffers( stream, &framesGot, &xrun )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 4426 ERROR:grpc._channel:Exception iterating requests! Traceback (most recent call last): File "/home/pi/env/lib/python3.7/site-packages/grpc/_channel.py", line 195, in consume_request_iterator request = next(request_iterator) File "/home/pi/env/lib/python3.7/site-packages/googlesamples/assistant/grpc/pushtotalk.py", line 131, in iter_log_assist_requests for c in self.gen_assist_requests(): File "/home/pi/env/lib/python3.7/site-packages/googlesamples/assistant/grpc/pushtotalk.py", line 217, in gen_assist_requests for data in self.conversation_stream: File "/home/pi/env/lib/python3.7/site-packages/googlesamples/assistant/grpc/audio_helpers.py", line 339, in iter yield self.read(self._iter_size) File "/home/pi/env/lib/python3.7/site-packages/googlesamples/assistant/grpc/audio_helpers.py", line 320, in read return self._source.read(size) File "/home/pi/env/lib/python3.7/site-packages/googlesamples/assistant/grpc/audio_helpers.py", line 198, in read buf, overflow = self._audio_stream.read(size) File "/home/pi/env/lib/python3.7/site-packages/sounddevice.py", line 1196, in read _check(err) File "/home/pi/env/lib/python3.7/site-packages/sounddevice.py", line 2651, in _check raise PortAudioError(errormsg, err, hosterror_info) sounddevice.PortAudioError: <unprintable PortAudioError object>
just add "rate 16000" for output like below pcm.!default { type asym capture.pcm "input" playback.pcm "output" } pcm.input { type plug slave { pcm "hw:1,0" } } pcm.output { type plug slave { pcm "hw:0,0" rate 16000 } } Thanks srdayne
Ubuntu works. Raspberry PI OS should install pulseaudio and reboot first.
sudo apt-get install pulseaudio