minhaj-ripon commited on
Commit
81cbd29
·
1 Parent(s): 06fd7fc

app.py updated

Browse files
Files changed (1) hide show
  1. app.py +1 -20
app.py CHANGED
@@ -14,10 +14,6 @@ model = load_model(os.path.join("lstm_all_four_complex.h5"))
14
 
15
 
16
  def convert_class_to_emotion(pred):
17
- """
18
- Method to convert the predictions (int) into human readable strings.
19
- """
20
-
21
  label_conversion = {0: 'neutral',
22
  1: 'calm',
23
  2: 'happy',
@@ -27,22 +23,10 @@ def convert_class_to_emotion(pred):
27
  6: 'disgust',
28
  7: 'surprised'}
29
 
30
- # label_conversion = {0: 'very happy',
31
- # 1: 'happy',
32
- # 2: 'very happy',
33
- # 3: 'very unhappy',
34
- # 4: 'very unhappy',
35
- # 5: 'unhappy',
36
- # 6: 'unhappy',
37
- # 7: 'happy'}
38
-
39
  return label_conversion[int(pred)]
40
 
41
 
42
  def make_predictions(file, micro=None):
43
- """
44
- Method to process the files and create your features.
45
- """
46
  if file is not None and micro is None:
47
  input_audio = file
48
  elif file is None and micro is not None:
@@ -87,12 +71,9 @@ def make_predictions(file, micro=None):
87
 
88
 
89
 
90
- # Set the starting state to an empty string
91
  iface = gr.Interface(
92
  fn=make_predictions,
93
- title="Identify emotion of a chunk of audio speech",
94
- description="a simple interface to perform emotion recognition from an audio file",
95
- #article="Author: <a href=\"https://huggingface.co/poisso\">Poisso</a>.",
96
  inputs=[gr.Audio(source="upload", type="filepath", label="File"),
97
  gr.Audio(source="microphone", type="filepath", streaming=False, label="Microphone")]
98
  ,
 
14
 
15
 
16
  def convert_class_to_emotion(pred):
 
 
 
 
17
  label_conversion = {0: 'neutral',
18
  1: 'calm',
19
  2: 'happy',
 
23
  6: 'disgust',
24
  7: 'surprised'}
25
 
 
 
 
 
 
 
 
 
 
26
  return label_conversion[int(pred)]
27
 
28
 
29
  def make_predictions(file, micro=None):
 
 
 
30
  if file is not None and micro is None:
31
  input_audio = file
32
  elif file is None and micro is not None:
 
71
 
72
 
73
 
 
74
  iface = gr.Interface(
75
  fn=make_predictions,
76
+ title="Identify emotion of a chunk of audio speech",
 
 
77
  inputs=[gr.Audio(source="upload", type="filepath", label="File"),
78
  gr.Audio(source="microphone", type="filepath", streaming=False, label="Microphone")]
79
  ,