Playing wav files in linux

Play MP3 or WAV file via the Linux command line

I would like to make an alarm system backed by a Ubuntu (no graphical interface) box, which plays various announcement and alarm audio tracks (.mp3 or .wav) via the command line. For example:

The audio should come from the PC audio jack. I might also wrap it with another socket listener (for example, Ruby Sinatra). How can I do this?

10 Answers 10

mpg123 is a command-line utility which plays mp3 files. You can install it in Ubuntu with:

sudo apt-get install mpg123 

The play command from the sox package will play any file format supported by sox using the default audio device, e.g

$ play something.mp3 $ play something.wav 

You may need to install extra packages to gain support for all formats, for example on Ubuntu 11.04 the MP3 support is not available until you install libsox-fmt-mp3 .

The most standard way to play a WAV file in Linux is using the aplay command, which is part of the ALSA system.

aplay [flags] [filename [filename]] . aplay a.wav 

(Both in Fedora and in Ubuntu/Mint it is part of the alsa-utils package)

This does not require any additional packages to your Linux installation like sox or mplayer or vlc, just the basic ALSA which is a part of any system nowadays.

Thanks for the tip! I added this alias to my shell config: alias beep=»aplay —quiet /usr/share/sounds/pop.wav» . That way I can get a notification when long running commands finish. For example: compile && run && beep

Yes, Jesse! I do exactly the same with compiling (long file conversions, etc). I use sounds from here: «Opilki sounds» (they are under the Creatve Commons license) forgive me this minor advertisement, i’m not related to the project in any way 🙂

sudo apt-get install vlc vlc-plugin-pulse mozilla-plugin-vlc 

Make sure that you have all repositories open. Also run the following before you install:

VLC has a command-line operation method invoked by cvlc . The next part would be to write a .sh that will call the command. I am no good at writing bash scripts. The end-result would be something like:

cvlc xyz.mp3 cvlc --play-and-exit done.mp3 

cvlc —play-and-exit —no-loop done.mp3 . I need the extra option —no-loop , so that the sound file is not repeated over and over. (vlc 2.2.2, xubuntu 16.04.4)

note that vlc usually depends on qt5 and X on some distribution, but mpg123 depends on only alsa-lib.

Читайте также:  Linux mint display resolution

You can simply pipe your sound data to the pc speaker device:

On Ubuntu 16.04 (Xenial Xerus), there is no need to install anything. You can play a sound using paplay with is part of the PulseAudio sound server:

I would think this works only if paplay —list-file-formats includes MP3 in the format list, which it does not on my machine (which, admittedly, is not Ubuntu). Does paplay ever really include MP3?

Correct. WAV seems to be on that list but not MP3. You might need to install proprietary codecs. On Ubuntu that would be sudo apt-get install ubuntu-restricted-extras .

MPlayer is another player which can play pretty much any audio/video format from command line. To install it in Ubuntu just execute this command:

sudo apt-get install mplayer 

You can then play the file using this syntax:

FFmpeg is installed on my Ubuntu 19.04 (Disco Dingo)

$ ffplay music.mp3 -nodisp hide spectrum analyzer -nostats hide cursor/file information -hide_banner hide build information Hide all (no output): $ ffplay music.mp3 -nodisp -nostats -hide_banner 

canberra-gtk-play

For simple Bash scripts MPlayer is probably a bit too heavy and too verbose in terms of output. A built-in option is canberra-gtk-play which comes preinstalled on Ubuntu:

canberra-gtk-play --file=/usr/share/sounds/gnome/default/alerts/drip.ogg 

Note: it uses the alerts volume, and you must pass —file= in order to play a file from a path.

It can also play a sound by id which represents the file name without extension of media files under /usr/share/sounds (apparently this only works for sounds that are registered as part of a sound theme):

canberra-gtk-play --id="desktop-login" canberra-gtk-play --id="message" 

gst-launch-1.0/gst-launch-0.10

Another option is using the gstreamer command-line tools which are present on most modern Linux boxes:

gst-launch-1.0 playbin uri=file:///usr/share/sounds/ubuntu/stereo/message.ogg 

To suppress all output redirect it to /dev/null :

gst-launch-1.0 playbin uri=file:///usr/share/sounds/ubuntu/stereo/message.ogg > /dev/null 2>&1 

Both gst-launch-1.0 and gst-launch-0.10 might be present on your system.

Источник

How to Listen to WAV Files on Ubuntu

You can also use the keyboard shortcut “Ctrl + O”. Search for the WAV music file you need to listen to. The music is there! Select the music and click the “Play” button.

  1. How do I play audio files in Ubuntu?
  2. How do I play music through Ubuntu terminal?
  3. How do I play audio files in Linux terminal?
  4. What devices play WAV files?
  5. How do I open an audio file in CMD?
  6. What are the best audio players for Linux?
  7. How do I open a music file in Linux?
  8. What is the default music player in boss Linux?
  9. How do you use CMus?
  10. Where are $path stored Linux?
  11. How do I play MP3 files in terminal?
  12. How do I play an audio file with FFmpeg?

How do I play audio files in Ubuntu?

Using VLC Player to play MP3 Music Files

Click on Media from the top menu bar. Then from the drop-down list, select Open File. In the window that appears, choose the mp3 file that you want to play and click on Open. It will instantly play the mp3 file in VLC player.

