File size: 1,298 Bytes
f03ec98
f4f5a40
 
488d50e
f03ec98
f4f5a40
f03ec98
f4f5a40
f03ec98
f4f5a40
f03ec98
 
 
f4f5a40
 
f03ec98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f4f5a40
488d50e
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 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()