alexa-pi / AlexaPiDEPRECATED

DEPRECATED - Use https://github.com/alexa-pi/AlexaPi instead ...Turn a Raspberry Pi into an Alexa Client
https://github.com/alexa-pi/AlexaPi
MIT License
587 stars 439 forks source link

Active Listening. Maybe the saving grace? #82

Closed gregwa1953 closed 8 years ago

gregwa1953 commented 8 years ago

Saw this on the Java Alexa version, so I thought that I would share it here. Sorry if someone already did this.

Gregwa

GemBro commented 8 years ago

@gregwa1953

You got the link Greg? ... I couldn't find it ... cheers ...

gregwa1953 commented 8 years ago

Sorry about that @GemBro.

The main issue page is: https://github.com/amzn/alexa-avs-raspberry-pi/issues/4#issuecomment-218787833

Here's the text from the post...

xuchen https://github.com/xuchen commented 3 days ago https://github.com/amzn/alexa-avs-raspberry-pi/issues/4#issuecomment-218787833

Sorry for coming late into this discussion. We just released a hotword (or "wake word" as Amazon calls it) detector specifically for voice triggering an action:

https://snowboy.kitt.ai

It has Raspberry Pi support and Python bindings/wrapper (through SWIG). Though no Java wrapper yet:

https://github.com/kitt-ai/snowboy

We'd very much appreciate a pull request for Alexa/Pi integration.

On Sun, May 15, 2016 at 1:19 PM, GemBro notifications@github.com wrote:

@gregwa1953 https://github.com/gregwa1953

You got the link Greg? ... I couldn't find it ... cheers ...

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/sammachin/AlexaPi/issues/82#issuecomment-219304925

flooie commented 8 years ago

I couldn't make it - anyone else try?

gregwa1953 commented 8 years ago

Haven't had a chance to yet. Maybe tomorrow.

On Sun, May 15, 2016 at 4:21 PM, flooie notifications@github.com wrote:

I couldn't make it - anyone else try?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/sammachin/AlexaPi/issues/82#issuecomment-219314370

GemBro commented 8 years ago

@gregwa1953

That (Kitt-AI) option seems a bit of a long way round ;) ... but Ben's comment looks interesting, even with 2 Pi's ... but again (as he said) a "convoluted way" to do it ...

I'm not playing with the AVS (Amazon) version at the moment, as I prefer a headless system ... but I love all the ideas that are coming out of this project ... all very useful ...

EDIT : I take back what I said above ... looks like it's a goer ... well done flooie for integrating the snowboy project into AlexaPi ... and to Greg for pointing out snowboy's project ...

gregwa1953 commented 8 years ago

Well, with a bit of code, it COULD replace the button. You would have to change the button input to a jump into the python program and change the need for pressing the button until you are through with your vocal input to ... say ... 10 second sampling.

Not saying it's the ultimate answer to get rid of the button, but it might be fun to try.

On Sun, May 15, 2016 at 8:31 PM, GemBro notifications@github.com wrote:

@gregwa1953 https://github.com/gregwa1953

That seems a bit of a long winded way :) ... I'm not playing with the AVS (Amazon) version at the moment, as I prefer a headless system ... but I love all the ideas that are coming out of this project ...

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/sammachin/AlexaPi/issues/82#issuecomment-219336440

flooie commented 8 years ago

I've had trouble making the snowboy project on my rpi - anyone else have any luck?

flooie commented 8 years ago

I got it working- and its awesome.

maso27 commented 8 years ago

I haven't tried snowboy, but I've had voice control working via CMU Sphinx for a few weeks now in my office.

I grabbed a number of things from https://github.com/fcooper/beagleman to get it running.

I wedged it into Sam's latest version1.1 this morning, and if you want you can try it here: https://github.com/maso27/AlexaPi/tree/version1.1

(FYI, in this one the button still works, and I used the same 5-second listening window for voice-activated recording that was in beagleman)

tube0013 commented 8 years ago

That's awesome, can you share the code?

On May 16, 2016, at 1:02 PM, flooie notifications@github.com wrote:

I got it working- and its awesome.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub

flooie commented 8 years ago

@tube0013 planning on it - just working on one kink - right now i can't command it to stop the previous command -

flooie commented 8 years ago

@tube0013 anyone know how to detect a file executing

GemBro commented 8 years ago

Nice one flooie ... so I take it the 'button' does not stop the previous command? ...

flooie commented 8 years ago

@tube0013 - i posted my code - - I haven't figured out how to stop Alexa if its playing with voice commands but it works and works well. you are going to need to add a few more modules - and i had trouble getting the microphone code up to snuff but feel free to ping me if you have trouble

