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

Audio problem when running as a service #157

Closed santi4488 closed 7 years ago

santi4488 commented 7 years ago

When running alexapi as a service, I can hear the audio and her responses, but it is not picking up my voice.
Checking the status gave me this:

AlexaPi.service - Alexa client for all your devices Loaded: loaded (/usr/lib/systemd/system/AlexaPi.service; enabled) Drop-In: /etc/systemd/system/AlexaPi.service.d └─restart.conf Active: active (running) since Thu 2017-01-05 13:24:02 CST; 13s ago Docs: https://github.com/alexa-pi/AlexaPi/wiki Main PID: 4176 (python) CGroup: /system.slice/AlexaPi.service ├─4176 /usr/bin/python /opt/AlexaPi/src/main.py └─4192 /usr/bin/pulseaudio --start --log-target=syslog

Jan 05 13:24:05 raspberrypi pulseaudio[4192]: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11 Jan 05 13:24:05 raspberrypi pulseaudio[4192]: [pulseaudio] bluez4-util.c: org.bluez.Manager.GetProperties() failed: org.freedesktop.DBus.Error.UnknownMethod: Method "GetProperties" with signature "" on interface "org.bluez.Manager" doesn't exist Jan 05 13:24:08 raspberrypi python[4176]: Checking Internet Connection... Jan 05 13:24:08 raspberrypi python[4176]: Connection OK Jan 05 13:24:08 raspberrypi python[4176]: Traceback (most recent call last): Jan 05 13:24:08 raspberrypi python[4176]: File "/opt/AlexaPi/src/main.py", line 587, in Jan 05 13:24:08 raspberrypi python[4176]: loop() Jan 05 13:24:08 raspberrypi python[4176]: File "/opt/AlexaPi/src/main.py", line 505, in loop Jan 05 13:24:08 raspberrypi python[4176]: inp = alsaaudio.PCM(alsaaudio.PCM_CAPTURE, alsaaudio.PCM_NORMAL, config['sound']['input_device']) Jan 05 13:24:08 raspberrypi python[4176]: alsaaudio.ALSAAudioError: Device or resource busy [plughw:CARD=Device,DEV=0]

So I stopped the service and ran AlexaPi in debug mode from command line, and to my surprise, everything works fine. I can talk to alexa and she replies back no problem. I have no idea what the problem could be as I'm a beginner at dealing with audio in linux.

I set the audio input and output in the config.yaml file. sound: input_device: "plughw:CARD=Device,DEV=0" output: output_device: "plughw:CARD=ALSA,DEV=0"

This is the output from arecord -L:

null Discard all samples (playback) or generate zero samples (capture) pulse PulseAudio Sound Server sysdefault:CARD=Device USB PnP Sound Device, USB Audio Default Audio Device front:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio Front speakers surround21:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio 2.1 Surround output to Front and Subwoofer speakers surround40:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio 4.0 Surround output to Front and Rear speakers surround41:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio 4.1 Surround output to Front, Rear and Subwoofer speakers surround50:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio 5.0 Surround output to Front, Center and Rear speakers surround51:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio 5.1 Surround output to Front, Center, Rear and Subwoofer speakers surround71:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers iec958:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio IEC958 (S/PDIF) Digital Audio Output dmix:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio Direct sample mixing device dsnoop:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio Direct sample snooping device hw:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio Direct hardware device without any conversions plughw:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio Hardware device with all software conversions

renekliment commented 7 years ago

If you want to run it under a desktop OS, you have to set up PulseAudio in system-wide mode. Checkout out the wiki at the right repo. This doesn't concern this repo, closing.