agentforeverything commited on
Commit
38d6c01
·
verified ·
1 Parent(s): d35e7ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -15
app.py CHANGED
@@ -1,22 +1,19 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load the deepfake audio detection model
5
  model = pipeline("audio-classification", model="motheecreator/Deepfake-audio-detection")
6
 
7
- def predict(audio):
8
- result = model(audio)
9
- # Assuming the model returns a list of dictionaries with 'label' and 'score'
10
- label = result[0]['label']
11
- score = result[0]['score']
12
- return f"Prediction: {label} (Confidence: {score:.2f})"
13
 
14
- interface = gr.Interface(
15
- fn=predict,
16
- inputs=gr.Audio(type="filepath"),
17
  outputs="text",
18
- title="Deepfake Audio Detector",
19
- description="Upload an audio file to check if it's AI-generated or human."
20
- )
21
-
22
- interface.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load audio classification pipeline with an open model
5
  model = pipeline("audio-classification", model="motheecreator/Deepfake-audio-detection")
6
 
7
+ def detect_deepfake(audio):
8
+ result = model(audio)[0]
9
+ label = result['label']
10
+ score = result['score']
11
+ return f"{label} ({round(score * 100, 2)}%)"
 
12
 
13
+ gr.Interface(
14
+ fn=detect_deepfake,
15
+ inputs=gr.Audio(type="filepath", label="Upload a voice clip"),
16
  outputs="text",
17
+ title="AI Voice Detector",
18
+ description="This tool uses a trained AI model to detect whether a voice clip is real or AI-generated."
19
+ ).launch()