|
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) |
|
|
|
audio_base64 = base64.b64encode(audio_data).decode("utf-8") |
|
|
|
|
|
|
|
payload = { |
|
"inputs": audio_data, |
|
} |
|
|
|
response = requests.post(API_URL, headers=headers, data=payload) |
|
return response.json() |
|
|
|
output = query("sample1.flac") |
|
print("-----------------") |
|
print(output) |
|
|