Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,6 +24,9 @@ def create_interface():
|
|
| 24 |
execution_time = gr.Textbox(label="Execution Time", visible=False)
|
| 25 |
detected_language = gr.Textbox(label="Detected Language", visible=False)
|
| 26 |
|
|
|
|
|
|
|
|
|
|
| 27 |
charts_and_explanations = []
|
| 28 |
for _ in range(6): # 3 analysis types * 2 speakers
|
| 29 |
with gr.Row():
|
|
@@ -33,16 +36,25 @@ def create_interface():
|
|
| 33 |
|
| 34 |
def process_and_update(input_file):
|
| 35 |
if input_file is None:
|
| 36 |
-
return [gr.update(value="No file selected")] + [gr.update(visible=False)] *
|
| 37 |
|
| 38 |
results = process_input(input_file, progress=gr.Progress())
|
| 39 |
|
| 40 |
if len(results) != 10:
|
| 41 |
-
return [gr.update(value="Error: Unexpected number of results")] + [gr.update(visible=False)] *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
|
| 44 |
-
results = results[:3] + results[3:6]
|
| 45 |
-
return update_visibility_and_charts(*results)
|
| 46 |
|
| 47 |
def use_example_video():
|
| 48 |
return example_video_path
|
|
@@ -50,7 +62,7 @@ def create_interface():
|
|
| 50 |
input_file.upload(
|
| 51 |
fn=process_and_update,
|
| 52 |
inputs=[input_file],
|
| 53 |
-
outputs=[status_text, execution_time, detected_language] + charts_and_explanations
|
| 54 |
)
|
| 55 |
|
| 56 |
example_button.click(
|
|
@@ -60,7 +72,7 @@ def create_interface():
|
|
| 60 |
).then(
|
| 61 |
fn=process_and_update,
|
| 62 |
inputs=[input_file],
|
| 63 |
-
outputs=[status_text, execution_time, detected_language] + charts_and_explanations
|
| 64 |
)
|
| 65 |
|
| 66 |
return iface
|
|
|
|
| 24 |
execution_time = gr.Textbox(label="Execution Time", visible=False)
|
| 25 |
detected_language = gr.Textbox(label="Detected Language", visible=False)
|
| 26 |
|
| 27 |
+
# Add a Textbox for the SRT transcription
|
| 28 |
+
transcription_text = gr.Textbox(label="Transcription", visible=False, lines=10)
|
| 29 |
+
|
| 30 |
charts_and_explanations = []
|
| 31 |
for _ in range(6): # 3 analysis types * 2 speakers
|
| 32 |
with gr.Row():
|
|
|
|
| 36 |
|
| 37 |
def process_and_update(input_file):
|
| 38 |
if input_file is None:
|
| 39 |
+
return [gr.update(value="No file selected")] + [gr.update(visible=False)] * 21 # +1 for transcription
|
| 40 |
|
| 41 |
results = process_input(input_file, progress=gr.Progress())
|
| 42 |
|
| 43 |
if len(results) != 10:
|
| 44 |
+
return [gr.update(value="Error: Unexpected number of results")] + [gr.update(visible=False)] * 21
|
| 45 |
+
|
| 46 |
+
# Extract transcription from results (assuming it's the last item)
|
| 47 |
+
transcription = results[-1]
|
| 48 |
+
|
| 49 |
+
# Remove token information and transcription from results
|
| 50 |
+
results = results[:3] + results[3:6] + [transcription]
|
| 51 |
+
|
| 52 |
+
visibility_updates = update_visibility_and_charts(*results[:6])
|
| 53 |
+
|
| 54 |
+
# Add update for transcription text
|
| 55 |
+
transcription_update = gr.update(value=transcription, visible=True)
|
| 56 |
|
| 57 |
+
return visibility_updates + [transcription_update]
|
|
|
|
|
|
|
| 58 |
|
| 59 |
def use_example_video():
|
| 60 |
return example_video_path
|
|
|
|
| 62 |
input_file.upload(
|
| 63 |
fn=process_and_update,
|
| 64 |
inputs=[input_file],
|
| 65 |
+
outputs=[status_text, execution_time, detected_language] + charts_and_explanations + [transcription_text]
|
| 66 |
)
|
| 67 |
|
| 68 |
example_button.click(
|
|
|
|
| 72 |
).then(
|
| 73 |
fn=process_and_update,
|
| 74 |
inputs=[input_file],
|
| 75 |
+
outputs=[status_text, execution_time, detected_language] + charts_and_explanations + [transcription_text]
|
| 76 |
)
|
| 77 |
|
| 78 |
return iface
|