Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
37 |
|
38 |
-
iface = gr.Interface(fn=SER, inputs=audio_input, outputs=
|
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)
|