AlexaPi icon indicating copy to clipboard operation
AlexaPi copied to clipboard

Support PulseAudio / write docs regarding PA

Open eugenelai opened this issue 10 years ago • 48 comments

I've installed the package exactly as outlined however I'm getting the following error message:

Oct 09 23:25:11 raspberrypi python[576]: alsaaudio.ALSAAudioError: Input/output error [plughw:1] Oct 09 23:25:11 raspberrypi systemd[1]: AlexaPi.service: main process exited, code=exited, status=1/FAILURE Oct 09 23:25:11 raspberrypi systemd[1]: Unit AlexaPi.service entered failed state. Oct 09 23:25:12 raspberrypi systemd[1]: AlexaPi.service holdoff time over, scheduling restart. Oct 09 23:25:12 raspberrypi systemd[1]: Stopping Alexa client for all your devices... Oct 09 23:25:12 raspberrypi systemd[1]: Starting Alexa client for all your devices... Oct 09 23:25:12 raspberrypi systemd[1]: Started Alexa client for all your devices. Oct 09 23:25:17 raspberrypi python[1321]: Checking Internet Connection... Oct 09 23:25:17 raspberrypi python[1321]: Connection OK Oct 09 23:25:17 raspberrypi python[1321]: Home directory not accessible: Permission denied Oct 09 23:25:17 raspberrypi python[1321]: W: [pulseaudio] core-util.c: Failed to open configuration file '/home/alexapi/.config/pulse//daemon.conf': Permission denied Oct 09 23:25:17 raspberrypi python[1321]: W: [pulseaudio] daemon-conf.c: Failed to open configuration file: Permission denied Oct 09 23:25:17 raspberrypi python[1321]: Home directory not accessible: Permission denied Oct 09 23:25:17 raspberrypi python[1321]: W: [pulseaudio] core-util.c: Failed to open configuration file '/home/alexapi/.config/pulse//daemon.conf': Permission denied Oct 09 23:25:17 raspberrypi python[1321]: W: [pulseaudio] daemon-conf.c: Failed to open configuration file: Permission denied Oct 09 23:25:18 raspberrypi python[1321]: Home directory not accessible: Permission denied Oct 09 23:25:18 raspberrypi python[1321]: W: [pulseaudio] core-util.c: Failed to open configuration file '/home/alexapi/.config/pulse//daemon.conf': Permission denied Oct 09 23:25:18 raspberrypi python[1321]: W: [pulseaudio] daemon-conf.c: Failed to open configuration file: Permission denied

Anyone have any ideas?

eugenelai avatar Oct 09 '16 15:10 eugenelai

Hey, thanks for reporting. I'll work on a fix regarding PulseAudio when I find some time.

Does it work though? You can just ignore the messages for now if it does. If it doesn't, try tweaking the audio device in the configuration file. You can give default a shot.

renekliment avatar Oct 10 '16 10:10 renekliment

I'm having a lot of issues setting up my audio as well. My setup is outputting audio over the analog jack and using a USB microphone. I've tried changing the audio device within AlexaPi's configuration and I've changed the default devices of alsa to be my usb microphone. My setup changes have either stopped AlexaPi from working entirely or have only allowed me to use it after starting in manually on boot.

lsumner4 avatar Oct 19 '16 15:10 lsumner4

@lsumner4 Are you using PulseAudio? We have yet to fix the support for PA. Please provide logs.

renekliment avatar Oct 19 '16 15:10 renekliment

Yes, I'm using pulse audio. Is there any other option on Raspberry Pi? My log on startup now: Oct 19 13:13:59 raspberrypi systemd[1]: Starting Alexa client for all your devices... Oct 19 13:13:59 raspberrypi systemd[1]: Started Alexa client for all your devices. Oct 19 13:14:22 raspberrypi python[737]: Home directory not accessible: Permission denied Oct 19 13:14:22 raspberrypi python[737]: W: [pulseaudio] core-util.c: Failed to open configuration file '/home/alexapi/.config/pulse//daemon.conf': Permission denied Oct 19 13:14:22 raspberrypi python[737]: W: [pulseaudio] daemon-conf.c: Failed to open configuration file: Permission denied Oct 19 13:14:22 raspberrypi python[737]: Home directory not accessible: Permission denied Oct 19 13:14:22 raspberrypi python[737]: W: [pulseaudio] core-util.c: Failed to open configuration file '/home/alexapi/.config/pulse//daemon.conf': Permission denied Oct 19 13:14:22 raspberrypi python[737]: W: [pulseaudio] daemon-conf.c: Failed to open configuration file: Permission denied Oct 19 13:14:22 raspberrypi python[737]: Home directory not accessible: Permission denied Oct 19 13:14:22 raspberrypi python[737]: W: [pulseaudio] core-util.c: Failed to open configuration file '/home/alexapi/.config/pulse//daemon.conf': Permission denied Oct 19 13:14:22 raspberrypi python[737]: W: [pulseaudio] daemon-conf.c: Failed to open configuration file: Permission denied

lsumner4 avatar Oct 19 '16 17:10 lsumner4

