Kabatubare commited on
Commit
ee91d94
1 Parent(s): 7a76878

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def predict_voice(audio_path):
4
+ # Load the Hugging Face model directly through gr.Interface.load
5
+ model = gr.Interface.load("models/Kabatubare/ast_celeb_spoof")
6
+
7
+ # Since we're loading the model directly inside the prediction function,
8
+ # we use it immediately to make a prediction on the provided audio file.
9
+ predictions = model(audio_path)
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", type="filepath"),
19
+ outputs=gr.Text(label="Model Predictions"),
20
+ title="Voice Authenticity Detection with AST Celeb Spoof",
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"
24
+ )
25
+
26
+ # Launch the Gradio app
27
+ iface.launch()