Beets and Song Recognition?

I’m throwing this out to the Beets Community in case it proves useful as an adjunct to Beets for processing unknown or questionable music files.

There is a project underway at Github called SongRec that uses Shazam to identify music. It comes as both a GUI app and command line tool and can (by use of the GUI) monitor and identify a live signal as well (see Features below).

Installation is drop-dead simple on Linux and it can be compiled on other platforms.

From the ReadMe SongRec’s main features are:

• Recognize audio from an arbitrary audio file.
• Recognize audio from the microphone.
• Usage from both GUI and command line (for the file recognition part).
• Provide an history of the recognized songs on the GUI, exportable to CSV.
• Continuous song detection from the microphone, with the ability to choose your input device.
• Ability to recognize songs from your speakers rather than your microphone (on compatible PulseAudio setups).
• Generate a lure from a song that, when played, will fool Shazam into thinking that it is the concerned song.

While it is currently written in Rust, Python code is also available.

By use of the command line tool you can grab the entire metadata “dump” from Shazam which includes fields like release year, album art URI, Youtube and Deezer links, genre, label, and lyrics (sometimes).

It’s still a young program but it might prove useful to anyone who spends time messing with lots of partially (or badly) tagged audio files or needs a quick and easy way to identify songs for an application.

1 Like

Beets does have some fingerprinting support already, via AcoustID:

But the SongRec project is still interesting since Shazam is a totally different technology than AcoustID. It would be cool if some day SongRec supported more than only Shazam, since there are several different fingerprinting approaches out there. And in the meantime, a beets plugin using SongRec would be neat.

Relatedly, I found this thread interesting:

One danger with Shazam is I suspect it has close ties with the music labels and their digital catalogues. You could for example have a 1980 master of Abbey Road that gets matched with the 2009 master. And the name that comes back could be some garbage like “Come Together (2009 Remastered)”.

I just tested SongRec and the JSON metadata is awesome! I would really appreciate a plugin that imports shazam metadata for autotag in beets.

Example:

$ songrec audio-file-to-recognized-song "Jorge\ Ben\ -\ Zumbi.mp3"