tube0013 commented 8 years ago

My pi is at my office, and I was home today, so I'll give it a go tomorrow. I just saw that the snowbird folks added in silence detection:

https://github.com/Kitt-AI/snowboy/issues/3

GemBro commented 8 years ago

Blimey ... this has taken off a bit eh? ... great work all ... good to see it's all coming together nicely ... now to keep up with all the additions being made ... :) ...

@flooie Hope you and the other guys are talking to Sam? ... hope you're all putting your heads together ... would be a nice combination with all the ideas & code in one package ...

benwoodley commented 8 years ago

In that issue I gave a mock up solution btw, but it isn't amazing for long term.

GemBro commented 8 years ago

@benwoodley Yes, sorry Ben, I saw that ... have ammended the above comment ;) ...

flooie commented 8 years ago

@GemBro @tube0013 I have everything working (albeit a bit slow) - and I posted a short video of it running in my kitchen - switching accounts playing music etc. etc.

https://youtu.be/wLbsAQDmN-c

gregwa1953 commented 8 years ago

Thanks to everyone for all their hard work in integrating this into the project. I'm glad that I was able to help out by pointing this out.

Gregwa

On Tue, May 17, 2016 at 9:30 AM, flooie notifications@github.com wrote:

@GemBro https://github.com/GemBro @tube0013 https://github.com/tube0013 I have everything working (albeit a bit slow) - and I posted a short video of it running in my kitchen - switching accounts playing music etc. etc.

https://youtu.be/wLbsAQDmN-c

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/sammachin/AlexaPi/issues/82#issuecomment-219755320

GemBro commented 8 years ago

@flooie

It maybe slow but that is totally awesome mate ... very well done ... love the feedback tones ... I see you got Alexa to actually stop now too ... nice ... I understand you're a bit of a distance away from the unit hence the couple of tries ... :) ...

One thing flooie ... I tried to install your VC version last night and I couldn't get the setup.sh to run ... running v1.1 (of Sam's) then editing the main.py file to yours works fine ... but I may have it all wrong when cloning your VC GIT files ...

Will you be doing a simple step by step installation write up for this? ... I find installing GIT stuff a bit hard, as I'm new to it all ... :) ...

@greg Yes indeed ... good call mate ... thanks for pointing us all in that direction ... ;) ...

Dammed if I can get my Prime Music to play though ... on any version ... :) ...

tube0013 commented 8 years ago

@flooie I pulled this down, but I'm having issues with the pyaudio throwing an error at start, did you have to do anything to get this part to work with snowdecoder.py?

flooie commented 8 years ago

@tube0013 - yeah - i had a heck of time getting pyaudio to work.

Look at the stack questions below - they should probably help you figure out what going on. Before you try to run my code you need to test that you can execute pyaudio - I ended up having to adjust a couple files. - also you should have everything installed that snowboy requires.

Hope that helps

http://raspberrypi.stackexchange.com/questions/9951/pyaudio-recording-sound-on-pi-getting-errors

http://raspberrypi.stackexchange.com/questions/39928/unable-to-set-default-input-and-output-audio-device-on-raspberry-jessie

https://github.com/raspberrypi/linux/issues/994

xuchen commented 8 years ago

Coming late into this conversation: glad that some of you got it working! We actually wrote in the documentation how to configure pyaudio on the Pi:

https://snowboy.kitt.ai/docs/#set-up-audio

Hope it helps!

xuchen commented 8 years ago

Two more tips, if you want to have it working across the room better you can do two things:

  1. adjust sensitivity level
  2. when training the model, record your voice from far in the room. You can also record it on your Pi with your microphone, and upload the .wav files to snowboy website to train a new model that fits exactly to your microphone and room settings.
tube0013 commented 8 years ago

I've set my default cards up in the .asound and also in /etc/asoound.conf.

I've also tried changing the default card to my usb mic (which also has audio out) in the /usr/share/alsa/alsa.conf file. no matter what I get errors like this:

$ python demo.py Alexa.pmdl 
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
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 "demo.py", line 27, in <module>
    detector = snowboydecoder.HotwordDetector(model, sensitivity=0.5)
  File "/home/pi/Downloads/rpi-arm-raspbian-8.0-1.0.0/snowboydecoder.py", line 115, in __init__
    stream_callback=audio_callback)
  File "build/bdist.linux-armv7l/egg/pyaudio.py", line 750, in open

  File "build/bdist.linux-armv7l/egg/pyaudio.py", line 441, in __init__
    # calling pa.open returns a stream object
IOError: [Errno -9997] Invalid sample rate
flooie commented 8 years ago

