Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,22 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
predictions
|
10 |
-
|
11 |
-
# Format predictions for display
|
12 |
formatted_predictions = [f"Label: {prediction['label']}, Confidence: {prediction['score']:.4f}" for prediction in predictions]
|
13 |
-
return formatted_predictions
|
14 |
|
15 |
# Define the Gradio interface
|
16 |
iface = gr.Interface(
|
17 |
fn=predict_voice,
|
18 |
-
inputs=gr.Audio(label="Upload Audio File"
|
19 |
-
outputs=gr.Text(label="
|
20 |
-
title="Voice Authenticity Detection
|
21 |
description="This model detects whether a voice is real or AI-generated. Upload an audio file to get started.",
|
22 |
allow_flagging="never",
|
23 |
theme="huggingface"
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# Initialize the pipeline for audio classification
|
5 |
+
# Ensure you have the transformers library installed
|
6 |
+
model_pipeline = pipeline("audio-classification", model="Kabatubare/ast_celeb_spoof")
|
7 |
+
|
8 |
+
def predict_voice(audio_file):
|
9 |
+
predictions = model_pipeline(audio_file.name)
|
10 |
+
# Format the predictions for display
|
|
|
|
|
11 |
formatted_predictions = [f"Label: {prediction['label']}, Confidence: {prediction['score']:.4f}" for prediction in predictions]
|
12 |
+
return "\n".join(formatted_predictions)
|
13 |
|
14 |
# Define the Gradio interface
|
15 |
iface = gr.Interface(
|
16 |
fn=predict_voice,
|
17 |
+
inputs=gr.Audio(source="upload", type="file", label="Upload Audio File"),
|
18 |
+
outputs=gr.Text(label="Predictions"),
|
19 |
+
title="Voice Authenticity Detection",
|
20 |
description="This model detects whether a voice is real or AI-generated. Upload an audio file to get started.",
|
21 |
allow_flagging="never",
|
22 |
theme="huggingface"
|