Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speech Rec Works Intermittantly #287

Closed
HelloExactly opened this issue Jun 11, 2016 · 13 comments
Closed

Speech Rec Works Intermittantly #287

HelloExactly opened this issue Jun 11, 2016 · 13 comments

Comments

@HelloExactly
Copy link

I've noticed others with this issue so I thought I'd post it here. Speech rec works but not always. Sometimes 2 in a row will work, sometimes 10, sometimes none at all. Only fix seems to be a reboot but then the issue will start all over again.

@evancohen
Copy link
Owner

@HelloExactly it would help if you could give more information about your issue. IE: what branch are you using, what errors you see, etc. This is likely already a known issue #170 and I should have a complete fix this weekend.

@GobleSt
Copy link

GobleSt commented Jun 12, 2016

@HelloExactly have you tried just killing the running instance and restarting? That works for me. ALT-F4 to close the open window, use terminal and run the ./smart-start.sh. ...shouldn't need a whole reboot.

@evancohen I have the same issue. Today, I wiped and started from scratch to get a clean install. I still need to run pulseaudio --start prior to the ./smart-start.sh to get the voice working correctly. I get a couple of commands out of it before it stops listening to me.

I tested it on the new master and rss-dev. Keyword spotting is working fine. In testing, I got about 3 commands out of it and it stopped listening. I have not met quota and restarting will allow me to get a few more commands in.

