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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
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,7 +33,10 @@ 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
- return outputs
 
 
 
37
 
38
- iface = gr.Interface(fn=SER, inputs=audio_input, outputs=text_output)
39
  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
+ 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)