synesthesiam / rhasspy

Rhasspy voice assistant for offline home automation
https://rhasspy.readthedocs.io
MIT License
942 stars 101 forks source link

Rhasspy recognizes microphone but only reads 44 bytes of data #196

Closed moritzschaefer closed 4 years ago

moritzschaefer commented 4 years ago

I've got a fresh rhasspy git/venv installation on my RPi 3B. I use a PlayStation Eye as microphone. When I test the microphone in the "Speech" tab in the web interface, I get the following error in the command line running rhasspy:

DEBUG:PyAudioRecorder:started -> recording
[2020-03-22 10:06:42,453] 192.168.178.92:36080 POST /api/start-recording 1.1 200 2 9401
INFO:quart.serving:192.168.178.92:36080 POST /api/start-recording 1.1 200 2 9401
Expression 'alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )' failed in 'src/hostapi/alsa/pa_linux$
alsa.c', line: 924
ALSA lib pcm_dmix.c:1108:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5036:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5036:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
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

ALSA lib pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_dmix.c:1108:(snd_pcm_dmix_open) unable to open slave
Expression 'alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )' failed in 'src/hostapi/alsa/pa_linux_
alsa.c', line: 924
DEBUG:__main__:Recorded 44 byte(s) of audio data
DEBUG:PocketsphinxDecoder:rate=16000, width=2, channels=1.
DEBUG:PocketsphinxDecoder:Decoded WAV in 0.0024895668029785156 second(s)
DEBUG:PocketsphinxDecoder:
DEBUG:InboxActor: -> stopped
DEBUG:__main__:
ERROR:FsticuffsRecognizer:in_loaded
Traceback (most recent call last):
  File "/home/pi/rhasspy_git/rhasspy/intent.py", line 183, in in_loaded
    assert recognitions, "No intent recognized"
AssertionError: No intent recognized
DEBUG:InboxActor: -> stopped
DEBUG:__main__:{"text": "", "intent": {"name": "", "confidence": 0}, "entities": [], "raw_text": "", "speech_confidence": 0, "slots": {}, "wakeId": "", "siteId": "default"}
INFO:quart.serving:192.168.178.92:36024 GET /api/events/intent 1.1 101 - 417568105
[2020-03-22 10:06:44,449] 192.168.178.92:36024 GET /api/events/intent 1.1 101 - 417568105
[2020-03-22 10:06:44,456] 192.168.178.92:36068 GET /api/events/intent 1.1 101 - 176875020
INFO:quart.serving:192.168.178.92:36068 GET /api/events/intent 1.1 101 - 176875020
DEBUG:InboxActor: -> stopped
[2020-03-22 10:06:44,471] 192.168.178.92:36080 POST /api/stop-recording 1.1 200 139 94426
INFO:quart.serving:192.168.178.92:36080 POST /api/stop-recording 1.1 200 139 94426
ERROR:__main__:api_websocket
Traceback (most recent call last):
  File "app.py", line 1232, in wrapper
    return await func(queue, *_args, **kwargs)
  File "app.py", line 1247, in api_events_intent
    message_type, text = await queue.get()
  File "/usr/lib/python3.7/asyncio/queues.py", line 159, in get
    await getter
concurrent.futures._base.CancelledError

Interestingly, when testing my microphone with arecord I get a similar error as the resulting file also contains only 44 bytes. This is the output:

$ arecord --device="hw:1,0" --dump-hw-params
Recording WAVE 'stdin' : Unsigned 8 bit, Rate 8000 Hz, Mono
HW Params of device "hw:1,0":
--------------------
ACCESS:  MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT:  S16_LE
SUBFORMAT:  STD
SAMPLE_BITS: 16
FRAME_BITS: 64
CHANNELS: 4
RATE: 16000
PERIOD_TIME: [1000 4096000]
PERIOD_SIZE: [16 65536]
PERIOD_BYTES: [128 524288]
PERIODS: [2 1024]
BUFFER_TIME: [2000 8192000]
BUFFER_SIZE: [32 131072]
BUFFER_BYTES: [256 1048576]
TICK_TIME: ALL
--------------------
arecord: set_params:1339: Sample format non available
Available formats:
- S16_LE
$ arecord --device="hw:1,0" -d 2 -r 16000 -f S16_LE -c 4 /tmp/test.wav
Recording WAVE '/tmp/test.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Channels 4
ls -l /tmp/tarecord: pcm_read:2145: read error: Input/output error
$ ls -l /tmp/test.wav
-rw-r--r-- 1 pi pi 44 Mar 22 10:13 /tmp/test.wav

Also, during startup, I get the following errors (but don't know, whether they do any harm):

ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
[2020-03-22 10:03:45,799] 192.168.178.92:36058 GET /api/profile 1.1 200 6907 30061
INFO:quart.serving:192.168.178.92:36058 GET /api/profile 1.1 200 6907 30061
[2020-03-22 10:03:45,803] 192.168.178.92:36060 GET /api/unknown-words 1.1 200 2 32606
INFO:quart.serving:192.168.178.92:36060 GET /api/unknown-words 1.1 200 2 32606
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5036:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5036:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
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

ALSA lib pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_dmix.c:1108:(snd_pcm_dmix_open) unable to open slave
Expression 'alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )' failed in 'src/hostapi/alsa/pa_linux$
alsa.c', line: 924

I don't know what all the pulseaudio errors mean. I had pulseaudio installed once, but removed it from my system. Might this be an issue?

synesthesiam commented 4 years ago

44 bytes is the length of the WAV header, so it's getting no audio samples. What do you see when you run the microphone test in settings?

moritzschaefer commented 4 years ago

My .asoundrc wasn't configured correctly which caused this issue. Sorry for the inconveniences.