Kabatubare's picture
Update app.py
0c35856 verified
raw
history blame
990 Bytes
import gradio as gr
from transformers import pipeline
# Initialize the pipeline for audio classification
# Ensure you have the transformers library installed
model_pipeline = pipeline("audio-classification", model="Kabatubare/ast_celeb_spoof")
def predict_voice(audio_file):
predictions = model_pipeline(audio_file.name)
# Format the predictions for display
formatted_predictions = [f"Label: {prediction['label']}, Confidence: {prediction['score']:.4f}" for prediction in predictions]
return "\n".join(formatted_predictions)
# Define the Gradio interface
iface = gr.Interface(
fn=predict_voice,
inputs=gr.Audio(source="upload", type="file", label="Upload Audio File"),
outputs=gr.Text(label="Predictions"),
title="Voice Authenticity Detection",
description="This model detects whether a voice is real or AI-generated. Upload an audio file to get started.",
allow_flagging="never",
theme="huggingface"
)
# Launch the Gradio app
iface.launch()