Boltz79 commited on
Commit
eebb902
·
verified ·
1 Parent(s): 9729a4f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
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
- _, _, _, label = classifier.classify_file(temp_file)
115
  os.remove(temp_file)
116
- return add_emoji_to_label(label)
 
 
 
 
 
 
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.