I'm trying to run two assistants at the same time. On the one hand I can run Alexa without any problems. On the other hand I can run the Google Assistant without any problems.
However when I try to run both at the same time, it gives me errors because one has exclusive access to my microphone.
After some reading I found out about the dsnoop plugin. This should allow me to share the microhpone between applications. So I tried changing my .asoundrc file to use dsnoop.
I tested this with arecord in two terminals and I can record at the same time without any problems. But as soon as I want to start the Google Assistant I get an error:
(Google) pi@Thomas:~ $ googlesamples-assistant-pushtotalk
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/Assistants-Pi/Google/bin/googlesamples-assistant-pushtotalk", line 8, in <module>
sys.exit(main())
File "/home/pi/Assistants-Pi/Google/lib/python3.7/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/home/pi/Assistants-Pi/Google/lib/python3.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/home/pi/Assistants-Pi/Google/lib/python3.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/pi/Assistants-Pi/Google/lib/python3.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/pi/Assistants-Pi/Google/lib/python3.7/site-packages/googlesamples/assistant/grpc/pushtotalk.py", line 351, in main
flush_size=audio_flush_size
File "/home/pi/Assistants-Pi/Google/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/Assistants-Pi/Google/lib/python3.7/site-packages/sounddevice.py", line 1345, in __init__
**_remove_self(locals()))
File "/home/pi/Assistants-Pi/Google/lib/python3.7/site-packages/sounddevice.py", line 861, in __init__
'Error opening {0}'.format(self.__class__.__name__))
File "/home/pi/Assistants-Pi/Google/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 tried entering all different sample rates in my .asoundrc but none seem to work. Does anybody else have this problem or knows how to solve it?
This is how my .asoundrc file now looks (which works for arecord side by side in two terminals):
pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm "output"
}
capture.pcm {
type plug
slave.pcm "input"
}
}
pcm.output {
type hw
card 0
rate 16000
}
ctl.!default {
type hw
card 0
}
pcm.input {
type dsnoop
card 1
}