When I run it npm start dev I DO see 3 errors (they appear to be related to traffic " http://dev.virtualearth.net/REST/V1/Routes/Driving?wp.0=&wp.1=&avoid=minimi…Tolls&key=Aq8GFZ6_bp7LIu0uuYZl7Z0kv-1Sa0eUAXgAhPMtlLwkj-jFoDGd9cjcpk8IHe1d 400 (Bad Request)" but they do not stop me from using voice and when it stops listening no new errors are present.

In addition, I see the ALSA errors in CLI but nothing is jumping out at me (and I am not as smart as you guys) that leads me anywhere.

@HelloExactly
Copy link
Author

Reboot/restarting the app, semantics.

@evancohen I'm using the Dev branch, and same as the above poster, I see no errors after KWS shuts off.

@evancohen
Copy link
Owner

evancohen commented Jun 13, 2016

Thanks for the details @GobleSt! Sounds like this is a bug. I haven't had this repro in my current build, but I'll do a clean install this week and see if I either missed a step in the documentation or if there's something up with the keyword spotter.

@shep99
Copy link

shep99 commented Jun 14, 2016

Hey Guys: I'm getting the same also. KWS works one or two times, then seems to die. Below is my log:

pi@mirror_1:~/smart-mirror $ npm start

> [email protected] start /home/pi/smart-mirror
> electron main.js 

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

@evancohen
Copy link
Owner

evancohen commented Jun 14, 2016

So I was able to spend a few minutes looking at this tonight, and it looks like the keyword spotter is causing the alsa-sink to hang in a rewind (the hang itself is intermittent, which is probably why you are seeing it work for a couple times before stopping). I was able to get this to reliably repro when recording via the microphone debug utility (npm run microphone-debug) and the keyword spotter. Effectively recording audio through two sources simultaneously.

From the PulseAudio logs:

D: [pulseaudio] module-intended-roles.c: Not setting device for stream ALSA Playback, because it lacks role.
D: [pulseaudio] sink-input.c: Negotiated format: pcm, format.sample_format = "\"s16le\""  format.rate = "16000"  format.channels = "1"  format.channel_map = "\"mono\""
I: [pulseaudio] sink-input.c: Trying to change sample rate
I: [pulseaudio] sink.c: Cannot update rate, SINK_IS_RUNNING, will keep using 44100 Hz
D: [pulseaudio] module-suspend-on-idle.c: Sink alsa_output.0.analog-stereo becomes busy, resuming.
D: [pulseaudio] resampler.c: Channel matrix:
D: [pulseaudio] resampler.c:        I00
D: [pulseaudio] resampler.c:     +------
D: [pulseaudio] resampler.c: O00 | 1.000
D: [pulseaudio] resampler.c: O01 | 1.000
I: [pulseaudio] remap.c: Using mono to stereo remapping
D: [pulseaudio] resampler.c: Resampler:
D: [pulseaudio] resampler.c:   rate 16000 -> 44100 (method speex-fixed-1)
D: [pulseaudio] resampler.c:   format s16le -> s16le (intermediate s16le)
D: [pulseaudio] resampler.c:   channels 1 -> 2 (resampling 1)
I: [pulseaudio] resampler.c: Choosing speex quality setting 1.
D: [pulseaudio] memblockq.c: memblockq requested: maxlength=33554432, tlength=0, base=4, prebuf=0, minreq=1 maxrewind=0
D: [pulseaudio] memblockq.c: memblockq sanitized: maxlength=33554432, tlength=33554432, base=4, prebuf=0, minreq=4 maxrewind=0
I: [pulseaudio] sink-input.c: Created input 8 "ALSA Playback" on alsa_output.0.analog-stereo with sample spec s16le 1ch 16000Hz and channel map mono
I: [pulseaudio] sink-input.c:     media.name = "ALSA Playback"
I: [pulseaudio] sink-input.c:     application.name = "ALSA plug-in [python2.7]"
I: [pulseaudio] sink-input.c:     native-protocol.peer = "UNIX socket client"
I: [pulseaudio] sink-input.c:     native-protocol.version = "29"
I: [pulseaudio] sink-input.c:     application.process.id = "1854"
I: [pulseaudio] sink-input.c:     application.process.user = "pi"
I: [pulseaudio] sink-input.c:     application.process.host = "raspberrypi"
I: [pulseaudio] sink-input.c:     application.process.binary = "python2.7"
I: [pulseaudio] sink-input.c:     application.language = "C"
I: [pulseaudio] sink-input.c:     window.x11.display = ":0.0"
I: [pulseaudio] sink-input.c:     application.process.machine_id = "8dadf95c2f504864bc0f8b3ab149cbe0"
I: [pulseaudio] sink-input.c:     application.process.session_id = "c1"
I: [pulseaudio] sink-input.c:     application.icon_name = "/usr/share/pixmaps/python2.7.xpm"
I: [pulseaudio] sink-input.c:     module-stream-restore.id = "sink-input-by-application-name:ALSA plug-in [python2.7]"
I: [pulseaudio] protocol-native.c: Requested tlength=192.00 ms, minreq=64.00 ms
D: [pulseaudio] protocol-native.c: Early requests mode enabled, configuring sink latency to minreq.
D: [pulseaudio] protocol-native.c: Requested latency=64.00 ms, Received latency=64.00 ms
D: [pulseaudio] memblockq.c: memblockq requested: maxlength=4194304, tlength=6144, base=2, prebuf=2048, minreq=2048 maxrewind=0
D: [pulseaudio] memblockq.c: memblockq sanitized: maxlength=4194304, tlength=6144, base=2, prebuf=2048, minreq=2048 maxrewind=0
I: [pulseaudio] protocol-native.c: Final latency 256.00 ms = 64.00 ms + 2*64.00 ms + 64.00 ms
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: Latency set to 11.61ms
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: hwbuf_unused=63488
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: setting avail_min=16129
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: Requested volume: front-left: 36938 /  56% / -14.94 dB,   front-right: 36938 /  56% / -14.94 dB
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: Got hardware volume: front-left: 36938 /  56% / -14.94 dB,   front-right: 36938 /  56% / -14.94 dB
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: Calculated software volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB (accurate-enough=yes)
D: [alsa-sink-bcm2835 ALSA] sink.c: Volume not changing
D: [alsa-sink-bcm2835 ALSA] protocol-native.c: Requesting rewind due to end of underrun.
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: Requested to rewind 65536 bytes.
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: Limited to 1792 bytes.
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: before: 448
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: after: 448
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: Rewound 1792 bytes.
D: [alsa-sink-bcm2835 ALSA] sink.c: Processing rewind...
D: [alsa-sink-bcm2835 ALSA] sink.c: latency = 0
D: [alsa-sink-bcm2835 ALSA] sink-input.c: Have to rewind 1792 bytes on render memblockq.
D: [alsa-sink-bcm2835 ALSA] sink-input.c: Have to rewind 1792 bytes on render memblockq.
D: [alsa-sink-bcm2835 ALSA] source.c: Processing rewind...

The corresponding failure in the keyword spotter:

Expression 'alsa_snd_pcm_poll_descriptors_revents( self->pcm, pfds, self->nfds, &revents )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3659
Expression 'PaAlsaStreamComponent_EndPolling( &self->capture, capturePfds, &pollCapture, &xrun )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3861
Expression 'PaAlsaStream_WaitForFrames( stream, &framesAvail, &xrun )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 4253
Expression 'alsa_snd_pcm_poll_descriptors_revents( self->pcm, pfds, self->nfds, &revents )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3659
Expression 'PaAlsaStreamComponent_EndPolling( &self->playback, playbackPfds, &pollPlayback, &xrun )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3865
Expression 'PaAlsaStream_WaitForFrames( stream, &framesAvail, &xrun )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 4460
Traceback (most recent call last):
  File "speech/kws.py", line 38, in <module>
    sleep_time=0.03)
  File "/home/pi/smart-mirror/speech/snowboydecoder.py", line 172, in start
    callback()
  File "speech/kws.py", line 19, in hotword_detected_callback
    snowboydecoder.play_audio_file(snowboydecoder.DETECT_DING)
  File "/home/pi/smart-mirror/speech/snowboydecoder.py", line 52, in play_audio_file
    stream_out.write(ding_data)
  File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 587, in write
    exception_on_underflow)
