When you think of music recognition, Shazam is probably the first service that springs to mind. It's completely free to use and available for Android and iOS on the mobile and macOS and Windows on the desktop side of things. Linux, unfortunately, doesn't get a desktop client.

So how do you recognize music on Linux, then? Well, as its turns out, there's an unofficial Shazam client to help you with music recognition on Linux. It's called SongRec, and it can do a lot more than the official Shazam service.

Follow along as we demonstrate its use on Linux.

What Is SongRec?

SongRec is a free and open-source Shazam client for Linux. It's written in Rust and helps you identify songs in a couple of ways. In addition to allowing you to recognize audio via the microphone/speaker, which most song recognition services do, SongRec also lets you identify songs through audio files stored on your computer.

A list of all recognized songs is available under SongRec history. Plus, you even have the option to export it as a CSV file to keep a record of your Shazam-ed songs when you're switching devices.

One of the standout features of SongRec is the ability to identify songs via the CLI, which is something you don't get to see on most music recognition services, including Shazam (on Mac and Windows).

How to Install SongRec on Linux

SongRec is available via repositories as well as Flatpak. Depending on what Linux distro you're using on your computer, follow the instructions below to install SongRec:

On Debian/Ubuntu, open the terminal and run the commands below:

        sudo apt-add-repository ppa:marin-m/songrec
sudo apt install songrec

To install it on Arch Linux, use:

        sudo pacman -S songrec
    

On other Linux distros, you can install SongRec via Flatpak. For this, first, ensure your system has Flatpak by opening a terminal and running:

        flatpak --version
    

If this returns a version number, like Flatpak 1.6.5, it means Flatpak is present on your system, and you can proceed with SongRec installation. However, if it doesn't, you'll have to install Flatpak first. Follow our Flatpak guide to learn how to do this.

Once you've installed Flatpak, go back to the terminal and run the following command to install SongRec:

        flatpak install flathub com.github.marinm.songrec
    

Since Flatpak packages run inside a sandbox, you won't be able to use some of SongRec's CLI features if you install it via Flatpak.

How to Identify Songs With the SongRec GUI

SongRec supports both GUI and CLI for recognizing audio on Linux. So depending on how you'd like to identify songs on your machine, follow the instructions in the sections below.

No matter the installation method you use to install SongRec on your machine, you'll get a quick access shortcut inside the Applications menu. Go ahead and run it to launch SongRec.

Once the SongRec GUI is up, do the following:

  1. Click on the Audio input dropdown and select default.
  2. Tap on the Turn on microphone recognition button to enable the microphone.
SongRec basic configuration

1. Identify a Song Playing on Another Device

If you have a song on your phone or another device that you want to identify, start playing it and bring the device closer to your Linux desktop that's running SongRec. Wait for a few seconds, and SongRec will return the song name, artist, and album under Recognition results.

identifying song from another-device

2. Listen to a Complete Song

If you'd like to listen to a song you've just identified, click on the Search on YouTube button in its search result, and SongRec will open the song on YouTube in your default web browser.

3. Identify a Song Playing on the Same Device

Similar to identifying songs playing on other devices, if there's an audio clip on your desktop that you'd like to identify, SongRec can help you with that as well.

For this, open SongRec and tick the Recognize from my speakers instead of microphone checkbox to allow SongRec to listen to your speakers.

recognize audio from speaker

Now, go to the directory that contains the audio file you want to identify and play it. Give SongRec a few seconds, and it will return all the song details.

4. Identify a Song via Audio File

Aside from identifying songs playing in the background, SongRec also gives you the ability to determine a song via an audio file. To do this, click on the Recognize from file button on the SongRec home screen and select the audio file using the file explorer to upload it to SongRec. Soon, you'll see all the details about the song on the app.

5. View Song History

Over time, as you use SongRec, you'll accumulate a list of all the songs you've identified. SongRec saves this for you for future reference, and you can find it under Recognition history on the right.

SongRec recognition history

To clear the recognition history, hit the Wipe history button.

Identify Songs With SongRec Using the CLI

While SongRec's graphical interface is pretty intuitive and works really well, if you prefer working in the terminal, you can use SongRec's CLI to identify songs instead.

A quick way to identify a song in SongRec is to launch its GUI from the terminal, like this:

        songrec
    

Doing so will run SongRec graphically and start identifying the song playing on another device or the same machine. However, if you'd like to see the output in the terminal itself, play the audio on the other device or the same machine and use the following command:

        songrec recognize
    

Output:

identifying songs via CLI

Similarly, you can also identify multiple songs, back-to-back, inside the terminal. To do this, run the command below, and SongRec will start recognizing music:

        songrec listen
    

Output:

identifying songs via CLI

To stop the recognition, hit Ctrl + C.

Lastly, if you want to identify the song from an audio file present on your system, you can do it easily from the terminal. For this, first, use the cd and ls commands to navigate to the directory containing the audio file, and then run this command to identify its audio:

        songrec recognize file_name.mp3
    

Output:

identifying song on device

Export SongRec History as CSV

SongRec saves your recognized songs in a CSV file by default. To find it, open the terminal and cd into ~/.local/share/SongRec. Next, enter the ls command to list all the files and directories. Here, you should see a file with the name song_history.csv. To view its content, enter:

        cat song_history.csv
    

Output:

export SongRec history

If, for some reason, you don't find the CSV file under SongRec, open the GUI and tap on the Export to CSV button. This will open a Text Import dialog box. Click OK to generate the CSV, and load it into a CSV reader like LibreOffice Calc.

export SongRec history

Accurately Identify Music on Your Linux Computer

SongRec makes identifying songs on Linux incredibly easy. It works flawlessly and can identify songs across a gamut of genres.

Although there are other Linux music recognition tools, SongRec far outperforms them as it relies on Shazam's servers for identification, which makes it pretty accurate at recognizing songs.

We hope this guide gives you a head start and helps you navigate SongRec so that you can recognize songs on your Linux machine.

Besides, if you're interested in learning about how Shazam works, we've got you covered on that front as well.