Spaces:
Runtime error
Runtime error
with open(audio, "rb") as f:
Browse files
main.py
CHANGED
|
@@ -34,23 +34,22 @@ async def score_audio_plus(
|
|
| 34 |
url = "https://api.elsanow.io/api/v1/score_audio_plus"
|
| 35 |
headers = {"Authorization": f"ELSA {ELSA_API_TOKEN}"}
|
| 36 |
|
| 37 |
-
# Read file content
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
response = requests.post(url, files=files, data=data, headers=headers)
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
| 54 |
|
| 55 |
if response.status_code == 200:
|
| 56 |
# Successfully made the request
|
|
|
|
| 34 |
url = "https://api.elsanow.io/api/v1/score_audio_plus"
|
| 35 |
headers = {"Authorization": f"ELSA {ELSA_API_TOKEN}"}
|
| 36 |
|
| 37 |
+
# Read file content
|
| 38 |
+
with open(audio, "rb") as f:
|
| 39 |
+
files = {
|
| 40 |
+
'audio_file': (os.path.basename(audio), f, 'audio/wav')
|
| 41 |
+
}
|
| 42 |
+
data = {
|
| 43 |
+
'api_plan': api_plan,
|
| 44 |
+
'return_json': "true" if return_json else "false"
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
# Send POST request
|
| 48 |
+
response = requests.post(url, files=files, data=data, headers=headers)
|
| 49 |
+
|
|
|
|
| 50 |
|
| 51 |
+
print("====response===")
|
| 52 |
+
print(response)
|
| 53 |
|
| 54 |
if response.status_code == 200:
|
| 55 |
# Successfully made the request
|