ericmattmann's picture
update
990550b
raw
history blame contribute delete
740 Bytes
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)