Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -93,14 +93,7 @@ def transcribe_audio_api(audio_filepath):
|
|
| 93 |
audio=handle_file(audio_filepath),
|
| 94 |
api_name="/predict"
|
| 95 |
)
|
| 96 |
-
|
| 97 |
-
if isinstance(result, dict) and 'text' in result:
|
| 98 |
-
transcript = result['text']
|
| 99 |
-
elif isinstance(result, str):
|
| 100 |
-
transcript = result
|
| 101 |
-
else:
|
| 102 |
-
transcript = f"Error: Unexpected response format from transcription service: {type(result)}"
|
| 103 |
-
return transcript if transcript is not None else "Error: Empty transcript received."
|
| 104 |
except Exception as e:
|
| 105 |
print(f"Error during transcription API call: {e}")
|
| 106 |
return f"Error during transcription: {e}"
|
|
@@ -276,10 +269,12 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
|
|
| 276 |
syllable_transcript = "Error: No reference text found."
|
| 277 |
# Return 7 values
|
| 278 |
return transcript, syllable_transcript, None, None, None, "", ""
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
|
|
|
|
|
|
| 283 |
# --- Calculate Metrics and Highlight Errors (only if first transcript is not an error) ---
|
| 284 |
if not transcript.startswith("Error"):
|
| 285 |
wer, der, cer = calculate_metrics(reference_text, transcript)
|
|
|
|
| 93 |
audio=handle_file(audio_filepath),
|
| 94 |
api_name="/predict"
|
| 95 |
)
|
| 96 |
+
return result[0], result[1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
except Exception as e:
|
| 98 |
print(f"Error during transcription API call: {e}")
|
| 99 |
return f"Error during transcription: {e}"
|
|
|
|
| 269 |
syllable_transcript = "Error: No reference text found."
|
| 270 |
# Return 7 values
|
| 271 |
return transcript, syllable_transcript, None, None, None, "", ""
|
| 272 |
+
try:
|
| 273 |
+
# --- Call Transcription APIs ---
|
| 274 |
+
transcript, syllable_transcript = transcribe_audio_api(audio_filepath)
|
| 275 |
+
except:
|
| 276 |
+
print(f"Error calculating metrics: {e}")
|
| 277 |
+
transcript, syllable_transcript = "error", "error"
|
| 278 |
# --- Calculate Metrics and Highlight Errors (only if first transcript is not an error) ---
|
| 279 |
if not transcript.startswith("Error"):
|
| 280 |
wer, der, cer = calculate_metrics(reference_text, transcript)
|