Spaces:
Sleeping
Sleeping
Update app.py
Browse filesreturn line updated
app.py
CHANGED
@@ -30,7 +30,7 @@ def predict_audio(file_path):
|
|
30 |
max_length = target_sample_rate * 10
|
31 |
|
32 |
try:
|
33 |
-
#
|
34 |
waveform, sample_rate = torchaudio.load(file_path)
|
35 |
|
36 |
# Resample agar sample_rate mos kelmasa
|
@@ -67,7 +67,8 @@ def predict_audio(file_path):
|
|
67 |
|
68 |
return {
|
69 |
"Class": class_name,
|
70 |
-
"
|
|
|
71 |
}
|
72 |
except Exception as e:
|
73 |
return {"error": str(e)}
|
@@ -75,12 +76,12 @@ def predict_audio(file_path):
|
|
75 |
# Gradio interfeysi
|
76 |
iface = gr.Interface(
|
77 |
fn=predict_audio,
|
78 |
-
inputs=gr.Audio(type="filepath"), # `filepath`
|
79 |
outputs=[
|
80 |
gr.Label(label="Predicted Class"),
|
81 |
gr.Label(label="Confidence")
|
82 |
],
|
83 |
-
title="
|
84 |
description="Upload an audio file to classify it into one of the predefined categories."
|
85 |
)
|
86 |
|
|
|
30 |
max_length = target_sample_rate * 10
|
31 |
|
32 |
try:
|
33 |
+
# upload audio file
|
34 |
waveform, sample_rate = torchaudio.load(file_path)
|
35 |
|
36 |
# Resample agar sample_rate mos kelmasa
|
|
|
67 |
|
68 |
return {
|
69 |
"Class": class_name,
|
70 |
+
"label": int(predicted_label),
|
71 |
+
"Confidence": float(confidence)
|
72 |
}
|
73 |
except Exception as e:
|
74 |
return {"error": str(e)}
|
|
|
76 |
# Gradio interfeysi
|
77 |
iface = gr.Interface(
|
78 |
fn=predict_audio,
|
79 |
+
inputs=gr.Audio(type="filepath"), # `filepath` parameter use
|
80 |
outputs=[
|
81 |
gr.Label(label="Predicted Class"),
|
82 |
gr.Label(label="Confidence")
|
83 |
],
|
84 |
+
title="Human or AI-generated voice classification",
|
85 |
description="Upload an audio file to classify it into one of the predefined categories."
|
86 |
)
|
87 |
|