@tube0013 http://superuser.com/questions/989385/alsa-base-conf-missing-in-new-raspberry-pi-raspbian-jesse

Found it - look at the answer from Digitalfix

I bet that will fix it

tube0013 commented 8 years ago

@flooie thanks. just tried that, and it's a no go. not sure but may have to do with sample rate and chunk size based on some other posts I've seen. I don't get the IOError when I run start.py from your files, I just get a Traceback. the demo from snowboy gives the Sample Rate error.

xuchen commented 8 years ago

@tube0013 did you follow our docs: https://snowboy.kitt.ai/docs/#set-up-audio

tube0013 commented 8 years ago

Yes, that's where I started from.

On Tue, May 17, 2016 at 5:08 PM xuchen notifications@github.com wrote:

@tube0013 https://github.com/tube0013 did you follow our docs: https://snowboy.kitt.ai/docs/#set-up-audio

— You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub https://github.com/sammachin/AlexaPi/issues/82#issuecomment-219854644

xuchen commented 8 years ago

@tube0013 i'd try to uninstall PulseAudio and only use ALSA.

tube0013 commented 8 years ago

I'm going to start from a fresh Rasbian/Jessie install tomorrow. I thought I had pulse completely uninstalled.

On May 17, 2016, at 5:34 PM, xuchen notifications@github.com wrote:

@tube0013 i'd try to uninstall PulseAudio and only use ALSA.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

chenguoguo commented 8 years ago

In addition to what Xuchen said regarding using Snowboy with a distance, I'd add one more trick: increasing the audio gain in the snowboy API.

xuchen commented 8 years ago

@flooie any idea why it's a bit slow to respond, esp. when you turn on BBC?

flooie commented 8 years ago

1) I haven't implemented silence detection so it listens for a set period of time- 2) My code collects all of the content before it starts playing it so its slightly delayed there 3) *The internet sucks in Cambridge, MA.

tube0013 commented 8 years ago

I'm still having the same issues after a complete re-flash of the latest raspbian.

I managed to get the demo.py provided in the snowbird download working. Weirdly it only works if I run as root/sudo.

for voice-command AlexaPi, I'm running python start.py Alexa.pmdl,

and I get an error: no Module named subfile

is this a prereq I'm missing? if so can you point me to it?

flooie commented 8 years ago

@tube0013 email me wpalin [at] gmail.com

GemBro commented 8 years ago

@tube0013

Have you tried running the files using sudo? ... like this:

sudo python start.py Alexa.pmdl

I have to use sudo sometimes if it cannot find files that are there and visible ...

tube0013 commented 8 years ago

Yes I got it running. Only works as root/sudo.

Had to delete the import subfile line, @flooie made the change in his repository today.

On Wed, May 18, 2016 at 9:56 PM GemBro notifications@github.com wrote:

@tube0013 https://github.com/tube0013

Have you tried running the files using sudo? ... like this:

sudo python start.py Alexa.pmdl

I have to use sudo sometimes if it cannot find files that are there and visible ...

— You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub https://github.com/sammachin/AlexaPi/issues/82#issuecomment-220208113

GemBro commented 8 years ago

@tube0013

Cool ... thanks for heads up ... gonna grab the new update ...

olsonk commented 8 years ago

Hey Everyone,

Really appreciate the work that's gone into this so already! I tried installing everything, though, and running with python start.py Alexa.pmdl and am getting this error:

