Identification API

Request this API you should use “multipart/form-data” Content-Type. You can use this API to identify all of the audio formats or fingerprint extracted with our SDK/Tools. We suggest you use data type “fingerprint”, which will reduce the internet bandwidth and accelerate recognition speeds. Also, we suggest you do not use a large file to request this API, this can cause delays, its advised to reduce the file size before upload, files that are less than 15 seconds are generally better.

Identifying an audio file or a fingerprint file

POST https://identify-eu-west-1.acrcloud.com/v1/identify

Request Body

{
    "metadata":{
        "timestamp_utc":"2020-01-19 02:58:28",
        "music":[
            {
                "db_begin_time_offset_ms":0,
                "db_end_time_offset_ms":9280,
                "sample_begin_time_offset_ms":0,
                "sample_end_time_offset_ms":9280,
                "play_offset_ms":9040,
                "artists":[
                    {
                        "name":"Adele",
                        "langs":[{"code":"zh-Hans", "name":"阿黛尔"}]
                    }
                ],
                "lyrics":{
                    "copyrights":[
                        "Sony/ATV Music Publishing LLC",
                        "Universal Music Publishing Group"
                    ]
                },
                "acrid":"6049f11da7095e8bb8266871d4a70873",
                "album":{
                    "name":"Hello",
                    "langs":[{"code":"zh-Hans","name":"Hello"}]
                },
                "rights_claim": [
                    {"distributor":{"id":"PADPIDA2007050901U", "name":"Warner Music Group"},"rights_owners":[{"name":"Warner Music Group", "share_percentage":100.00}],"rights_claim_policy":"monetize", "territories":["AD","AE","AF"]},
                    {"distributor":{"id":"PADPIDA2007040502I", "name":"Sony Music Entertainment"}, "rights_owners":[{"name":"Sony Music Entertainment", "share_percentage":100.00}],"territories":["AB","AC"]}
               ],                
               "external_ids":{
                    "iswc":"T-917.819.808-8",
                    "isrc":"GBBKS1500214",
                    "upc":"886445581959"
                },
                "result_from":3,
                "contributors":{
                    "composers":[
                        "Adele Adkins",
                        "Greg Kurstin"
                    ],
                    "lyricists":[
                        "ADELE ADKINS",
                        "GREGORY KURSTIN"
                    ]
                },
                "title":"Hello",
                "langs":[{"code":"zh-Hans","name":"Hello"}]
                "language":"en",
                "duration_ms":295000,
                "label":"XL Recording",
                "external_metadata":{
                    "musicbrainz":[
                        {
                            "track":{
                                "id":"0a8e8d55-4b83-4f8a-9732-fbb5ded9f344"
                            }
                        }
                    ],
                    "deezer":{
                        "track":{
                            "id":"110265034"
                        },
                        "artists":[
                            {
                                "id":"75798"
                            }
                        ],
                        "album":{
                            "id":"11483764"
                        }
                    },
                    "spotify":{
                        "track":{
                            "id":"4aebBr4JAihzJQR0CiIZJv"
                        },
                        "artists":[
                            {
                                "id":"4dpARuHxo51G3z768sgnrY"
                            }
                        ],
                        "album":{
                            "id":"7uwTHXmFa1Ebi5flqBosig"
                        }
                    },
                    "musicstory":{
                        "track":{
                            "id":"13106540"
                        },
                        "album":{
                            "id":"931271"
                        }
                    },
                    "youtube":{
                        "vid":"YQHsXMglC9A"
                    }
                },
                "score":100,
                "genres":[{"name":"Pop"}],
                "release_date":"2015-10-23"
                "release_by_territories": [{"territories": ["DK"], "release_date": "2006-04-17"}, {"territories": ["JP"], "release_date": "2006-10-17"}, {"territories": ["SE"], "release_date": "2005-06-21"}, {"territories": ["BG", "AL", "BA", "CZ", "EE", "HR", "HU", "LT", "LV", "MK", "ME", "PL", "RO", "RS", "SI", "SK", "UA"], "release_date": "2006-03-24"}, {"territories": ["GB", "IE", "NZ"], "release_date": "2005-07-18"}, {"territories": ["FR"], "release_date": "2005-07-26"}]
 
            }
        ],
        "custom_files": [
            {
                "acrid":"e6f7e3884b00fd265871754c5b64782b",
                "title":"YOUR_TITLE",
                "bucket_id":999,
                "duration_ms":295000,
                "db_begin_time_offset_ms":0,
                "db_end_time_offset_ms":9280,
                "sample_begin_time_offset_ms":0,
                "sample_end_time_offset_ms":9280,
                "key1":"value1",  //custom-defined 
                "key2":"value2"   //custom-defined 
            }
        ]
    },
    "status":{
        "msg":"Success",
        "version":"1.0",
        "code":0
    },
    "result_type":0
}

"""
This is a demo program which implements ACRCloud Identify Protocol V1 with the third party library "requests".
We recomment you implement your own app with "requests" too.
You can install this python library by:
1) sudo easy_install requests 
2) sudo pip install requests
"""

import base64
import hashlib
import hmac
import os
import sys
import time

import requests

'''
Replace "###...###" below with your project's host, access_key and access_secret.
'''
access_key = "###YOUR_ACCESS_KEY###"
access_secret = "###YOUR_ACCESS_SECRET###"
requrl = "https://###HOST###/v1/identify"

http_method = "POST"
http_uri = "/v1/identify"
# default is "fingerprint", it's for recognizing fingerprint,
# if you want to identify audio, please change data_type="audio"
data_type = "audio"
signature_version = "1"
timestamp = time.time()

string_to_sign = http_method + "\n" + http_uri + "\n" + access_key + "\n" + data_type + "\n" + signature_version + "\n" + str(
    timestamp)

sign = base64.b64encode(hmac.new(access_secret.encode('ascii'), string_to_sign.encode('ascii'),
                                 digestmod=hashlib.sha1).digest()).decode('ascii')

# suported file formats: mp3,wav,wma,amr,ogg, ape,acc,spx,m4a,mp4,FLAC, etc
# File size: < 1M , You'de better cut large file to small file, within 15 seconds data size is better
f = open(sys.argv[1], "rb")
sample_bytes = os.path.getsize(sys.argv[1])

files = [
    ('sample', ('test.mp3', open(sys.argv[1], 'rb'), 'audio/mpeg'))
]
data = {'access_key': access_key,
        'sample_bytes': sample_bytes,
        'timestamp': str(timestamp),
        'signature': sign,
        'data_type': data_type,
        "signature_version": signature_version}

r = requests.post(requrl, files=files, data=data)
r.encoding = "utf-8"
print(r.text)

Last updated