0

I'm trying to execute shell-commands in emacs which play sounds or otherwise involve audio output, but I'm not having much luck.

When I execute:

(shell-command
 (concat "espeak -v mb-en1 -k5 -s150 " "'" "hello" " " "world" "'" " --stdout|paplay"))

No audio output is generated and I find the following message:

Connection failure: Connection refused
pa_context_connect() failed: Connection refused
1 (#o1, #x1, ?\C-a)

A different though related problem, if I try:

(shell-command
                (concat "mplayer -really-quiet " "/usr/share/sounds/speech-dispatcher/test.wav" " 2> /dev/null"))

Again, I don't actually get any audio output and I find the message:

(Shell command succeeded with no output)
0 (#o0, #x0, ?\C-@)

Both commands work as expected from the actual terminal shell (i.e. they produce audio output).

Edit: Ok, this seems to be part of a more general problem. On my home computer I finally got everything to work by allowing greater permissions to pulse-audio. However, now on my office computer, I'm having trouble getting notify-send to work when issued in shell-command in Emacs. I'm getting the same odd 0 (#o0, #x0, ?\C-@) message when I try to do this.

  • 1
    How was your Emacs process launched? Was it from a menu in your desktop environment? If so, try running Emacs from a terminal and see if it works. It might be a problem related to the environment being richer in an actual terminal shell. – ffevotte Dec 3 '14 at 7:31
  • 1
    Also, try removing 2>/dev/null from your mplayer command, so that you can see whether there are errors. – ffevotte Dec 3 '14 at 7:32
  • @Francesco: Thanks. Emacs was run as a daemon, autostarting as a process by systemd, and running as a process owned by my username. I then launched an emacsclient instance. The errors from mplayer had to do with connecting to ALSA. – emacsomancer Dec 3 '14 at 14:20
  • 1
    Since this question is about your operating system and only peripherally about Emacs, Unix & Linux would be a better place for it. Do not repost there unless your question is closed here; you can flag your question to request that moderators migrate your question. – Gilles Dec 4 '14 at 0:43
  • 1
    What distribution are you running? What else can you tell us about your environment: apparently you're using systemd, which desktop environment do you use? Have you set up SELinux or other hardening mechanism? How do you start Emacs: from your GUI session, or do you start a daemon first? – Gilles Dec 4 '14 at 0:44
-1

Running paprefs and checking the box next to "enable network access to local sound devices" and under that also the "don't require authentication" box worked as a workaround for the problem.

  • You are aware that this enables any system in your local network to play sound on your speakers? – lunaryorn Dec 3 '14 at 14:25
  • Do you have suggestions on a more limited way of granting permissions such that I can actually get audio output via shell-commands from Emacs? – emacsomancer Dec 3 '14 at 18:32
  • Though, actually, now I'm having trouble with notify-send (see above edit). – emacsomancer Dec 3 '14 at 18:40
  • 2
    Start Emacs through your desktop environment, so that it gets proper permissions to access PulseAudio and your DBus session bus (for notify-send). – lunaryorn Dec 3 '14 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.