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

Can’t get past the 'Verify audio setup' step #4

Closed
stursby opened this issue Apr 28, 2017 · 25 comments
Closed

Can’t get past the 'Verify audio setup' step #4

stursby opened this issue Apr 28, 2017 · 25 comments
Labels

Comments

@stursby
Copy link

stursby commented Apr 28, 2017

I'm trying to get this demo working, but getting stuck at the 'Verify audio setup' step.

I'm running this command --> python -m googlesamples.assistant.audio_helpers

And get the following output:

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/pi/google-home-pi/env/lib/python2.7/site-packages/googlesamples/assistant/audio_helpers/__main__.py", line 94, in <module>
    main()
  File "/home/pi/google-home-pi/env/local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/pi/google-home-pi/env/local/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/pi/google-home-pi/env/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/pi/google-home-pi/env/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/pi/google-home-pi/env/lib/python2.7/site-packages/googlesamples/assistant/audio_helpers/__main__.py", line 67, in main
    flush_size=audio_flush_size)
  File "/home/pi/google-home-pi/env/local/lib/python2.7/site-packages/googlesamples/assistant/audio_helpers/__init__.py", line 140, in __init__
    blocksize=int(block_size/2),  # blocksize is in number of frames.
  File "/home/pi/google-home-pi/env/local/lib/python2.7/site-packages/sounddevice.py", line 1491, in __init__
    **_remove_self(locals()))
  File "/home/pi/google-home-pi/env/local/lib/python2.7/site-packages/sounddevice.py", line 1017, in __init__
    'Error opening {0}'.format(self.__class__.__name__))
  File "/home/pi/google-home-pi/env/local/lib/python2.7/site-packages/sounddevice.py", line 2671, in _check
    raise PortAudioError(msg)
sounddevice.PortAudioError: Error opening RawStream: Invalid sample rate

Setup:

  • Raspberry Pi 3 (Model B)
  • Raspbian Jessie Lite (4.4)
  • Adafruit Mini USB Microphone (link)

Any help/tips would be much appreciated! Thanks

@proppy
Copy link
Contributor

proppy commented Apr 28, 2017

Can you paste the content of your .asoundrc and the output of aplay -l arecord -l?

See also:
https://developers.google.com/assistant/sdk/prototype/getting-started-pi-python/configure-audio

@stursby
Copy link
Author

stursby commented May 1, 2017

@proppy, When I pasted the sample .asoundrc file, playback was failing, so I removed it. So assume I don't have one set. I'm currently using this USB mic and the 3.5mm headphone jack for output.

aplay -l

**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

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

Thanks so much for your help!

@oscartprom
Copy link

I am using the same setup. According to your output, your /home/pi/.asoundrc file should read:

pcm.!default {
  type asym
  capture.pcm "usb_mic"
  playback.pcm "jack_speaker"
}

pcm.usb_mic {
  type plug
  slave {
    pcm "hw:1,0"
  }
}

pcm.jack_speaker {
  type plug
  slave {
    pcm "hw:0,0"
  }
}

Note the modified lines pcm "hw:card_number,device_number"

@stursby
Copy link
Author

stursby commented May 1, 2017

@oscartprom Ok, I added that file. It seems to record just fine, however I'm not hearing anything played back when I run aplay --format=S16_LE --rate=16k out.raw.

I do however hear "front left, front left..." when running speaker-test -t wav

And now trying to run python -m googlesamples.assistant gives the following error:

(env)pi@hatch-google-home:~/google-home-pi $ python -m googlesamples.assistant
INFO:root:Connecting to embeddedassistant.googleapis.com
Press Enter to send a new request...
INFO:root:Recording audio request.
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/pi/google-home-pi/env/lib/python2.7/site-packages/googlesamples/assistant/__main__.py", line 273, in <module>
    main()
  File "/home/pi/google-home-pi/env/local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/pi/google-home-pi/env/local/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/pi/google-home-pi/env/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/pi/google-home-pi/env/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/pi/google-home-pi/env/lib/python2.7/site-packages/googlesamples/assistant/__main__.py", line 234, in main
    grpc_deadline):
  File "/home/pi/google-home-pi/env/local/lib/python2.7/site-packages/grpc/_channel.py", line 366, in next
    return self._next()
  File "/home/pi/google-home-pi/env/local/lib/python2.7/site-packages/grpc/_channel.py", line 357, in _next
    raise self
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.UNAVAILABLE, Connect Failed)>