IOError: [Errno Unanticipated host error] -9999

Maybe the error above is something that @chenguoguo has seen before (although I doubt it because PulseAudio is not their recommended audio input library, it's ALSA)?

The "nice" part about this is that it's just the playback that I think is causing this issue, not the actual recording. Removing the playback of the "ding" sound should fix the problem (theoretically). If I have some time later tonight I'll take a look at pushing something to the dev branch.

I'm guessing that the real solution to this is to ditch PulseAudio altogether, but there are loads of compatibility issues between microphones that PulseAudio takes care of.

Ideally there's another way to specify the default input device for Electron when using webkitSpeechRecognition(). I've tried --alsa-input-device before with zero success :/

@xuchen
Copy link

xuchen commented Jun 14, 2016

I have never seen this error before. And PulseAudio isn't my favorite way
to handle audio either.

If the errors come from audio playback, why not use a different prompt,
such as printing something on the mirror.

On Mon, Jun 13, 2016 at 9:51 PM, Evan Cohen [email protected]
wrote:

So I was able to spend a few minutes looking at this tonight, and it looks
like the keyword spotter is causing the alsa-sink to hang in a rewind (the
hang itself is intermittent, which is probably why you are seeing it work
for a couple times before stopping). I was able to get this to reliably
repro when recording via the microphone debug utility (npm run
microphone-debug) and recording audio through two sources simultaneously.

From the PulseAudio logs:

D: [pulseaudio] module-intended-roles.c: Not setting device for stream ALSA Playback, because it lacks role.
D: [pulseaudio] sink-input.c: Negotiated format: pcm, format.sample_format = ""s16le"" format.rate = "16000" format.channels = "1" format.channel_map = ""mono""
I: [pulseaudio] sink-input.c: Trying to change sample rate
I: [pulseaudio] sink.c: Cannot update rate, SINK_IS_RUNNING, will keep using 44100 Hz
D: [pulseaudio] module-suspend-on-idle.c: Sink alsa_output.0.analog-stereo becomes busy, resuming.
D: [pulseaudio] resampler.c: Channel matrix:
D: [pulseaudio] resampler.c: I00
D: [pulseaudio] resampler.c: +------
D: [pulseaudio] resampler.c: O00 | 1.000
D: [pulseaudio] resampler.c: O01 | 1.000
I: [pulseaudio] remap.c: Using mono to stereo remapping
D: [pulseaudio] resampler.c: Resampler:
D: [pulseaudio] resampler.c: rate 16000 -> 44100 (method speex-fixed-1)
D: [pulseaudio] resampler.c: format s16le -> s16le (intermediate s16le)
D: [pulseaudio] resampler.c: channels 1 -> 2 (resampling 1)
I: [pulseaudio] resampler.c: Choosing speex quality setting 1.
D: [pulseaudio] memblockq.c: memblockq requested: maxlength=33554432, tlength=0, base=4, prebuf=0, minreq=1 maxrewind=0
D: [pulseaudio] memblockq.c: memblockq sanitized: maxlength=33554432, tlength=33554432, base=4, prebuf=0, minreq=4 maxrewind=0
I: [pulseaudio] sink-input.c: Created input 8 "ALSA Playback" on alsa_output.0.analog-stereo with sample spec s16le 1ch 16000Hz and channel map mono
I: [pulseaudio] sink-input.c: media.name = "ALSA Playback"
I: [pulseaudio] sink-input.c: application.name = "ALSA plug-in [python2.7]"
I: [pulseaudio] sink-input.c: native-protocol.peer = "UNIX socket client"
I: [pulseaudio] sink-input.c: native-protocol.version = "29"
I: [pulseaudio] sink-input.c: application.process.id = "1854"
I: [pulseaudio] sink-input.c: application.process.user = "pi"
I: [pulseaudio] sink-input.c: application.process.host = "raspberrypi"
I: [pulseaudio] sink-input.c: application.process.binary = "python2.7"
I: [pulseaudio] sink-input.c: application.language = "C"
I: [pulseaudio] sink-input.c: window.x11.display = ":0.0"
I: [pulseaudio] sink-input.c: application.process.machine_id = "8dadf95c2f504864bc0f8b3ab149cbe0"
I: [pulseaudio] sink-input.c: application.process.session_id = "c1"
I: [pulseaudio] sink-input.c: application.icon_name = "/usr/share/pixmaps/python2.7.xpm"
I: [pulseaudio] sink-input.c: module-stream-restore.id = "sink-input-by-application-name:ALSA plug-in [python2.7]"
I: [pulseaudio] protocol-native.c: Requested tlength=192.00 ms, minreq=64.00 ms
D: [pulseaudio] protocol-native.c: Early requests mode enabled, configuring sink latency to minreq.
D: [pulseaudio] protocol-native.c: Requested latency=64.00 ms, Received latency=64.00 ms
D: [pulseaudio] memblockq.c: memblockq requested: maxlength=4194304, tlength=6144, base=2, prebuf=2048, minreq=2048 maxrewind=0
D: [pulseaudio] memblockq.c: memblockq sanitized: maxlength=4194304, tlength=6144, base=2, prebuf=2048, minreq=2048 maxrewind=0
I: [pulseaudio] protocol-native.c: Final latency 256.00 ms = 64.00 ms + 2*64.00 ms + 64.00 ms
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: Latency set to 11.61ms
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: hwbuf_unused=63488
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: setting avail_min=16129
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: Requested volume: front-left: 36938 / 56% / -14.94 dB, front-right: 36938 / 56% / -14.94 dB
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: Got hardware volume: front-left: 36938 / 56% / -14.94 dB, front-right: 36938 / 56% / -14.94 dB
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: Calculated software volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB (accurate-enough=yes)
D: [alsa-sink-bcm2835 ALSA] sink.c: Volume not changing
D: [alsa-sink-bcm2835 ALSA] protocol-native.c: Requesting rewind due to end of underrun.
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: Requested to rewind 65536 bytes.
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: Limited to 1792 bytes.
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: before: 448
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: after: 448
D: [alsa-sink-bcm2835 ALSA] alsa-sink.c: Rewound 1792 bytes.
D: [alsa-sink-bcm2835 ALSA] sink.c: Processing rewind...
D: [alsa-sink-bcm2835 ALSA] sink.c: latency = 0
D: [alsa-sink-bcm2835 ALSA] sink-input.c: Have to rewind 1792 bytes on render memblockq.
D: [alsa-sink-bcm2835 ALSA] sink-input.c: Have to rewind 1792 bytes on render memblockq.
D: [alsa-sink-bcm2835 ALSA] source.c: Processing rewind...

The corresponding failure in the keyword spotter:

Expression 'alsa_snd_pcm_poll_descriptors_revents( self->pcm, pfds, self->nfds, &revents )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3659
Expression 'PaAlsaStreamComponent_EndPolling( &self->capture, capturePfds, &pollCapture, &xrun )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3861
Expression 'PaAlsaStream_WaitForFrames( stream, &framesAvail, &xrun )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 4253
Expression 'alsa_snd_pcm_poll_descriptors_revents( self->pcm, pfds, self->nfds, &revents )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3659
Expression 'PaAlsaStreamComponent_EndPolling( &self->playback, playbackPfds, &pollPlayback, &xrun )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3865
Expression 'PaAlsaStream_WaitForFrames( stream, &framesAvail, &xrun )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 4460
Traceback (most recent call last):
File "speech/kws.py", line 38, in
sleep_time=0.03)
File "/home/pi/smart-mirror/speech/snowboydecoder.py", line 172, in start
callback()
File "speech/kws.py", line 19, in hotword_detected_callback
snowboydecoder.play_audio_file(snowboydecoder.DETECT_DING)
File "/home/pi/smart-mirror/speech/snowboydecoder.py", line 52, in play_audio_file
stream_out.write(ding_data)
File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 587, in write
exception_on_underflow)
IOError: [Errno Unanticipated host error] -9999