Ditto and i hear nothing.... Home directory not accessible: Permission denied Oct 19 21:33:40 raspberrypi python[548]: W: [pulseaudio] core-util.c: Failed to open configuration file '/home/alexapi/.con Oct 19 21:33:40 raspberrypi python[548]: W: [pulseaudio] daemon-conf.c: Failed to open configuration file: Permission denie Oct 19 21:33:40 raspberrypi python[548]: Home directory not accessible: Permission denied Oct 19 21:33:40 raspberrypi python[548]: W: [pulseaudio] core-util.c: Failed to open configuration file '/home/alexapi/.con Oct 19 21:33:40 raspberrypi python[548]: W: [pulseaudio] daemon-conf.c: Failed to open configuration file: Permission denie Oct 19 21:33:40 raspberrypi python[548]: Home directory not accessible: Permission denied Oct 19 21:33:40 raspberrypi python[548]: W: [pulseaudio] core-util.c: Failed to open configuration file '/home/alexapi/.con Oct 19 21:33:40 raspberrypi python[548]: W: [pulseaudio] daemon-conf.c: Failed to open configuration file: Permission denie ~

I would like to use this in a presentation coming soon, is there a known work around?

bchuckles avatar Oct 19 '16 21:10 bchuckles

@bchuckles ~~Haven't tried it yet, but

  1. comment out ProtectHome=true in /usr/lib/systemd/system/AlexaPi.service. You'll probably have to do that as the user root.
  2. if there is no directory /home/alexapi, do the following (under root):~~ ~~mkdir /home/alexapi; chown alexapi:alexapi /home/alexapi~~

~~Then you should be able to run AlexaPi normally as a service under the alexapi user. But as I said, I haven't tested it, it's just what I would try. I need to debug this and find a sensible solution instead of this hack.~~

~~The good & clean solution would be something like~~ A silly solution might be sudo usermod --home /run/AlexaPi alexapi

renekliment avatar Oct 19 '16 21:10 renekliment

@renekliment yes this might work in theory...maybe ill wait lol. With that said i guess i will have to switch it back to a pi3 since the zero doesnt have an audio out and the usb sound dongle is PulseAudio

bchuckles avatar Oct 19 '16 21:10 bchuckles

@bchuckles Check out the updated comment to see if that works.

usb sound dongle is PulseAudio

What does that mean?

renekliment avatar Oct 19 '16 22:10 renekliment

@renekliment I uninstalled Pulse Audio entirely and that seemed to solve my issue. Perhaps recommend this in step in the ReadME if it works for other people?

lsumner4 avatar Oct 19 '16 22:10 lsumner4

@lsumner4 Well, that's not a solution, that's a workaround. We need to make a fix so people can use PA if they want to.

Could you maybe test that one command with PA to see if it works? I don't have much time these days to try it out myself.

renekliment avatar Oct 19 '16 22:10 renekliment

@bchuckles, I use a C-Media usb dongle and a wifi adapter off of a micro-usb hub on the Zeros. You have to make sure that you are using a strong enough power source when you do this, though. Otherwise, you tend to see your wireless drop out on you. I am not using pulseaudio at all at this point, and it is working well.

illperipherals avatar Oct 19 '16 22:10 illperipherals

Sorry I was rushed when i was typing. I want to install on a zero i was on a 3! So maybe if i get some time tonight ill try on a zero and see how it works!

bchuckles avatar Oct 20 '16 00:10 bchuckles

By the way this is the coolest project ever for Alexa and fits my use case perfect

bchuckles avatar Oct 20 '16 00:10 bchuckles

So I guess we need to solve these situations:

  1. AlexaPi with PA in system mode - this is most probably headless systems
    • I guess here we just add alexapi in the pulse-access group
  2. AlexaPi with PA in user session mode
    • we have to solve some d-bus stuff that happens probably because it's run as a service and not as a user session
  3. AlexaPi on systems that run GUI with the user pi with PA in user session mode
    • how the fu** do we solve this?
    • we'd have to reconfigure PA to communicate over TCP / UNIX socket
    • if the user pi isn't logged in, then what?

Please let us know which scenario is yours. Suggestions welcome. If you don't use any audio apps on your pi, you can temporarily uninstall PA.

renekliment avatar Oct 21 '16 16:10 renekliment

So i am option 1, and tried on a Zero last night. I ended up removing PA. No errors which was great! But also no sound, is this now a config problem? Is there any log that shows me the calls and what is happening, maybe like debug mode. I feel helpless when it doesnt work.....even though i could debug if needed.

bchuckles avatar Oct 21 '16 17:10 bchuckles

I run most of mine in option #1 as well. What sound card are you using on the Zero? I use the C-Media USB plug off of a micro-USB hub so I can also work wireless in. You can run main.py with the -d option, but you are not going to get much info there. I suggest going through dmesg to see what is going on. I have done several Zero setups, so maybe I could help out. Can you do the general aplay/arecord -L, lsusb, dmesg, etc?

illperipherals avatar Oct 21 '16 17:10 illperipherals

Best option for debugging is to run AlexaPi from console (not as a service) with the -d option.

renekliment avatar Oct 21 '16 18:10 renekliment

I have plenty of power confirmed with meter.

here is the soundscard: https://www.amazon.com/Plugable-Headphone-Microphone-Aluminum-Compatibility/dp/B00NMXY2MO/ref=sr_1_1?ie=UTF8&qid=1477072900&sr=8-1&keywords=USB+Sound+Dongle

Yes i can run general commands, i have played with the output before and i remember its a setting i just forget what i did because it was with the first project Sam did.

Whats the command to run with -d. On that note it would be really helpful in you put how to manually run and stop your script in the readme.

@illperipherals you just ran the script and everything worked on a zero? You didnt change anything?

what distro did you use?

bchuckles avatar Oct 21 '16 18:10 bchuckles

/opt/AlexaPi/src/main.py -d

renekliment avatar Oct 21 '16 18:10 renekliment

No, I had initial issues on the Zero. Much had to do with how I wanted to handle the sound/mic issue. You are using the same card I am on the Zero, though, so I know it will work.

illperipherals avatar Oct 21 '16 19:10 illperipherals