Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -111,12 +111,19 @@ def predict_emotion(audio_file, use_ensemble=False, apply_noise_reduction=False,
|
|
111 |
label = ensemble_prediction(audio_file, apply_noise_reduction, segment_duration, overlap)
|
112 |
else:
|
113 |
temp_file = preprocess_audio(audio_file, apply_noise_reduction)
|
114 |
-
|
115 |
os.remove(temp_file)
|
116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
except Exception as e:
|
118 |
return f"Error processing file: {str(e)}"
|
119 |
|
|
|
120 |
def plot_waveform(audio_file):
|
121 |
"""
|
122 |
Generate and return a waveform plot image (as a PIL Image) for the given audio file.
|
|
|
111 |
label = ensemble_prediction(audio_file, apply_noise_reduction, segment_duration, overlap)
|
112 |
else:
|
113 |
temp_file = preprocess_audio(audio_file, apply_noise_reduction)
|
114 |
+
result = classifier.classify_file(temp_file) # Check if this returns a list
|
115 |
os.remove(temp_file)
|
116 |
+
|
117 |
+
if isinstance(result, list): # Ensure we extract the correct label
|
118 |
+
label = result[-1] # Assuming the last item is the label
|
119 |
+
else:
|
120 |
+
label = result
|
121 |
+
|
122 |
+
return add_emoji_to_label(str(label)) # Convert to string before .lower()
|
123 |
except Exception as e:
|
124 |
return f"Error processing file: {str(e)}"
|
125 |
|
126 |
+
|
127 |
def plot_waveform(audio_file):
|
128 |
"""
|
129 |
Generate and return a waveform plot image (as a PIL Image) for the given audio file.
|