Skip to content

Instantly share code, notes, and snippets.

@lucasvazq
Last active July 18, 2020 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasvazq/ca647796287b55f365b62963e8f042fe to your computer and use it in GitHub Desktop.
Save lucasvazq/ca647796287b55f365b62963e8f042fe to your computer and use it in GitHub Desktop.
Obtain songs by file and lyrics
#!/usr/bin/env python3
"""
Recognize vocaroo songs using audd.io API

Change api_token key in post_data variable if you have one, else, you can make
only 10 requests
"""


# E.g. song: Laura Cantrell - The Way It Is
vocaroo_url = "https://vocaroo.com/9WLJWzhBhB1"
lyrics = "I can't help myself at all"


import json
import requests
from urllib import parse

audio_file = f"https://media.vocaroo.com/mp3/{vocaroo_url.split('/')[-1]}"
api_url = f"https://api.audd.io/findLyrics/?q={parse.quote(lyrics)}"
post_data = {
    "url": audio_file,
    "api_token": "test"
}
response = requests.post(api_url, data=post_data)
text_response = json.loads(response.text)
if text_response["status"] == "success":
    for result in text_response["result"]:
        print(f"{result['artist']} - {result['title']}")

Results:

Hank Williams Jr. - Whiskey Bent And Hell Bound
The Venus Project - Need / Want
Of Verona - Dark In My Imagination
ZaeHD & CEO - Percocets & Alcohol
The crane wives - Allies or Enemies
Laura Cantrell - The Way It Is
Cody Jinks - Whiskey Bent and Hell Bound
Cooder Graw - Whiskey Bent and Hell Bound
Mark Chesnutt - Whiskey Bent And Hell Bound
Jake&Papa - Where the Wild Things Are

# The correct one is on the list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment