Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

sounddevice.PortAudioError: Error opening RawStream: Invalid sample rate [PaErrorCode -9997] #382

Open
newtonsart opened this issue Nov 17, 2019 · 26 comments

Comments

@newtonsart
Copy link

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"
  }
}
@Fleker
Copy link
Contributor

Fleker commented Nov 18, 2019

Looks like a sample rate issue between the code and your hardware device.

@newtonsart
Copy link
Author

newtonsart commented Nov 18, 2019

Is there any way to fix that?

These are my devices:
Speaker
Microphone

@SrDayne
Copy link

SrDayne commented Nov 19, 2019

Hi. Try add "rate" in asound config, like here:

pcm.mic {
  type plug
  slave {
    pcm "hw:1,0"
    rate 16000
  }

@newtonsart
Copy link
Author

@SrDayne still having the same problem

@SrDayne
Copy link

SrDayne commented Nov 20, 2019

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?

@amrky
Copy link

amrky commented Dec 16, 2019

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]

@SrDayne
Copy link

SrDayne commented Dec 19, 2019

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
}

@sangdonyeom
Copy link

sangdonyeom commented Dec 28, 2019

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

@SrDayne
Copy link

SrDayne commented Dec 28, 2019

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.

@sangdonyeom
Copy link

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"
}
}

@SrDayne
Copy link

SrDayne commented Dec 30, 2019

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.

@sangdonyeom
Copy link

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.

@SrDayne
Copy link

SrDayne commented Jan 1, 2020

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.

@sangdonyeom
Copy link

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
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]
now I retry 4times but I don't understand why uu

@sangdonyeom
Copy link

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

@SrDayne
Copy link

SrDayne commented Jan 7, 2020

sangdonyeom, I'm glad to hear that:)

I think, we can close this issue?

@Redblock6YT
Copy link

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]

@SrDayne
Copy link

SrDayne commented Jan 31, 2020

Redblock6YT, show your .audiorc config

@hco125
Copy link

hco125 commented Feb 8, 2020

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

@SrDayne
Copy link

SrDayne commented Feb 8, 2020

hco125, Hi. Looks like this is hardware issue. Show, please, your arecord -l output.

@Redblock6YT
Copy link

@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
Copy link

hco125 commented Feb 8, 2020

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

@SrDayne
Copy link

SrDayne commented Feb 9, 2020

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"
  }
}

@yeunbok2g
Copy link

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
}
}

@ghost
Copy link

ghost commented Dec 24, 2020

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
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 459, in main
continue_conversation = assistant.assist()
File "/home/pi/env/lib/python3.7/site-packages/tenacity/init.py", line 241, in wrapped_f
return self.call(f, *args, **kw)
File "/home/pi/env/lib/python3.7/site-packages/tenacity/init.py", line 330, in call
start_time=start_time)
File "/home/pi/env/lib/python3.7/site-packages/tenacity/init.py", line 279, in iter
return fut.result()
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 425, in result
return self.__get_result()
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/home/pi/env/lib/python3.7/site-packages/tenacity/init.py", line 333, in call
result = fn(*args, **kwargs)
File "/home/pi/env/lib/python3.7/site-packages/googlesamples/assistant/grpc/pushtotalk.py", line 139, in assist
self.deadline):
File "/home/pi/env/lib/python3.7/site-packages/grpc/_channel.py", line 416, in next
return self._next()
File "/home/pi/env/lib/python3.7/site-packages/grpc/_channel.py", line 803, in _next
raise self
grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
status = StatusCode.RESOURCE_EXHAUSTED
details = "Quota exceeded for quota metric 'embedded-assistant-prod/converse_requests' and limit 'ConverseRequestsPerDayPerProject' of service 'embeddedassistant.googleapis.com' for consumer 'project_number:448247344213'."
debug_error_string = "{"created":"@1608776470.560048422","description":"Error received from peer ipv4:142.250.199.74:443","file":"src/core/lib/surface/call.cc","file_line":1063,"grpc_message":"Quota exceeded for quota metric 'embedded-assistant-prod/converse_requests' and limit 'ConverseRequestsPerDayPerProject' of service 'embeddedassistant.googleapis.com' for consumer 'project_number:448247344213'.","grpc_status":8}"

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:

@pengzhendong
Copy link

pengzhendong commented Oct 16, 2022

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants