Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,11 +8,16 @@ def process_audio(audio_file):
|
|
| 8 |
try:
|
| 9 |
# Send the audio file to your API with the correct field name
|
| 10 |
with open(audio_file, "rb") as f:
|
| 11 |
-
files = {"audio_file": f} # <--
|
| 12 |
response = requests.post(API_URL, files=files)
|
| 13 |
|
| 14 |
if response.status_code == 200:
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
else:
|
| 17 |
return f"β Error: {response.status_code} - {response.text}"
|
| 18 |
|
|
|
|
| 8 |
try:
|
| 9 |
# Send the audio file to your API with the correct field name
|
| 10 |
with open(audio_file, "rb") as f:
|
| 11 |
+
files = {"audio_file": f} # <-- match API spec
|
| 12 |
response = requests.post(API_URL, files=files)
|
| 13 |
|
| 14 |
if response.status_code == 200:
|
| 15 |
+
try:
|
| 16 |
+
data = response.json()
|
| 17 |
+
transcription = data.get("transcription", "No transcription found")
|
| 18 |
+
return f"π Transcription: {transcription}"
|
| 19 |
+
except ValueError:
|
| 20 |
+
return f"β οΈ Could not parse JSON: {response.text}"
|
| 21 |
else:
|
| 22 |
return f"β Error: {response.status_code} - {response.text}"
|
| 23 |
|