@szabodabo
Copy link

Hm... if you are hearing audio when you run speaker-test but nothing when you aplay a file, are you sure that the file you're passing to aplay isn't empty? How do you know the recording actually picked up sound?

Is the Connect Failed error persistent? Did it work for you before? Are you running any kind of local or network firewall?

@proppy
Copy link
Contributor

proppy commented May 2, 2017

Can you also try that command again after adding the .asoundrc file?

python -m googlesamples.assistant.audio_helpers

@proppy proppy added the question label May 2, 2017
@stursby
Copy link
Author

stursby commented May 2, 2017

@proppy Here's the output from that:

(env)pi@hatch-google-home:~/google-home-pi $ python -m googlesamples.assistant.audio_helpers
INFO:root:Starting audio test.
INFO:root:Recording samples.
INFO:root:Finished recording.
INFO:root:Playing back samples.
INFO:root:Finished playback.
INFO:root:audio test completed.

I do hear a brief second or two of static... what am I supposed to hear?

@proppy
Copy link
Contributor

proppy commented May 3, 2017

It's supposed to record something for 5 seconds and then replay it? Does it behave correctly?

@mayankshekhar111
Copy link

After reading the comments I changed the .asoundrc file accordingly. Now the mic and playback are working fine.
However on starting the SDK the same error pops up.

Now what to do??

@proppy
Copy link
Contributor

proppy commented May 9, 2017

However on starting the SDK the same error pops up.

Can you paste the output of python -m googlesamples.assistant.audio_helpers and comment if it behaves correctly (record 5 seconds of audio and replay them).

@mayankshekhar111
Copy link

I'm able to record and playback the audio. No issues. But this error continues

Traceback (most recent call last):
File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/root/env/lib/python3.4/site-packages/googlesamples/assistant/audio_helpers/main.py", line 95, in
main()
File "/root/env/lib/python3.4/site-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/root/env/lib/python3.4/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/root/env/lib/python3.4/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/root/env/lib/python3.4/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/root/env/lib/python3.4/site-packages/googlesamples/assistant/audio_helpers/main.py", line 67, in main
flush_size=audio_flush_size)
File "/root/env/lib/python3.4/site-packages/googlesamples/assistant/audio_helpers/init.py", line 179, in init
blocksize=int(block_size/2), # blocksize is in number of frames.
File "/root/env/lib/python3.4/site-packages/sounddevice.py", line 1491, in init
**_remove_self(locals()))
File "/root/env/lib/python3.4/site-packages/sounddevice.py", line 1017, in init
'Error opening {0}'.format(self.class.name))
File "/root/env/lib/python3.4/site-packages/sounddevice.py", line 2671, in _check
raise PortAudioError(msg)
sounddevice.PortAudioError: Error opening RawStream: Invalid sample rate

@mayankshekhar111
Copy link

How do I change the sample rate of the audio devices. I believe it should have been set to 16000 Hz as per this page
https://developers.google.com/assistant/sdk/best-practices/audio

@proppy
Copy link
Contributor

proppy commented May 9, 2017

--audio-sample-rate flag allow you to control the sample rate, but it should already default to 16000.

I'm able to record and playback the audio.

Can you show past here the command you're using to record/playback audio.

@mayankshekhar111
Copy link

Record a short audio clip.

arecord --format=S16_LE --duration=5 --rate=16k --file-type=raw out.raw

Check the recording by replaying it.

aplay --format=S16_LE --rate=16k out.raw

@proppy
Copy link
Contributor

proppy commented May 9, 2017

@mayankshekhar111 can you share the content of your .asoundrc?

@proppy
Copy link
Contributor

proppy commented May 9, 2017

@stursby did you get it working?

@stursby
Copy link
Author

stursby commented May 9, 2017

I did not, however I haven't had much time to test again... will follow back up as I give it another shot! @mayankshekhar111 if you get it working, please share your findings! Thanks.

@stursby
Copy link
Author

stursby commented May 16, 2017

@proppy Still can't get it to work... here's my .asoundrc and output from python -m googlesamples.assistant.audio_helpers

