Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,31 +21,21 @@ LANGUAGE_MAP = {
|
|
21 |
"Arabic": "ar"
|
22 |
}
|
23 |
|
24 |
-
|
|
|
|
|
25 |
start_time = time.time()
|
26 |
|
27 |
if not video_path:
|
28 |
return [gr.Markdown("Please upload a video file.")] + [gr.update(visible=False)] * 48 + ["Analysis not started."]
|
29 |
|
30 |
-
# Convert the display name to the language code
|
31 |
-
language = LANGUAGE_MAP[language_display_name]
|
32 |
-
|
33 |
# Start the progress bar
|
34 |
progress(0, desc="Starting analysis...")
|
35 |
|
36 |
-
# Progress for diarization
|
37 |
-
progress(0.2, desc="Starting diarization...")
|
38 |
-
|
39 |
-
progress(0.
|
40 |
-
|
41 |
-
# Print the diarization results
|
42 |
-
print("Diarization Results:")
|
43 |
-
print(diarization_output)
|
44 |
-
|
45 |
-
# Progress for transcription
|
46 |
-
with open(srt_path, 'r', encoding='utf-8') as file:
|
47 |
-
transcription = file.read()
|
48 |
-
progress(0.6, desc="Transcription complete.")
|
49 |
|
50 |
# Progress for processing the transcription
|
51 |
progress(0.7, desc="Processing transcription...")
|
@@ -57,9 +47,6 @@ def analyze_video(video_path, language_display_name, max_speakers, progress=gr.P
|
|
57 |
charts, explanations = create_charts(results)
|
58 |
progress(1.0, desc="Charts generation complete.")
|
59 |
|
60 |
-
# Clean up the temporary SRT file
|
61 |
-
os.remove(srt_path)
|
62 |
-
|
63 |
end_time = time.time()
|
64 |
execution_time = end_time - start_time
|
65 |
|
@@ -104,14 +91,12 @@ def analyze_video(video_path, language_display_name, max_speakers, progress=gr.P
|
|
104 |
|
105 |
return output_components
|
106 |
|
107 |
-
|
108 |
# Define the Gradio interface
|
109 |
with gr.Blocks() as iface:
|
110 |
gr.Markdown("# AI Personality Detection")
|
111 |
gr.Markdown("Upload a video")
|
112 |
|
113 |
video_input = gr.Video(label="Upload Video")
|
114 |
-
language_input = gr.Dropdown(choices=list(LANGUAGE_MAP.keys()), value="English", label="Select Language")
|
115 |
max_speakers = gr.Slider(minimum=1, maximum=4, step=1, value=2, label="Maximum Number of Speakers")
|
116 |
|
117 |
analyze_button = gr.Button("Analyze")
|
@@ -136,7 +121,7 @@ with gr.Blocks() as iface:
|
|
136 |
|
137 |
analyze_button.click(
|
138 |
fn=analyze_video,
|
139 |
-
inputs=[video_input,
|
140 |
outputs=output_components,
|
141 |
show_progress=True
|
142 |
)
|
|
|
21 |
"Arabic": "ar"
|
22 |
}
|
23 |
|
24 |
+
# app.py
|
25 |
+
|
26 |
+
def analyze_video(video_path, max_speakers, progress=gr.Progress()):
|
27 |
start_time = time.time()
|
28 |
|
29 |
if not video_path:
|
30 |
return [gr.Markdown("Please upload a video file.")] + [gr.update(visible=False)] * 48 + ["Analysis not started."]
|
31 |
|
|
|
|
|
|
|
32 |
# Start the progress bar
|
33 |
progress(0, desc="Starting analysis...")
|
34 |
|
35 |
+
# Progress for transcription and diarization
|
36 |
+
progress(0.2, desc="Starting transcription and diarization...")
|
37 |
+
transcription = diarize_audio(video_path, max_speakers)
|
38 |
+
progress(0.6, desc="Transcription and diarization complete.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
# Progress for processing the transcription
|
41 |
progress(0.7, desc="Processing transcription...")
|
|
|
47 |
charts, explanations = create_charts(results)
|
48 |
progress(1.0, desc="Charts generation complete.")
|
49 |
|
|
|
|
|
|
|
50 |
end_time = time.time()
|
51 |
execution_time = end_time - start_time
|
52 |
|
|
|
91 |
|
92 |
return output_components
|
93 |
|
|
|
94 |
# Define the Gradio interface
|
95 |
with gr.Blocks() as iface:
|
96 |
gr.Markdown("# AI Personality Detection")
|
97 |
gr.Markdown("Upload a video")
|
98 |
|
99 |
video_input = gr.Video(label="Upload Video")
|
|
|
100 |
max_speakers = gr.Slider(minimum=1, maximum=4, step=1, value=2, label="Maximum Number of Speakers")
|
101 |
|
102 |
analyze_button = gr.Button("Analyze")
|
|
|
121 |
|
122 |
analyze_button.click(
|
123 |
fn=analyze_video,
|
124 |
+
inputs=[video_input, max_speakers],
|
125 |
outputs=output_components,
|
126 |
show_progress=True
|
127 |
)
|