Spaces:
Sleeping
Sleeping
File size: 990 Bytes
c60cce9 8b76de6 c60cce9 8b76de6 c60cce9 8b76de6 c60cce9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import gradio as gr
from transformers import pipeline
# Load Hugging Face model
pipe = pipeline("audio-classification", model="mo-thecreator/Deepfake-audio-detection")
# Risk mapping
def detect_deepfake(audio_file):
results = pipe(audio_file)
fake_score = [r['score'] for r in results if r['label'].lower() == "fake"][0]
if fake_score < 0.3:
risk = "The audio has a low probability of being a deepfake"
elif fake_score < 0.7:
risk = "The audio is suspicious"
else:
risk = "The audio is likely a deepfake"
return {
"Assessment": risk,
"Fake probability": round(fake_score, 4),
"Raw model output": results
}
# Gradio UI
demo = gr.Interface(
fn=detect_deepfake,
inputs=gr.Audio(type="filepath", label="Upload or Record Audio"),
outputs="json",
title="Deepfake Audio Detector",
description="Upload or record audio to check if it's real or fake."
)
if __name__ == "__main__":
demo.launch() |