How do I play music through Ubuntu terminal?

MOC or Music on Console is a command-line music player for Linux and Unix like systems. All you have to do is install the player, select a file from a directory using the MOC menu and all files in that directory start playing, starting from the selected file. MOC is an easy to use yet powerful tool.

Читайте также:  Монтирование разделов linux fstab

How do I play audio files in Linux terminal?

  1. Launch the terminal (Ctrl + Alt +T) type the command below and strike enter: sudo apt-get install sox.
  2. Input your password and hit enter.
  3. Type “y” without quotes and hit enter.
  4. After installation has been completed, run the command below to make SoX play . .
  5. After the installation is done.

What devices play WAV files?

WAV files are widely used, and because of this, many programs can open them on different platforms—Windows Media Player, Winamp, iTunes, VLC, and QuickTime, to name a few. Windows and macOS users can play WAV files right out of the box without having to install any third-party software.

How do I open an audio file in CMD?

The Windows Media Player can run from the command line, or in a batch file, to play sound files. In Windows 10, the Media Player executable file is located at Program Files (x86)\Windows Media Player\wmplayer.exe. In previous versions of Windows, the Media Player executable was named mplay32.exe or mplayer.exe.

What are the best audio players for Linux?

  1. Rhythmbox Audio Player. .
  2. Clementine Music Player. .
  3. Audacious Audio Player. .
  4. Amarok Music Player. .
  5. DeaDBeef Audio Player. .
  6. CMUS – Console Music Player. .
  7. Sayonara Audio Player. .
  8. MOC – Terminal Music Player.

How do I open a music file in Linux?

Just go to the folder containing the MP3 files that you want to play and type mpg123 *. mp3. You can also load a playlist file and use the *-z* option on the command line to shuffle the tracks you want to play. If you’re adamant about using truly open formats, then you’ll want to go with Ogg Vorbis for your music.

What is the default music player in boss Linux?

RhythmBox is the default music player for many Linux distributions including Ubuntu. It is nice music player with support for most of the audio formats. It is designed using Gstreamer media framework, basically for GNOME desktop but works well on other desktop environments as well.

How do you use CMus?

Some CMus keys to control Play

Press *c* to pause/unpause Press right/left to seek by 10 seconds Press ** seek by one minute Press «r» to repeat the track Press «s» to random order to play all tracks.

Where are $path stored Linux?

The Global environment variables of your system are stored in /etc/environment . Any changes here will get reflected throughout the system and will affect all users of the system. Also, you need a Reboot, for any changes made here to take effect. User level Environment variables are mostly stored in .

How do I play MP3 files in terminal?

Install the Sox Command Line Utility

Sox is easily available through the Official Ubuntu repository and can be installed through the command line using the apt-get command. Open your Terminal application either through the system Application Launcher Search or through the Ctrl+Alt+T shortcut.

Читайте также:  Linux for windows gui

How do I play an audio file with FFmpeg?

You can use AudioTrack class to play audio onto device. In order to use the FFmpeg as an audio playback tool you can untilize FFplay (available for Windows and for Linux). It’s as simple as: ffplay The audio track must be of a supported format, meaning you will need some libraries.

Top 3 Video Players for Ubuntu

Player

Best Linux video playersVLC Media Player. Key Highlights: . MPlayer. Key Highlights: . SMPlayer. Key Highlights: . MPV Player. Key Highlights: .

Best Icon Packs for Linux

Icon

Best icon themes for Ubuntu and other Linux distributionsPop icon theme. This is my favorite icon theme and this is why it took the top spot here.Papi.

At Command in Linux

Command

at is a command-line utility that allows you to schedule commands to be executed at a particular time. Jobs created with at are executed only once. In.

Latest news, practical advice, detailed reviews and guides. We have everything about the Linux operating system

Источник

How to Listen to WAV Files on Ubuntu

There are a number of available media file types all over the internet, each of them having their own features and disadvantages. Thanks to the community that powers the Linux platform, there are a number of available apps that are able to play the majority of them for you.

What is WAV?

WAV (Waveform Audio File Format) is an audio file format. WAV is an IBM and Microsoft standard file format for storing an audio bitstream on the PC platform. There are a lot of available unpopular file formats and WAV is one of them.

Using WAV files hold a few disadvantages. For example, WAV file format has a size limitation – up to 4GB. Some programs even lower the limit – up to 2GB. Uncompressed WAV files also tend to be larger, making them not suitable for sharing over the internet. However, for retaining the sound quality, WAV is very powerful. That’s why it’s only used when disk space isn’t a bottleneck.

However, there are a number of media players you can use to play a WAV file.

Playing WAV file

For playing a WAV file, there are a number of available players. Check out the best media players for Ubuntu. Almost all the media players are available for other Linux distros as well. WAV, despite not being used as widely as MP3 or others, all the players in the list supports the file format. You won’t have any trouble listening to WAV files.

In the following demo, I’ll be using Rhythmbox – one of the most popular music players for Linux distros. Start Rhythmbox –

Now, go to File >> Add Music. You can also use the keyboard shortcut “Ctrl + O”.

Search for the WAV music file you need to listen to.

The music is there! Select the music and click the “Play” button.

Voila! Enjoy your favorite music!

Источник

Оцените статью
Adblock
detector