do you have mplayer? it's how i make a sound from a script, works flawlessly On Fri, Jan 21, 2022 at 6:21 AM Carlos E. R. <robin.listas@telefonica.net> wrote:
Hi,
I want to play a sound from a script, for example to signal it finished, but I can't.
First problem: I can't find a CLI command able to play the sound files I want, found in the default installed system:
er@Erebor4:~> aplay /usr/share/sounds/freedesktop/stereo/bell.oga Playing raw data '/usr/share/sounds/freedesktop/stereo/bell.oga' : Unsigned 8 bit, Rate 8000 Hz, Mono ^CAborted by signal Interrupt... cer@Erebor4:~>
This command produces horrible noise with any .oga file I try.
cer@Erebor4:~> madplay /usr/share/sounds/freedesktop/stereo/bell.oga MPEG Audio Decoder 0.15.2 (beta) - Copyright © 2000-2004 Robert Leslie et al. audio: No such file or directory cer@Erebor4:~>
cer@Erebor4:~> paplay /usr/share/sounds/freedesktop/stereo/bell.oga cer@Erebor4:~>
(silence...)
cer@Erebor4:~> play /usr/share/sounds/freedesktop/stereo/bell.oga
/usr/share/sounds/freedesktop/stereo/bell.oga:
File Size: 8.50k Bit Rate: 487k Encoding: Vorbis Channels: 2 @ 16-bit Samplerate: 44100Hz Replaygain: off Duration: 00:00:00.14
In:100% 00:00:00.14 [00:00:00.00] Out:6.15k [ ====|==== ] Clip:0 Done. cer@Erebor4:~>
(silence...)
I can play sounds with VLC, but not being a CLI command, it starts a GUI that then I have to close manually. "vlc --help" is huge, I have not seen a way to play a sound and exit.
I can probably convert a sound to .wav, and play that one. play, aplay, and paplay all work that way.
Second problem: I can not play them as root, and I do need them as rootm because those scripts run as root.
Erebor4:~ # su cer - -c vlc /usr/share/sounds/freedesktop/stereo/service-logout.oga VLC media player 3.0.16 Vetinari (revision 3.0.13-8-g41878ff4f2) [000055713e92b640] vlcpulse audio output error: PulseAudio server connection failure: *Connection refused* [000055713e8494e0] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface. QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-cer' [000055713e84ba40] main playlist: playlist is empty QObject::~QObject: Timers cannot be stopped from another thread Erebor4:~ #
Erebor4:~ # vlc /usr/share/sounds/freedesktop/stereo/service-logout.oga VLC is not supposed to be run as root. Sorry. If you need to use real-time priorities and/or privileged TCP ports you can use vlc-wrapper (make sure it is Set-UID root and cannot be run by non-trusted users first). Erebor4:~ #
Erebor4:~ # su cer - -c "aplay /usr/share/sounds/freedesktop/stereo/service-logout.oga" ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
aplay: main:830: audio open error: Connection refused Erebor4:~ #
Erebor4:~ # su cer - -c "paplay /usr/share/sounds/freedesktop/stereo/service-logout.oga" Connection failure: Connection refused pa_context_connect() failed: Connection refused Erebor4:~ #
stuck.
-- Cheers / Saludos,
Carlos E. R.
(from oS Leap 15.3 x86_64 (Erebor-4))