Update video_processing.py
Browse files- video_processing.py +22 -5
video_processing.py
CHANGED
@@ -166,12 +166,29 @@ def process_video(video_path, anomaly_threshold, desired_fps, progress=None):
|
|
166 |
audio_path = os.path.join(temp_dir, "audio.wav")
|
167 |
video.export(audio_path, format="wav")
|
168 |
|
169 |
-
|
170 |
-
|
|
|
171 |
|
172 |
-
|
173 |
-
|
174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
|
177 |
progress(0.95, "Generating plots")
|
|
|
166 |
audio_path = os.path.join(temp_dir, "audio.wav")
|
167 |
video.export(audio_path, format="wav")
|
168 |
|
169 |
+
try:
|
170 |
+
# Process audio
|
171 |
+
most_frequent_voice, voice_features, voice_clusters = process_audio(audio_path)
|
172 |
|
173 |
+
# Perform anomaly detection on voice
|
174 |
+
X_voice = np.array(most_frequent_voice)
|
175 |
+
mse_voice = anomaly_detection(X_voice, X_voice) # Using the same function as for facial features
|
176 |
+
|
177 |
+
# Generate plots for voice
|
178 |
+
mse_plot_voice, anomaly_segments_voice = plot_mse(df, mse_voice, "Voice",
|
179 |
+
color='green',
|
180 |
+
anomaly_threshold=anomaly_threshold)
|
181 |
+
mse_histogram_voice = plot_mse_histogram(mse_voice, "MSE Distribution: Voice",
|
182 |
+
anomaly_threshold, color='green')
|
183 |
+
mse_heatmap_voice = plot_mse_heatmap(mse_voice, "Voice MSE Heatmap", df)
|
184 |
+
except Exception as e:
|
185 |
+
print(f"Error in voice processing: {str(e)}")
|
186 |
+
mse_voice = None
|
187 |
+
mse_plot_voice = None
|
188 |
+
mse_histogram_voice = None
|
189 |
+
mse_heatmap_voice = None
|
190 |
+
anomaly_segments_voice = None
|
191 |
+
|
192 |
|
193 |
|
194 |
progress(0.95, "Generating plots")
|