14

Which bash command will indicate the sound output speaker(output or no output), so I can reset my web radio when it crashes?

1
  • 1
    It sounds like this question does not want to test that the speakers work, he wants to find out if the OS is currently playing any sound through them. Thus he doesn't want to play sound but to find out if any sound is currently playing. Dec 13, 2015 at 12:14

4 Answers 4

38

This is a really good command testing out all speakers.

speaker-test -t wav -c 6

Remarks on usage

There is no loud noise heard when running this command, except a voice saying "front left, front center, front right...". This command will continue to repeat the testing, until the user presses Ctrl+c keys to stop the testing.

4
  • 3
    +1 because tested working in Xubuntu 14.04. This works well and there is no loud noise when running this command.
    – user37165
    Dec 13, 2015 at 8:55
  • 2
    With -l, you can actually specify the loop count if you want it to stop after so many iterations, as in -l2. Dec 10, 2019 at 9:28
  • +1 as this allows to interactively stop playback with <kbd>Ctrl</kbd>+<kbd>Z</kbd> and it worked on OpenMediaVault 5.5.12-1 out of the box when I connected via SSH for playback on an Odroid Home Cloud 2 single board computer which has USB and an USB digital audio speaker attached.
    – porg
    Nov 26, 2020 at 21:08
  • 2
    CTRL+Z stop and paced the job(speaker-test) in the bg (background). You can list the jobs stopped with jobs command. Actually you need to kill the job with, CTRL+C , It take many seconds. May 3, 2021 at 1:40
3

Assuming that all you want is to check if the there is an output on the speaker, Use

speaker-test
3
  • yeah and for more info you can use this manpages.ubuntu.com/manpages/natty/man1/speaker-test.1.html
    – Raja G
    Jun 9, 2012 at 3:32
  • OP said speaker-test is too noise for him in duplicate question which should be closed soon. Alternatives?
    – ish
    Jun 9, 2012 at 23:11
  • Without the -t option, this outputs a ton of loud static, which you might not like on headphones!
    – A B
    Nov 9, 2023 at 14:36
2

To test a two channel (left and right) setup, this plays a voice saying "front left", "front right", then exits:

speaker-test -t wav -c 2 -l 1

For a surround sound setup, set -c to as many channels as you have:

speaker-test -t wav -c 6 -l 1

Meaning of the options:

  • -t,--test wav play a voice instead of static/noise
  • -l,--nloops 1 test only once
  • -c,--channels number of output channels to test
0

If you want it to exit even faster, set both voice output (-t wav) and one loop (-l 1):

speaker-test -t wav -l 1

On my setup, it defaults to one channel (-c 1), so this just speaks "front left" once and then exits.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .