Spaces:
Sleeping
Sleeping
cptsubtext
commited on
Commit
·
cb4f0e8
1
Parent(s):
a703b74
with exceptions
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ def transcribe_to_subtitle(audio_bytes, model_name):
|
|
21 |
"""Transcribe audio to subtitle using OpenAI Whisper"""
|
22 |
# Load model based on selection
|
23 |
model = load_model(model_name)
|
24 |
-
speedmodel = load_hf_whisper(model_name)
|
25 |
|
26 |
# Check file size for free tier
|
27 |
if use_free_tier and len(audio_bytes) > 2 * 60 * 1024:
|
@@ -29,16 +29,15 @@ def transcribe_to_subtitle(audio_bytes, model_name):
|
|
29 |
return
|
30 |
|
31 |
# Transcribe audio
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
return {"error": f"Error during transcription: {str(e)}"}
|
42 |
|
43 |
# Generate subtitle file
|
44 |
subtitle_text = result.text
|
|
|
21 |
"""Transcribe audio to subtitle using OpenAI Whisper"""
|
22 |
# Load model based on selection
|
23 |
model = load_model(model_name)
|
24 |
+
#speedmodel = load_hf_whisper(model_name)
|
25 |
|
26 |
# Check file size for free tier
|
27 |
if use_free_tier and len(audio_bytes) > 2 * 60 * 1024:
|
|
|
29 |
return
|
30 |
|
31 |
# Transcribe audio
|
32 |
+
try:
|
33 |
+
result = model.transcribe(audio_bytes, verbose=True)
|
34 |
+
except Exception as e:
|
35 |
+
return {"error": f"Error during transcription: {str(e)}"}
|
36 |
+
# else:
|
37 |
+
# try:
|
38 |
+
# result = speedmodel.transcribe(audio_bytes, verbose=True)
|
39 |
+
# except Exception as e:
|
40 |
+
# return {"error": f"Error during transcription: {str(e)}"}
|
|
|
41 |
|
42 |
# Generate subtitle file
|
43 |
subtitle_text = result.text
|