pi@raspberrypi:~/Downloads/AlexaPi $ python start.py Alexa.pmdl
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.front.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM front
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround40.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround40
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround41
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround50
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround51
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround71.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround71
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM iec958
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
Listening... Press Ctrl+C to exit
INFO:snowboy:Keyword 1 detected at time: 2016-05-24 09:31:22
Ready to Record.
Recording...
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1736
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1904
Expression 'PaAlsaStreamComponent_Initialize( &self->capture, alsaApi, inParams, StreamDirection_In, NULL != callback )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2171
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2840
Traceback (most recent call last):
  File "start.py", line 38, in <module>
    sleep_time=0.03)
  File "/home/pi/Downloads/AlexaPi/snowboydecoder.py", line 190, in start
    main.start()
  File "/home/pi/Downloads/AlexaPi/main.py", line 61, in start
    recordAudio()
  File "/home/pi/Downloads/AlexaPi/main.py", line 82, in recordAudio
    frames_per_buffer=CHUNK)
  File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 747, in open
    stream = Stream(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 442, in __init__
    self._stream = pa.open(**arguments)
IOError: [Errno Device unavailable] -9985

Any ideas what might be going on there? I tried running the Snowboy demo and it worked properly, and I can use rec temp.wav and play temp.wav to record and playback audio properly. I'm not sure exactly what's going on...

EDIT: To clarify, I get that string of error messages, but it still prints out "Listening..." and will trigger the ding.wav audio when I say "Alexa." The rest of the errors that follow the hotword detection come up after about 2 seconds of the recording being on.

tube0013 commented 8 years ago

I had to run it as root or I'd get similar errors. I also had to make sure my default audio devices were set up. My Microphone also has an audio output, so I was unable to pick just the mic as default and had to plug my speaker into the usb output. and change the default device in /usr/share/asla/alsa.conf

olsonk commented 8 years ago

@tube0013 Thanks for responding. I'm actually getting errors that prevent it from even listening when I run as root! Here's the printout from running sudo python start.py Alexa.pmdl:

ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.front.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM front
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround40.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround40
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround41
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround50
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround51
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround71.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround71
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM iec958
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
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 "start.py", line 32, in <module>
    detector = snowboydecoder.HotwordDetector(model, sensitivity=0.5)
  File "/home/pi/Downloads/AlexaPi/snowboydecoder.py", line 123, in __init__
    stream_callback=audio_callback)
  File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 747, in open
    stream = Stream(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 442, in __init__
    self._stream = pa.open(**arguments)
IOError: [Errno Invalid sample rate] -9997

I thought I'd properly selected my audio devices by editing the ~/.asoundrc file, which is referenced in /usr/share/alsa/alsa.conf. Do I also need to change other settings in alsa.conf?

I'm pretty new to all of this stuff, so I apologize if I'm asking stupid questions or missed something obvious...

Here's my ~/.asoundrc file just in case it's helpful:

pcm.!default {
  type asym
   playback.pcm {
     type plug
     slave.pcm "hw:0,0"
   }
   capture.pcm {
     type plug
     slave.pcm "hw:1,0"
   }
}

Thanks for your help!

chenguoguo commented 8 years ago

@sciencedude100 is having similar problems, see the issue here: https://github.com/Kitt-AI/snowboy/issues/9

I posted a potential solution there. The idea is to manually set device for PyAudio, not sure if that's going to work. @olsonk, it will be great if you can give it a try.

tube0013 commented 8 years ago

@olsonk I was getting that same error. I ended up re installing Jessie and starting from scratch. And still had to update /usr/share/alsa/alsa.conf. @chenguoguo may be on to something by manually setting the device for PyAudio.

olsonk commented 8 years ago

Ha - I literally just googled "pyaudio set input device" after thinking more about the issue - seems as though PyAudio is setting off the IOError.

So, I followed your solution on that snowboy issue, @chenguoguo . I edited self.steam_in to reflect your code and found that my USB mic is index 2. I added input_device_index=2 and now I get this error:

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 "start.py", line 32, in <module>
    detector = snowboydecoder.HotwordDetector(model, sensitivity=0.5)
  File "/home/pi/Downloads/AlexaPi/snowboydecoder.py", line 123, in __init__
    input_device_index=2)
  File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 747, in open
    stream = Stream(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 442, in __init__
    self._stream = pa.open(**arguments)
IOError: [Errno Invalid sample rate] -9997

All of that is after the other errors and warnings from above. Here's snowboydecoder.py, the relevant section:

        self.audio = pyaudio.PyAudio()
        self.stream_in = self.audio.open(
            input=True, output=False,
            format=pyaudio.paInt16,
            channels=1,
            rate=16000,
            frames_per_buffer=2048,
            stream_callback=audio_callback,
            input_device_index=2)

Anything jump out to anyone?

I'm also getting close to re-installing fresh, @tube0013!

olsonk commented 8 years ago

I just adjusted the rate to 48000 and am no longer getting the Invalid Sample Rate error. However, it also won't detect the keyword! Is there any way for me to figure out the proper sample rate for the USB mic? Or is that even important? Also wondering if there's some way I can test whether it's picking up any audio from the mic with that stream and maybe I just need to speak differently?

chenguoguo commented 8 years ago

@olsonk, so looks like you USB micphone only supports a sampling rate of 48000? It's expected that keyword spotting stopped working with that sampling rate, as Snowboy requires a sampling rate of 16000 which is pretty standard for speech recognition tasks...

flooie commented 8 years ago

@olsonk which branch are you trying to run with? -

xuchen commented 8 years ago

@olsonk did you try your own .pmdl or someone else's .pmdl? You can also try the universal model for the word "snowboy":

https://github.com/Kitt-AI/snowboy/raw/master/resources/snowboy.umdl