Spaces:
Build error
Build error
Reduced GPU wait time for testing, removed preemptive Whisper load
Browse files
app.py
CHANGED
@@ -24,12 +24,12 @@ device = "cuda" if cuda_available else "cpu"
|
|
24 |
logger.info(f"Using device: {device}")
|
25 |
|
26 |
# Load Whisper model
|
27 |
-
print("Loading Whisper model...")
|
28 |
-
try:
|
29 |
-
|
30 |
-
except Exception as e:
|
31 |
-
|
32 |
-
|
33 |
|
34 |
print("Whisper model loaded successfully.")
|
35 |
|
@@ -57,11 +57,11 @@ def process_with_fallback(func, *args, **kwargs):
|
|
57 |
else:
|
58 |
raise
|
59 |
|
60 |
-
@spaces.GPU(duration=
|
61 |
def transcribe_audio(audio_file, translate, model_size, use_diarization):
|
62 |
return process_with_fallback(process_audio, audio_file, translate=translate, model_size=model_size, use_diarization=use_diarization)
|
63 |
|
64 |
-
@spaces.GPU(duration=
|
65 |
def summarize_text(text):
|
66 |
summarizer = load_summarization_model()
|
67 |
try:
|
@@ -72,7 +72,7 @@ def summarize_text(text):
|
|
72 |
summary = "Error occurred during summarization. Please try again."
|
73 |
return summary
|
74 |
|
75 |
-
@spaces.GPU(duration=
|
76 |
def process_and_summarize(audio_file, translate, model_size, use_diarization, do_summarize):
|
77 |
transcription, full_text = transcribe_audio(audio_file, translate, model_size, use_diarization)
|
78 |
summary = summarize_text(full_text) if do_summarize else ""
|
@@ -81,12 +81,12 @@ def process_and_summarize(audio_file, translate, model_size, use_diarization, do
|
|
81 |
# Main interface
|
82 |
with gr.Blocks() as iface:
|
83 |
gr.Markdown("# WhisperX Audio Transcription, Translation, and Summarization (with ZeroGPU support)")
|
84 |
-
|
85 |
audio_input = gr.Audio(type="filepath")
|
86 |
translate_checkbox = gr.Checkbox(label="Enable Translation")
|
87 |
summarize_checkbox = gr.Checkbox(label="Enable Summarization", interactive=False)
|
88 |
-
model_dropdown = gr.Dropdown(choices=["tiny", "base", "small", "medium", "large", "large-v2", "large-v3"], label="Whisper Model Size", value="small")
|
89 |
diarization_checkbox = gr.Checkbox(label="Enable Speaker Diarization")
|
|
|
90 |
process_button = gr.Button("Process Audio")
|
91 |
transcription_output = gr.Textbox(label="Transcription/Translation")
|
92 |
summary_output = gr.Textbox(label="Summary")
|
|
|
24 |
logger.info(f"Using device: {device}")
|
25 |
|
26 |
# Load Whisper model
|
27 |
+
# print("Loading Whisper model...")
|
28 |
+
# try:
|
29 |
+
# load_models() # Load Whisper model
|
30 |
+
# except Exception as e:
|
31 |
+
# logger.error(f"Error loading Whisper model: {str(e)}")
|
32 |
+
# raise
|
33 |
|
34 |
print("Whisper model loaded successfully.")
|
35 |
|
|
|
57 |
else:
|
58 |
raise
|
59 |
|
60 |
+
@spaces.GPU(duration=60)
|
61 |
def transcribe_audio(audio_file, translate, model_size, use_diarization):
|
62 |
return process_with_fallback(process_audio, audio_file, translate=translate, model_size=model_size, use_diarization=use_diarization)
|
63 |
|
64 |
+
@spaces.GPU(duration=60)
|
65 |
def summarize_text(text):
|
66 |
summarizer = load_summarization_model()
|
67 |
try:
|
|
|
72 |
summary = "Error occurred during summarization. Please try again."
|
73 |
return summary
|
74 |
|
75 |
+
@spaces.GPU(duration=60)
|
76 |
def process_and_summarize(audio_file, translate, model_size, use_diarization, do_summarize):
|
77 |
transcription, full_text = transcribe_audio(audio_file, translate, model_size, use_diarization)
|
78 |
summary = summarize_text(full_text) if do_summarize else ""
|
|
|
81 |
# Main interface
|
82 |
with gr.Blocks() as iface:
|
83 |
gr.Markdown("# WhisperX Audio Transcription, Translation, and Summarization (with ZeroGPU support)")
|
84 |
+
|
85 |
audio_input = gr.Audio(type="filepath")
|
86 |
translate_checkbox = gr.Checkbox(label="Enable Translation")
|
87 |
summarize_checkbox = gr.Checkbox(label="Enable Summarization", interactive=False)
|
|
|
88 |
diarization_checkbox = gr.Checkbox(label="Enable Speaker Diarization")
|
89 |
+
model_dropdown = gr.Dropdown(choices=["tiny", "base", "small", "medium", "large", "large-v2", "large-v3"], label="Whisper Model Size", value="small")
|
90 |
process_button = gr.Button("Process Audio")
|
91 |
transcription_output = gr.Textbox(label="Transcription/Translation")
|
92 |
summary_output = gr.Textbox(label="Summary")
|