SeyedAli commited on
Commit
c3ed70b
1 Parent(s): 14998e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -14,7 +14,7 @@ model = HubertForSpeechClassification.from_pretrained("SeyedAli/Persian-Speech-E
14
  sampling_rate = feature_extractor.sampling_rate
15
 
16
  audio_input = gr.Audio(label="صوت گفتار فارسی",type="filepath")
17
- #text_output = gr.TextArea(label="هیجان موجود در صوت گفتار",text_align="right",rtl=True,type="text")
18
 
19
  def SER(audio):
20
  with tempfile.NamedTemporaryFile(suffix=".wav") as temp_audio_file:
@@ -33,10 +33,8 @@ def SER(audio):
33
 
34
  scores = F.softmax(logits, dim=1).detach().cpu().numpy()[0]
35
  outputs = [{"Label": config.id2label[i], "Score": f"{round(score * 100, 3):.1f}%"} for i, score in enumerate(scores)]
36
- for p in outputs:
37
- outputs[p["label"]] = p["score"]
38
- return outputs
39
- #return outputs
40
 
41
- iface = gr.Interface(fn=SER, inputs=audio_input, outputs=gr.outputs.Label())
42
  iface.launch(share=False)
 
14
  sampling_rate = feature_extractor.sampling_rate
15
 
16
  audio_input = gr.Audio(label="صوت گفتار فارسی",type="filepath")
17
+ text_output = gr.TextArea(label="هیجان موجود در صوت گفتار",text_align="right",rtl=True,type="text")
18
 
19
  def SER(audio):
20
  with tempfile.NamedTemporaryFile(suffix=".wav") as temp_audio_file:
 
33
 
34
  scores = F.softmax(logits, dim=1).detach().cpu().numpy()[0]
35
  outputs = [{"Label": config.id2label[i], "Score": f"{round(score * 100, 3):.1f}%"} for i, score in enumerate(scores)]
36
+
37
+ return outputs
 
 
38
 
39
+ iface = gr.Interface(fn=SER, inputs=audio_input, outputs=text_output)
40
  iface.launch(share=False)