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.
post
https://identify-eu-west-1.acrcloud.com
/v1/identify
Identifying an audio file or a fingerprint file
Python
PHP
Java
Javascript
ReactNative
Ruby
"""
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 = "http://###YOUR_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('/Users/olym/Downloads/test.mp3', '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)
<?php
$http_method = "POST";
$http_uri = "/v1/identify";
$data_type = "audio";
$signature_version = "1" ;
$timestamp = time() ;
// Replace "###...###" below with your project's host, access_key and access_secret.
$requrl = "http://###YOUR_HOST###/v1/identify";
$access_key = '###YOUR_ACCESS_KEY###';
$access_secret = '###YOUR_ACCESS_SECRET###';
$string_to_sign = $http_method . "\n" .
$http_uri ."\n" .
$access_key . "\n" .
$data_type . "\n" .
$signature_version . "\n" .
$timestamp;
$signature = hash_hmac("sha1", $string_to_sign, $access_secret, true);