101Frost commited on
Commit
2f4a269
Β·
verified Β·
1 Parent(s): 054982c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
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} # <-- key changed to match your API spec
12
  response = requests.post(API_URL, files=files)
13
 
14
  if response.status_code == 200:
15
- return f"βœ… Results: {response.text.transcription}"
 
 
 
 
 
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