Maybe the error above is something that @xuchen
https://github.com/xuchen has seen before (although I doubt it because
PulseAudio is not their recommended audio input library, it's ALSA)?

The "nice" part about this is that it's just the playback that I think is
causing this issue, not the actual recording. Removing the playback of the
"ding" sound should fix the problem (theoretically). If I have some time
later tonight I'll take a look at pushing something to the dev branch.

I'm guessing that the real solution to this is to ditch PulseAudio
altogether, but there are loads of compatibility issues between
microphones that PulseAudio takes care of.

Ideally there's another way to specify the default input device for
Electron when using webkitSpeechRecognition(). I've tried
--alsa-input-device before with zero success :/


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#287 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAhLO7JedrbzBn31DktI7Hy_o5fQA4Bxks5qLjM7gaJpZM4Iznts
.

@evancohen evancohen reopened this Jun 14, 2016
@kgrewohl
Copy link

I can confirm with a decent amount of certainty that commenting out line 19 of kws.py (the playback line) that the keyword spotting detection works reliably.

evancohen added a commit that referenced this issue Jun 15, 2016
The ding was causing a freeze in a rewind. This is a temporary workaround to stop the keyword spotter from hanging after a few utterances.
@evancohen
Copy link
Owner

@kgrewohl I've pushed that change to the dev branch. @HelloExactly and @GobleSt could you test this and see if it fixes your issue?

@kgrewohl
Copy link

@evancohen I just re-cloned the dev branch and the mic is working like it was before. The ding was nice but functionality is way better. Thanks!

@evancohen
Copy link
Owner

@kgrewohl it won't be any trouble to add the ding back on the JavaScript side of things, the issue arose from the way the keyword spotter was playing audio.

@GobleSt
Copy link

GobleSt commented Jun 15, 2016

@evancohen confirmed.

VC is working like a charm. If for no other reason to put the mirror to sleep and wake it up again is totally awesome. Issue 284 still exists but I would say 244 and 287 are outta here!

Youtube also starts to play sound then stops and continues to play video. This appears to be a little intermittent as the bowtie plays a few seconds of audio and the new Jason Bourne trailer played almost 20 seconds of audio. Maybe poor wireless quality (hardware related to the pi) where it has a hard time caching both sound and video? I will look more into this when I can but VC is great!!! GJ guys!

@evancohen
Copy link
Owner

Seems like my GitHub automation got a little carried away there ;)

Regardless, this fix is now in the latest master, thank you all for your help 🚀

Repository owner locked and limited conversation to collaborators Jan 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants