alexa-pi / AlexaPi

Alexa client for all your devices! # No active development. PRs welcome # consider https://github.com/respeaker/avs instead
MIT License
1.33k stars 396 forks source link

Input device fails after first use? #458

Open metzen13 opened 5 years ago

metzen13 commented 5 years ago

In order to help troubleshooting, be sure to include the following information:

Output of the audio debugging script. I ran this script and it created the file "alsa-info.sh", but when I nano that file it looks like the actual code for running Alsa, not a log of issues.

Your OS (including version) where you are running AlexaPi: Note: Raspbian older than Stretch is not supported!

Raspbian 9 (stretch)

Your hardware platform and model you are running on:

Raspberry Pi 3 B+

Python release (python3 --version):

Python 3.5.3

Description of problem:

I installed AlexaPi per Installation Guide.  I updated the config.yaml to note my input device as "plughw:1,0".
When I first start AlexaPi ("sudo systemctl start AlexaPi.service"), then I check status ("sudo systemctl status AlexaPi.service") I get the following:
pi@raspberrypi:~ $ sudo systemctl start AlexaPi.service
pi@raspberrypi:~ $ sudo systemctl status AlexaPi.service
● AlexaPi.service - Alexa client for all your devices
   Loaded: loaded (/usr/lib/systemd/system/AlexaPi.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-05-27 11:20:31 PDT; 2s ago
     Docs: https://github.com/alexa-pi/AlexaPi/wiki
 Main PID: 10020 (python3)
   CGroup: /system.slice/AlexaPi.service
           └─10020 /usr/bin/python3 /opt/AlexaPi/src/main.py --daemon

May 27 11:20:31 raspberrypi systemd[1]: Started Alexa client for all your devices.

However, if I immediately check status again, I get this:
pi@raspberrypi:~ $ sudo systemctl status AlexaPi.service
● AlexaPi.service - Alexa client for all your devices
   Loaded: loaded (/usr/lib/systemd/system/AlexaPi.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2019-05-27 11:20:34 PDT; 1s ago
     Docs: https://github.com/alexa-pi/AlexaPi/wiki
  Process: 10020 ExecStart=/usr/bin/python3 /opt/AlexaPi/src/main.py --daemon (code=exited, status=1/FAILURE)
 Main PID: 10020 (code=exited, status=1/FAILURE)

May 27 11:20:34 raspberrypi python3[10020]: ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
May 27 11:20:34 raspberrypi python3[10020]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
May 27 11:20:34 raspberrypi python3[10020]: 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
May 27 11:20:34 raspberrypi python3[10020]: connect(2) call to /tmp/jack-999/default/jack_0 failed (err=No such file or directory)
May 27 11:20:34 raspberrypi python3[10020]: attempt to connect to server failed
May 27 11:20:34 raspberrypi python3[10020]: CRITICAL: Your input_device 'plughw:1,0' is invalid. Use one of the following:
May 27 11:20:34 raspberrypi python3[10020]: USB Camera-B4.09.24.1: Audio (plughw:1,0)
May 27 11:20:34 raspberrypi systemd[1]: AlexaPi.service: Main process exited, code=exited, status=1/FAILURE
May 27 11:20:34 raspberrypi systemd[1]: AlexaPi.service: Unit entered failed state.
May 27 11:20:34 raspberrypi systemd[1]: AlexaPi.service: Failed with result 'exit-code'.

It doesn't seem like it can be an issue with the format of the input device, since it runs okay at first.

I also took a test recording and played it back with the following commands, which worked perfectly.
arecord -f S16_LE -r 16000 -D your_input_device test.wav
aplay -f S16_LE -r 16000 test.wav

I am using a Playstation Eye as input and a bluetooth speaker as output.

Expected:

Not to get a failure after checking status twice/waiting for a period of time (see Additional info below).

Problem-relevant config.yaml entries:

Steps to reproduce:

Traceback (if applicable):

Additional info:

I tried this again and the failure seems to be connected to how long I wait to check status, not how many times.  I.E. if I start AlexaPi.service and wait for a while before checking status, I will get the same failure as above (I don't need to check it twice to get the failure, just wait long enough.)  Is the device in-use?  I was getting some errors about that a while back in my troubleshooting, but I thought I fixed it since I'm not getting any in-use errors for my recordings and playbacks outside of AlexaPi.
metzen13 commented 5 years ago

I think I fixed this by entering the entire line ("CameraB409241 [USB Camera-B4.09.24.1], device 0: USE Audio [USB Audio]" for "input_device"