Porjaz commited on
Commit
ac354b9
1 Parent(s): 7d30f3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -158,14 +158,16 @@ class CustomEncoderWav2vec2Classifier(Pretrained):
158
 
159
 
160
  def return_prediction(mic, file):
161
- # classifier = foreign_class(source="Porjaz/wavlm-base-emo-fi", pymodule_file="custom_interface.py", classname="CustomEncoderWav2vec2Classifier")
162
  if mic is not None:
163
  out_prob, score, index, text_lab = classifier.classify_file(mic)
164
  elif file is not None:
165
  out_prob, score, index, text_lab = classifier.classify_file(file)
166
  else:
167
  return "You must either provide a mic recording or a file"
168
- return text_lab
 
 
 
169
 
170
 
171
  classifier = foreign_class(source="Porjaz/wavlm-base-emo-fi", pymodule_file="custom_interface.py", classname="CustomEncoderWav2vec2Classifier")
@@ -180,4 +182,6 @@ gradio_app = gr.Interface(
180
  title="Finnish-Emotion-Recognition",
181
  )
182
 
183
- gradio_app.launch(share=True, ssl_verify=False)
 
 
 
158
 
159
 
160
  def return_prediction(mic, file):
 
161
  if mic is not None:
162
  out_prob, score, index, text_lab = classifier.classify_file(mic)
163
  elif file is not None:
164
  out_prob, score, index, text_lab = classifier.classify_file(file)
165
  else:
166
  return "You must either provide a mic recording or a file"
167
+
168
+ score = score.item()
169
+ score = str(round(100 * score, 2)) + "%"
170
+ return text_lab, score
171
 
172
 
173
  classifier = foreign_class(source="Porjaz/wavlm-base-emo-fi", pymodule_file="custom_interface.py", classname="CustomEncoderWav2vec2Classifier")
 
182
  title="Finnish-Emotion-Recognition",
183
  )
184
 
185
+
186
+ if __name__ == "__main__":
187
+ gradio_app.launch(share=True, ssl_verify=False)