File size: 740 Bytes
9b0a5af |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import requests
import base64
import json
API_URL = "https://w4a3d6hyuuiyrznb.eu-west-1.aws.endpoints.huggingface.cloud"
headers = {
"Authorization": "Bearer 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",
"Content-Type": "application/json"
}
def query(filename):
with open(filename, "rb") as f:
audio_data = f.read()
print(audio_data)
# Encode the audio data as base64
audio_base64 = base64.b64encode(audio_data).decode("utf-8")
# print(audio_base64)
# Construct the JSON payload
payload = {
"inputs": audio_data,
}
response = requests.post(API_URL, headers=headers, data=payload)
return response.json()
output = query("sample1.flac")
print("-----------------")
print(output)
|