pavan2606 commited on
Commit
bda8dcc
·
verified ·
1 Parent(s): 1e8fa3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -13,15 +13,28 @@ def save_uploaded_file(uploaded_file):
13
  f.write(uploaded_file.getbuffer())
14
  return file_path
15
 
 
 
 
16
  def emotion(file_path):
17
  if file_path:
18
  # Classify the file
19
  out_prob, score, index, text_lab = classifier.classify_file(file_path)
20
- # Display the output
21
- st.write(text_lab)
 
 
 
 
 
 
 
 
 
22
  else:
23
  st.write("Please provide the path to an audio file.")
24
 
 
25
  def main():
26
  st.title("Emotion Recognition")
27
  file_path = st.text_input("Enter the path of the audio file (e.g., /path/to/audio.wav):")
 
13
  f.write(uploaded_file.getbuffer())
14
  return file_path
15
 
16
+
17
+
18
+
19
  def emotion(file_path):
20
  if file_path:
21
  # Classify the file
22
  out_prob, score, index, text_lab = classifier.classify_file(file_path)
23
+ # Map the original labels to the desired categories
24
+ emotion_mapping = {
25
+ 'neu': 'Neutral',
26
+ 'ang': 'Angry',
27
+ 'hap': 'Happy',
28
+ 'sad': 'Sadness'
29
+ }
30
+ # Get the corresponding category from the mapping
31
+ emotion_category = emotion_mapping.get(text_lab, 'Unknown')
32
+ # Return the emotion category
33
+ st.write(emotion_category)
34
  else:
35
  st.write("Please provide the path to an audio file.")
36
 
37
+
38
  def main():
39
  st.title("Emotion Recognition")
40
  file_path = st.text_input("Enter the path of the audio file (e.g., /path/to/audio.wav):")