Yulu Fu commited on
Commit
4510960
1 Parent(s): 4c24f50

debugging why output show error

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -6,13 +6,23 @@ pipe = pipeline("audio-classification", model="MelodyMachine/Deepfake-audio-dete
6
 
7
  # Define the prediction function
8
  def predict(audio):
9
- return pipe(audio)
 
 
 
 
 
 
 
 
 
 
10
 
11
  # Create the Gradio interface
12
  iface = gr.Interface(
13
  fn=predict,
14
  inputs=gr.Audio(type="filepath"),
15
- outputs="label",
16
  title="Testing Deepfake Audio Detection Simple Interface",
17
  description="Upload an audio file or record your voice to detect if the audio is a deepfake."
18
  )
 
6
 
7
  # Define the prediction function
8
  def predict(audio):
9
+ print("Audio file received:", audio) # Debugging statement
10
+ try:
11
+ result = pipe(audio)
12
+ print("Raw prediction result:", result) # Debugging statement
13
+ # Convert the result to the expected format
14
+ output = {item['label']: item['score'] for item in result}
15
+ print("Formatted prediction result:", output) # Debugging statement
16
+ return output
17
+ except Exception as e:
18
+ print("Error during prediction:", e) # Debugging statement
19
+ return {"error": str(e)}
20
 
21
  # Create the Gradio interface
22
  iface = gr.Interface(
23
  fn=predict,
24
  inputs=gr.Audio(type="filepath"),
25
+ outputs=gr.Label(),
26
  title="Testing Deepfake Audio Detection Simple Interface",
27
  description="Upload an audio file or record your voice to detect if the audio is a deepfake."
28
  )