desbma / GoogleSpeech

Read text using Google Translate TTS API
GNU Lesser General Public License v2.1
161 stars 37 forks source link

Is there a way to run this as a root user? #25

Closed deltabravozulu closed 3 years ago

deltabravozulu commented 3 years ago

I seem to be unable to run this as root. Use case: I share a .bashrc with my root account. I wanted to have it announce when a switch is made, but it doesn't work.

sudo google_speech -l en "hi"
Playing speech segment (en): 'hi'
Home directory not accessible: Permission denied
Home directory not accessible: Permission denied
sox WARN alsa: can't encode 0-bit Unknown or not applicable

If I try to use my user account, it results in a similar problem:

$ sudo -H -u username google_speech -l en "hi"
Playing speech segment(en): 'hi'
sox WARN alsa: can't encode 0-bit Unknown or not applicable
desbma commented 3 years ago

google_speech needs a writable cache dir which would be /root/.cache for root.

It also needs a way to play audio, which is though pulseaudio in most systems, which is only running for user sessions, not root.

There is probably a way to run pulseaudio for the root user, but this is highly discouraged in their documentation, and it's a bad idea to do multimedia stuff as root anyway.