assistant-sdk-python icon indicating copy to clipboard operation
assistant-sdk-python copied to clipboard

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

Open newtonsart opened this issue 6 years ago • 26 comments

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

newtonsart avatar Nov 17 '19 20:11 newtonsart

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

Fleker avatar Nov 18 '19 15:11 Fleker

Is there any way to fix that?

These are my devices: Speaker Microphone

newtonsart avatar Nov 18 '19 22:11 newtonsart

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

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

SrDayne avatar Nov 19 '19 10:11 SrDayne

@SrDayne still having the same problem

newtonsart avatar Nov 20 '19 17:11 newtonsart

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?

SrDayne avatar Nov 20 '19 22:11 SrDayne

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]

amrky avatar Dec 16 '19 21:12 amrky

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 }

SrDayne avatar Dec 19 '19 10:12 SrDayne

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

sangdonyeom avatar Dec 28 '19 06:12 sangdonyeom

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.

SrDayne avatar Dec 28 '19 10:12 SrDayne

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

sangdonyeom avatar Dec 30 '19 03:12 sangdonyeom

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.

SrDayne avatar Dec 30 '19 11:12 SrDayne

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.

sangdonyeom avatar Jan 01 '20 09:01 sangdonyeom

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.

SrDayne avatar Jan 01 '20 11:01 SrDayne

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 avatar Jan 04 '20 06:01 sangdonyeom

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 avatar Jan 04 '20 12:01 sangdonyeom

sangdonyeom, I'm glad to hear that:)

I think, we can close this issue?

SrDayne avatar Jan 07 '20 10:01 SrDayne

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 avatar Jan 30 '20 02:01 Redblock6YT

Redblock6YT, show your .audiorc config

SrDayne avatar Jan 31 '20 11:01 SrDayne

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 avatar Feb 08 '20 01:02 hco125

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

SrDayne avatar Feb 08 '20 11:02 SrDayne

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

Redblock6YT avatar Feb 08 '20 15:02 Redblock6YT

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 avatar Feb 08 '20 18:02 hco125

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

SrDayne avatar Feb 09 '20 13:02 SrDayne

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

yeunbok2g avatar Mar 02 '20 08:03 yeunbok2g

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: <unprintable PortAudioError object>

ghost avatar Dec 24 '20 02:12 ghost

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

pengzhendong avatar Oct 16 '22 02:10 pengzhendong