(env) pi@hatch-google-home:~ $ cat .asoundrc 
pcm.!default {
  type asym
  capture.pcm "usb_mic"
  playback.pcm "jack_speaker"
}
pcm.usb_mic {
  type plug
  slave {
    pcm "hw:1,0"
  }
}
pcm.jack_speaker {
  type plug
  slave {
    pcm "hw:0,0"
  }
}
(env) pi@hatch-google-home:~ $ python -m googlesamples.assistant.audio_helpers
INFO:root:Starting audio test.
INFO:root:Recording samples.
INFO:root:Finished recording.
INFO:root:Playing back samples.
WARNING:root:SoundDeviceStream write underflow (size: 12800)
INFO:root:Finished playback.
INFO:root:audio test completed.
(env) pi@hatch-google-home:~ $ 

I only hear a quick static during the INFO:root:Finished playback. line, and speaker-test -t wav continues to work just fine.

And here's what I get when I try to run python -m googlesamples.assistant (and again, I don't hear anything)

(env) pi@hatch-google-home:~ $ python -m googlesamples.assistant
INFO:root:Connecting to embeddedassistant.googleapis.com
Press Enter to send a new request...
INFO:root:Recording audio request.
ERROR:root:grpc unavailable error: <_Rendezvous of RPC that terminated with (StatusCode.UNAVAILABLE, Connect Failed)>
INFO:root:Recording audio request.

@proppy
Copy link
Contributor

proppy commented May 17, 2017

@stursby can you do a test similar to what you did back in #4 (comment), and past the output here, your .asoundrc and attach the out.raw file?

arecord --format=S16_LE --duration=5 --rate=16k --file-type=raw out.raw
aplay --format=S16_LE --rate=16k out.raw
file out.raw

@stursby
Copy link
Author

stursby commented May 17, 2017

@proppy Still not hearing anything 😢 Here's the output.

pi@hatch-google-home:~ $ arecord --format=S16_LE --duration=5 --rate=16k --file-type=raw out.raw
Recording raw data 'out.raw' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
pi@hatch-google-home:~ $ aplay --format=S16_LE --rate=16k out.raw
Playing raw data 'out.raw' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
pi@hatch-google-home:~ $ file out.raw
out.raw: data
pi@hatch-google-home:~ $ 

@proppy
Copy link
Contributor

proppy commented May 17, 2017

@stursby can you try:

aplay --format=S16_LE --rate=16k -d dmix out.raw

@stursby
Copy link
Author

stursby commented May 17, 2017

@proppy Also... does it matter that I'm using Raspbian Jessie Lite? Do I need the full version for this to work?

@stursby
Copy link
Author

stursby commented May 17, 2017

@proppy Just tried aplay --format=S16_LE --rate=16k -d dmix out.raw ... silence.

@stursby
Copy link
Author

stursby commented May 17, 2017

@proppy Ok, I've got some good news! I just assumed that it couldn't be the USB mic that was the problem... it was. I had another USB mic (same make/model)... popped that one it, recording & playback totally work now!!! 💯

However... I'm still having this issue when running the assistant:

(env) pi@hatch-google-home:~ $ python -m googlesamples.assistant
INFO:root:Connecting to embeddedassistant.googleapis.com
Press Enter to send a new request...
INFO:root:Recording audio request.
ERROR:root:grpc unavailable error: <_Rendezvous of RPC that terminated with (StatusCode.UNAVAILABLE, Connect Failed)>
INFO:root:Recording audio request.
^C
Aborted!
(env) pi@hatch-google-home:~ $ 

Any idea what ERROR:root:grpc unavailable error: <_Rendezvous of RPC that terminated with (StatusCode.UNAVAILABLE, Connect Failed)> INFO:root:Recording audio request. means??

@proppy
Copy link
Contributor

proppy commented May 19, 2017

Happy it worked!

ERROR:root:grpc unavailable error: <_Rendezvous of RPC that terminated with (StatusCode.UNAVAILABLE, Connect Failed)>

That happens when the connection timeout and we automatically retry the connection (with 7da41cf).

That shouldn't be fatal or impact the operation of the sample, but we could definitely use a better error message, filed #40

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

No branches or pull requests

5 participants