1. Overview

Listening to the radio from a Linux terminal offers simplicity, resource efficiency, and other benefits. It enables us to listen to radio broadcasts without needing a separate graphical user interface (GUI) application. Thus, it’s ideal for low-resource systems. Additionally, it enables us to create scripts for tasks that involve audio playback or broadcasting.

In this tutorial, we’ll see a number of different ways to listen to radio from a Linux terminal. Specifically, we’ll use Ubuntu 22.04 to demonstrate each method.

Notably, we can background most commands to leave the radio playing while we interact with the system. Additionally, a public stream will serve as the sample radio channel for this tutorial.

2. Using MPlayer

MPlayer is a multimedia player for Linux and many other systems. It supports different audio and video formats, for instance, VCD, SVCD, DVD, and others. Also, MPlayer can stream and play audio files from the Web.

Let’s first install MPlayer using apt with sudo privileges:

$ sudo apt install mplayer

To listen to the radio with MPlayer, we can supply the stream link to the mplayer command:

$ mplayer http://radio.stereoscenic.com/asp-s

The above command loads and plays the stream at the specified URL. To stop the streaming, we can press the q key.

3. Using the VLC Command Line

Another popular media player, VLC, can also be used from the command line to listen to the radio.

Let’s install the VLC player:

$ sudo apt install vlc

To listen to the radio, the cvlc command comes in handy. We just supply the stream URL after the cvlc command:

$ cvlc http://radio.stereoscenic.com/asp-s

VLC now starts streaming the radio. To stop the radio streaming, we can press Ctrl + q.

4. Using Pyradio

Now, let’s explore another convenient tool for listening to the radio from the terminal – Pyradio. It’s a Python-based Internet radio player that’s both simple to use and customizable.

Pyradio can be installed using pip as long as we already have Python:

$ pip install pyradio

After installation, we run the pyradio command to start Pyradio:

$ pyradio
| 1. Afterhours.FM (Trance/Progressive)                                        │
│ 2. Bluemars (Ambient)                                                        │
│ 3. Bluemars: Cryosleep (Ambient)                                             │
│ 4. Bluemars: Voices Within (Ambient) 
...

This shows a list of available stations. We can navigate through them using the arrow keys. We can select the desired station and press Enter to listen to it.

Additionally, we can also add our custom station using the -a option. We can then add various details, such as the name of the station and stream URL:

$ sudo pyradio -a
Enter the name: Demo
Enter the url: http://radio.stereoscenic.com/asp-s

Notably, we require sudo privileges for adding a station. Alternatively, we can use the station list in the file /usr/local/lib/python3.10/dist-packages/pyradio/stations.csv to add or delete a station:

$ sudo nano /usr/local/lib/python3.10/dist-packages/pyradio/stations.csv
# Find lots more stations at http://www.iheard.com
Afterhours.FM (Trance/Progressive), http://at2.ah.fm:80 
Bluemars (Ambient), http://207.200.96.225:8020/listen.pls
...

To start listening to the radio stream, we again run the pyradio command:

$ pyradio

We can then hit the Enter key to select and play the desired station. Furthermore, to stop the radio, we simply exit Pyradio by entering the q key.

5. Using MOC (Music on Console)

MOC (Music on Console) is a lightweight, easy-to-use command-line audio player. To install MOC, we use the usual apt command:

$ sudo apt install moc

Once MOC is installed, we run the mocp command supplied with the stream link:

$ mocp http://radio.stereoscenic.com/asp-s

This opens the MOC interface on the terminal with our stream link highlighted:

MOC main window

Also, we can press the Tab key to navigate to the right panel. From here, we can choose the required file.

To stop the streaming, we first exit the MOC player and then run the mocp command with the -s option:

$ mocp -s

Let’s now turn to an interactive text-console-based MP3 player.

6. Using MP3blaster

MP3blaster is a text-based audio player that supports listening to radio streams. This is way simpler when compared to Pyradio and MOC, as we shall see.

Let’s install MP3blaster:

$ sudo apt install mp3blaster

Then, to start MP3blaster, we run the mp3blaster command with the stream URL:

$ mp3blaster http://radio.stereoscenic.com/asp-s

This opens a text-based interface and starts playing the supplied stream:

MP3Blaster main window

Also, we can browse and select radio stations and control the streaming from this interface.

7. Using MPV

MPV is a free, open-source, platform-independent media player. It can be run from the terminal. Furthermore, it’s compatible with many audio and video file types like MP4, AVI, WEBM, and others.

Let’s install MPV:

$ sudo apt install mpv

With MPV on board, we can listen to radio streams by running the mpv command followed by the stream URL:

$ mpv http://radio.stereoscenic.com/asp-s 
(+) Audio --aid=1 (mp3 2ch 44100Hz)
AO: [pulse] 44100Hz stereo 2ch float
A: 00:00:00 / 00:00:07 (14%) Cache: 5.7s/202KB
File tags:
icy-title: taennya - natural serenity
A: 00:00:14 / 00:00:30 (48%) Cache: 15s/552KB
...

As a result, MPV now starts playing the stream at the specified URL. To stop the streaming, we can enter the q key.

8. Conclusion

In this article, we’ve learned different methods to listen to the radio from the Ubuntu 22.04 terminal. Initially, we started with MPlayer and VLC. We then explored Pyradio and MOC. Finally, we saw the lightweight options with the MP3blaster and MPV players.

1 Comment
Oldest
Newest
Inline Feedbacks
View all comments
Comments are closed on this article!