You are not logged in.

#1 2014-12-03 01:26:51

emacsomancer
Member
Registered: 2014-09-20
Posts: 211

[Solved] pulseaudio issues - running shell-commands from emacs?

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).


[It's possible though probably unlikely that this is related to other issues I'm having with pulseaudio -- running the AUR package pulseaudio-ctl, whenever I wake my screen from sleep, I have to kill and restart pulseaudio to get it to connect properly with pulseaudio-ctl.]

Last edited by emacsomancer (2014-12-03 14:17:04)

Offline

#2 2014-12-03 04:37:48

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,950

Re: [Solved] pulseaudio issues - running shell-commands from emacs?

From the scratch buffer:

;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.

(shell-command "mpv -really-quiet ~/flotsam/diversions/daisy.wav")

Works.

(shell-command
 (concat "mplayer -really-quiet " "~/flotsam/diversions/daisy.wav"))

Works, but audio breaks.

(shell-command
 (concat "mpv -really-quiet " "~/flotsam/diversions/daisy.wav"))

Works Great

(shell-command
                (concat "mplayer -really-quiet " "~/flotsam/diversions/daisy.wav" " 2> /dev/null"))

Works, But audio breaks.

(shell-command
                (concat "mpv -really-quiet " "~/flotsam/diversions/daisy.wav" " 2> /dev/null"))

Works Great

From the console:

[ewaller@odin ~]$ # This breaks up:
[ewaller@odin ~]$ mplayer flotsam/diversions/daisy.wav 
MPlayer SVN-r37224 (C) 2000-2014 MPlayer Team
210 audio & 441 video codecs
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing flotsam/diversions/daisy.wav.
libavformat version 55.33.100 (internal)
Audio only file format detected.
Load subtitles in flotsam/diversions/
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 8000 Hz, 1 ch, u8, 64.0 kbit/100.00% (ratio: 8000->8000)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
AO: [pulse] 8000Hz 1ch u8 (1 bytes per sample)
Video: no video
Starting playback...
A:   0.1 (00.1) of 48.0 (48.0) ??,?% 
Audio device got stuck!
A:   0.1 (00.1) of 48.0 (48.0)  0.0% 
Audio device got stuck!
A:   0.5 (00.4) of 48.0 (48.0)  0.0% 
Audio device got stuck!
A:   0.8 (00.7) of 48.0 (48.0)  0.0% 


MPlayer interrupted by signal 2 in module: play_audio
Audio device got stuck!
A:   0.8 (00.7) of 48.0 (48.0)  0.0% 

Exiting... (Quit)
[ewaller@odin ~]$ # This works great !
[ewaller@odin ~]$ mpv flotsam/diversions/daisy.wav 
Playing: flotsam/diversions/daisy.wav
[stream] Audio (+) --aid=1 (pcm_u8)
AO: [pulse] 8000Hz stereo 2ch u8
A: 00:00:48 / 00:00:48 (99%)


Exiting... (End of file)
[ewaller@odin ~]$ 

Last edited by ewaller (2014-12-03 04:39:46)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2014-12-03 14:16:33

emacsomancer
Member
Registered: 2014-09-20
Posts: 211

Re: [Solved] pulseaudio issues - running shell-commands from emacs?

Hmm... I'll have to try mpv player to see if it works better.

In any case, I solved the main issue I was having by running paprefs and choosing "enable network access to local sound devices" and under that also "don't require authentication".


(Although, actually, on my office computer, I don't seem to be able to successfully run  `notify-send` via an Emacs' shell-command, for some reason)

Last edited by emacsomancer (2014-12-04 02:15:04)

Offline

Board footer

Powered by FluxBB