PK!xԢacr_cloud/__init__.pyfrom .acrcloud import ACRCloud PK!R۟acr_cloud/acrcloud.pyimport os import time import base64 import hmac import hashlib import requests class ACRCloud: def __init__(self, host, access_key, access_secret): self.host = host self.access_key = access_key self.access_secret = access_secret self.endpoint = "/v1/identify" self.signature_version = "1" self.data_type = "audio" self.http_post_method = "POST" def identify(self, file_path): timestamp = time.time() string_to_sign = '\n'.join([self.http_post_method, self.endpoint, self.access_key, self.data_type, self.signature_version, str(timestamp)]) sign = base64.b64encode(hmac.new(self.access_secret, string_to_sign.encode('utf-8'), digestmod=hashlib.sha1).digest()) f = open(file_path, "rb") sample_bytes = os.path.getsize(file_path) files = {'sample': f} data = { 'access_key': self.access_key, 'data_type': self.data_type, "signature_version": self.signature_version, 'sample_bytes': sample_bytes, 'timestamp': str(timestamp), 'signature': sign } url = "http://{}{}".format(self.host, self.endpoint) r = requests.post(url, files=files, data=data) return r.json() PK!HnHTUacr_cloud-0.1.1.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!H–o"acr_cloud-0.1.1.dist-info/METADATAT]O0}RĤua`Tx8Gbiɿuo{+ "A$2z |~ KdnʔG|D۲(:+ ɴ ['E~+2p.4Pԩʸa)Tamu&\;\MM*'ME_lnT}(ПON ?b\xV u3cZg6FW% g2'B .J"w{+PP>O%w>9ǣ ? )̌CrWYp0[>ftv3kzot1og\QՃ#PU"`},@sw0& iJSV%e3xS: 0@Ʒ 2b:!(b1 nn ~ycqE҄ʔ ̔yE*[_wDž"`LGn "D$V`-v[UPO>=0- ݭ'HxՕ\X )X4&,k;.=rV> k\3fmIt,UtZM^ܠp1 Z&TQԙY0y gugMaOَYs=(PK5f -O) :TyySe}}&B樭"IU;OA )x՟x,C^C5 l+CX&2;)Z#Oh=`vPK!xԢacr_cloud/__init__.pyPK!R۟Racr_cloud/acrcloud.pyPK!HnHTUnacr_cloud-0.1.1.dist-info/WHEELPK!H–o"acr_cloud-0.1.1.dist-info/METADATAPK!H8:Dn  acr_cloud-0.1.1.dist-info/RECORDPKq4