An open API service indexing awesome lists of open source software.

https://github.com/loiccoyle/shazam-cli

🎶 CLI music recognition using the Shazam API
https://github.com/loiccoyle/shazam-cli

cli music music-recognition shazam

Last synced: 5 months ago
JSON representation

🎶 CLI music recognition using the Shazam API

Awesome Lists containing this project

README

          

# 🎶 shazam-cli




Record audio and use the [Shazam](https://rapidapi.com/apidojo/api/shazam/) music recognition API from the command line. It is free for 500 queries per month.

The [`shazam`](./shazam) scripts queries the Shazam API. This repository also contains [`shazam-notif`](./shazam-notif) which uses [`shazam`](./shazam) and `libnotify` to return the match result.

## 📦 Installation

### Dependencies

The `shazam` script requires:

- [curl](https://github.com/curl/curl)
- [ffmpeg](https://git.ffmpeg.org/ffmpeg.git)

In addition to the above the `shazam-notif` script requires:

- [jq](https://github.com/stedolan/jq)
- notify-send
- [dunst](https://github.com/dunst-project/dunst) (optional)

#### Manual

Just clone this repo and place the `shazam` and `shazam-notif` scripts on your `$PATH`.

#### Arch (AUR)

Using your favourite AUR helper:

```sh
paru -S shazam-cli-git
```

## 📋 Usage

To use these scripts you'll need your own API key.
It can be obtained from [`rapidapi`](https://rapidapi.com/apidojo/api/shazam/) you'll need a RapidAPI account and subscribe to the Shazam API (there is a free a plan).
Provide the API key either through the `-a` flag or by writing to `${XDG_CONFIG_HOME:-$HOME/.config}/shazam-cli/key`.

```
$ shazam -h
Usage: shazam [OPTION]... [FILE]
Query the Shazam music recognition API.

Get free API access at: https://rapidapi.com/apidojo/api/shazam/

The API key can be read from file:
$ echo "api-key" > "~/.config/shazam-cli/key"

If no FILE is provided, a recording is made using the AUDIO_SOURCE.

Usage:
-h Show this message and exit.
-a API_KEY API token.
-s AUDIO_SOURCE ffmpeg audio input source, (default: "default").
-t RECORDING_TIME Length of recording time, in seconds, (default: 5).
```

> You can use `ffmpeg -sources pulse` to list available sources.