{
  "location": {
    "altitude": 300.0,
    "latitude": 45.0,
    "longitude": 2.0
  },
  "matches": [
    {
      "channel": "0",
      "frequencyskew": -0.0051016808,
      "id": "448688159",
      "offset": 100.004882812,
      "timeskew": -0.0051327944
    }
  ],
  "tagid": "a3e48bb1-a57a-4d0a-9c3c-e4f2c4109258",
  "timestamp": 1259618148,
  "timezone": "Europe/Paris",
  "track": {
    "albumadamid": "1444036491",
    "artists": [
      {
        "adamid": "117436",
        "id": "16416"
      }
    ],
    "genres": {
      "primary": "MPB"
    },
    "highlightsurls": {
      "artisthighlightsurl": "https://cdn.shazam.com/video/v3/en/US/android/117436/highlights?affiliate=mttnagencyid%3Ds2n%26mttnsiteid%3D125115%26mttn3pid%3DApple-Shazam%26mttnsub1%3DShazam_android_am%26mttnsub2%3D5348615A-616D-3235-3830-44754D6D5973%26itscg%3D30201%26app%3Dmusic%26itsct%3DShazam_android_am",
      "relatedhighlightsurl": "https://cdn.shazam.com/video/v3/en/US/android/16416/artist-similarities-id-16416/relatedhighlights?max_artists=5&affiliate=mttnagencyid%3Ds2n%26mttnsiteid%3D125115%26mttn3pid%3DApple-Shazam%26mttnsub1%3DShazam_android_am%26mttnsub2%3D5348615A-616D-3235-3830-44754D6D5973%26itscg%3D30201%26app%3Dmusic%26itsct%3DShazam_android_am"
    },
    "hub": {
      "actions": [
        {
          "id": "1444036647",
          "name": "apple",
          "type": "applemusicplay"
        },
        {
          "name": "apple",
          "type": "uri",
          "uri": "https://audio-ssl.itunes.apple.com/itunes-assets/AudioPreview115/v4/59/fa/74/59fa746a-8077-d6d7-66e3-1be09532890b/mzaf_12528279220818632514.plus.aac.ep.m4a"
        }
      ],
      "displayname": "APPLE MUSIC",
      "explicit": false,
      "image": "https://images.shazam.com/static/icons/hub/android/v5/applemusic_{scalefactor}.png",
      "options": [
        {
          "actions": [
            {
              "name": "hub:applemusic:deeplink",
              "type": "intent",
              "uri": "intent://music.apple.com/us/album/zumbi/1444036491?i=1444036647&mttnagencyid=s2n&mttnsiteid=125115&mttn3pid=Apple-Shazam&mttnsub1=Shazam_android_am&mttnsub2=5348615A-616D-3235-3830-44754D6D5973&itscg=30201&app=music&itsct=Shazam_android_am#Intent;scheme=http;package=com.apple.android.music;action=android.intent.action.VIEW;end"
            },
            {
              "id": "1444036647",
              "name": "hub:applemusic:connect",
              "type": "applemusicconnect",
              "uri": "https://unsupported.shazam.com"
            },
            {
              "name": "hub:applemusic:androidstore",
              "type": "uri",
              "uri": "https://play.google.com/store/apps/details?id=com.apple.android.music&referrer=utm_source=https%3A%2F%2Fmusic.apple.com%2Fsubscribe%3Fmttnagencyid%3Ds2n%26mttnsiteid%3D125115%26mttn3pid%3DApple-Shazam%26mttnsub1%3DShazam_android_am%26mttnsub2%3D5348615A-616D-3235-3830-44754D6D5973%26itscg%3D30201%26app%3Dmusic%26itsct%3DShazam_android_am"
            }
          ],
          "beacondata": {
            "providername": "applemusic",
            "type": "open"
          },
          "caption": "OPEN",
          "colouroverflowimage": false,
          "image": "https://images.shazam.com/static/icons/hub/android/v5/overflow-open-option_{scalefactor}.png",
          "listcaption": "Open in Apple Music",
          "overflowimage": "https://images.shazam.com/static/icons/hub/android/v5/applemusic-overflow_{scalefactor}.png",
          "providername": "applemusic",
          "type": "open"
        }
      ],
      "providers": [
        {
          "actions": [
            {
              "name": "hub:spotify:searchdeeplink",
              "type": "uri",
              "uri": "spotify:search:Zumbi%20Jorge%20Ben"
            }
          ],
          "caption": "Open in Spotify",
          "images": {
            "default": "https://images.shazam.com/static/icons/hub/android/v5/spotify_{scalefactor}.png",
            "overflow": "https://images.shazam.com/static/icons/hub/android/v5/spotify-overflow_{scalefactor}.png"
          },
          "type": "SPOTIFY"
        },
        {
          "actions": [
            {
              "name": "hub:youtubemusic:androiddeeplink",
              "type": "uri",
              "uri": "https://music.youtube.com/search?q=Zumbi+Jorge+Ben&feature=shazam"
            }
          ],
          "caption": "Open in YouTube Music",
          "images": {
            "default": "https://images.shazam.com/static/icons/hub/android/v5/youtubemusic_{scalefactor}.png",
            "overflow": "https://images.shazam.com/static/icons/hub/android/v5/youtubemusic-overflow_{scalefactor}.png"
          },
          "type": "YOUTUBEMUSIC"
        },
        {
          "actions": [
            {
              "name": "hub:deezer:searchdeeplink",
              "type": "uri",
              "uri": "deezer-query://www.deezer.com/play?query=%7Btrack%3A%27Zumbi%27%20artist%3A%27Jorge+Ben%27%7D"
            }
          ],
          "caption": "Open in Deezer",
          "images": {
            "default": "https://images.shazam.com/static/icons/hub/android/v5/deezer_{scalefactor}.png",
            "overflow": "https://images.shazam.com/static/icons/hub/android/v5/deezer-overflow_{scalefactor}.png"
          },
          "type": "DEEZER"
        }
      ],
      "type": "APPLEMUSIC"
    },
    "images": {
      "background": "https://is5-ssl.mzstatic.com/image/thumb/Features125/v4/e5/54/00/e554009f-9e1d-ba72-16ff-a567404c27f7/pr_source.png/800x800cc.jpg",
      "coverart": "https://is1-ssl.mzstatic.com/image/thumb/Music125/v4/b0/7d/23/b07d2358-9e7b-4dc7-ca5d-b4befa349fab/06UMGIM49335.rgb.jpg/400x400cc.jpg",
      "coverarthq": "https://is1-ssl.mzstatic.com/image/thumb/Music125/v4/b0/7d/23/b07d2358-9e7b-4dc7-ca5d-b4befa349fab/06UMGIM49335.rgb.jpg/400x400cc.jpg",
      "joecolor": "b:ffffffp:000000s:191617t:333333q:474545"
    },
    "isrc": "BRMCA7400136",
    "key": "45574939",
    "layout": "5",
    "relatedtracksurl": "https://cdn.shazam.com/shazam/v3/en/US/android/-/tracks/track-similarities-id-45574939?startFrom=0&pageSize=20&connected=",
    "sections": [
      {
        "metadata": [
          {
            "text": "A Tabua de Esmeralda",
            "title": "Album"
          },
          {
            "text": "Universal Music Ltda.",
            "title": "Label"
          },
          {
            "text": "1974",
            "title": "Released"
          }
        ],
        "metapages": [
          {
            "caption": "Jorge Ben",
            "image": "https://is5-ssl.mzstatic.com/image/thumb/Features125/v4/e5/54/00/e554009f-9e1d-ba72-16ff-a567404c27f7/pr_source.png/800x800cc.jpg"
          },
          {
            "caption": "Zumbi",
            "image": "https://is1-ssl.mzstatic.com/image/thumb/Music125/v4/b0/7d/23/b07d2358-9e7b-4dc7-ca5d-b4befa349fab/06UMGIM49335.rgb.jpg/400x400cc.jpg"
          }
        ],
        "tabname": "Song",
        "type": "SONG"
      },
      {
        "beacondata": {
          "commontrackid": "1744495",
          "lyricsid": "22983991",
          "providername": "musixmatch"
        },
        "footer": "Writer(s): Ben Jorge\nLyrics powered by www.musixmatch.com",
        "tabname": "Lyrics",
        "text": [
          "Angola Congo Benguela",
          "Monjolo Cabinda Mina",
          "Quiloa Rebolo",
          "Aqui onde estão os homens",
          "",
          "Há um grande leilão",
          "Dizem que nele há uma princesa à venda",
          "Que veio junto com seus súditos",
          "Acorrentados em carros de bois",
          "",
          "Eu quero ver",
          "Eu quero ver",
          "Eu quero ver",
          "Eu quero ver",
          "",
          "Angola Congo Benguela",
          "Monjolo Cabinda Mina",
          "Quiloa Rebolo",
          "Aqui onde estão os homens",
          "",
          "Dum lado cana de açúcar",
          "Do outro lado o cafezal",
          "Ao centro senhores sentados",
          "Vendo a colheita do algodão branco",
          "Sendo colhidos por mãos negras",
          "",
          "Eu quero ver",
          "Eu quero ver",
          "Eu quero ver",
          "Eu quero ver",
          "",
          "Quando Zumbi chegar",
          "O que vai acontecer",
          "Zumbi é senhor das guerras",
          "É senhor das demandas",
          "Quando Zumbi chega",
          "É Zumbi é quem manda",
          "",
          "Zumbi é senhor das guerras",
          "É senhor das demandas",
          "Quando Zumbi chega",
          "É Zumbi é quem manda, ê",
          "",
          "Eu quero ver",
          "Eu quero ver",
          "Eu quero ver",
          "Eu quero ver",
          "",
          "Angola Congo Benguela (eu quero ver, eu quero ver, eu quero ver)",
          "Monjolo Cabinda Mina (eu quero ver, eu quero ver, eu quero ver)",
          "Quiloa Rebolo (eu quero ver, eu quero ver, eu quero ver)",
          "",
          "Angola Congo Benguela",
          "Monjolo Cabinda Mina",
          "Quiloa Rebolo",
          "",
          "Angola Congo Benguela (eu quero ver quando Zumbi chegar)",
          "Monjolo Cabinda Mina (o que vai acontecer, eu quero ver)",
          "Quiloa"
        ],
        "type": "LYRICS",
        "url": "https://cdn.shazam.com/lyrics/v1/en/US/android/musixmatch/subtitles/1744495/210/1?token=736438045311dcb73fac6f805b0ffa19"
      },
      {
        "tabname": "Video",
        "type": "VIDEO",
        "youtubeurl": "https://cdn.shazam.com/video/v3/-/US/android/45574939/youtube/video?q=Jorge+Ben+%22Zumbi%22"
      },
      {
        "actions": [
          {
            "id": "16416",
            "type": "artistposts"
          },
          {
            "id": "16416",
            "type": "artist"
          }
        ],
        "avatar": "https://is5-ssl.mzstatic.com/image/thumb/Features125/v4/e5/54/00/e554009f-9e1d-ba72-16ff-a567404c27f7/pr_source.png/800x800cc.jpg",
        "id": "16416",
        "name": "Jorge Ben",
        "tabname": "Artist",
        "toptracks": {
          "url": "https://cdn.shazam.com/shazam/v3/en/US/android/-/tracks/artisttoptracks_16416?startFrom=0&pageSize=20&connected="
        },
        "type": "ARTIST",
        "url": "https://cdn.shazam.com/digest/v1/en/US/android/artist/16416/recentpost",
        "verified": false
      },
      {
        "tabname": "Related",
        "type": "RELATED",
        "url": "https://cdn.shazam.com/shazam/v3/en/US/android/-/tracks/track-similarities-id-45574939?startFrom=0&pageSize=20&connected="
      }
    ],
    "share": {
      "avatar": "https://is5-ssl.mzstatic.com/image/thumb/Features125/v4/e5/54/00/e554009f-9e1d-ba72-16ff-a567404c27f7/pr_source.png/800x800cc.jpg",
      "href": "https://www.shazam.com/track/45574939/zumbi",
      "html": "https://www.shazam.com/snippets/email-share/45574939?lang=en&country=US",
      "image": "https://is1-ssl.mzstatic.com/image/thumb/Music125/v4/b0/7d/23/b07d2358-9e7b-4dc7-ca5d-b4befa349fab/06UMGIM49335.rgb.jpg/400x400cc.jpg",
      "snapchat": "https://www.shazam.com/partner/sc/track/45574939",
      "subject": "Zumbi - Jorge Ben",
      "text": "I used Shazam to discover Zumbi by Jorge Ben.",
      "twitter": "I used @Shazam to discover Zumbi by Jorge Ben."
    },
    "subtitle": "Jorge Ben",
    "title": "Zumbi",
    "type": "MUSIC",
    "url": "https://www.shazam.com/track/45574939/zumbi",
    "urlparams": {
      "{trackartist}": "Jorge+Ben",
      "{tracktitle}": "Zumbi"
    }
  }
}

It could bring together several beets plugins in one place, with a single query and ZERO extra settings.

1 Like