Mrkomiljon commited on
Commit
e04d1d4
·
verified ·
1 Parent(s): 39f1550

Update app.py

Browse files

return line updated

Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -30,7 +30,7 @@ def predict_audio(file_path):
30
  max_length = target_sample_rate * 10
31
 
32
  try:
33
- # Faylni yuklash
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
- "Confidence": round(confidence * 100, 2)
 
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` parametridan foydalaning
79
  outputs=[
80
  gr.Label(label="Predicted Class"),
81
  gr.Label(label="Confidence")
82
  ],
83
- title="Audio Classification",
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