Kabatubare's picture
Update app.py
f03ec98 verified
raw
history blame
No virus
1.3 kB
# Import necessary libraries
import gradio as gr
import torchaudio
from audioseal import AudioSeal
import torch
# Function to detect watermarks in the audio and determine if it's AI-generated
def detect_watermark(file_info):
# Load the audio file from the uploaded file
audio, sr = torchaudio.load(file_info)
audio = audio.unsqueeze(0) # Add batch dimension as expected by the AudioSeal detector
# Initialize the AudioSeal detector
detector = AudioSeal.load_detector("audioseal_detector_16bits")
# Detect watermarks in the audio
result, message = detector.detect_watermark(audio, message_threshold=0.5)
# Interpret the detection result
detection_result = "AI-generated" if result else "genuine"
return f"This audio is likely {detection_result} based on watermark detection."
# Define Gradio interface
interface = gr.Interface(fn=detect_watermark,
inputs=gr.Audio(source="upload", type="file", label="Upload your audio"),
outputs="text",
title="Deep Fake Defender: AI Voice Cloning Detection",
description="Upload an audio file to check if it's AI-generated or genuine.")
# Launch the Gradio app
if __name__ == "__main__":
interface.launch()