Spaces:
Runtime error
Runtime error
from transformers import pipeline | |
import gradio as gr | |
from gradio import Interface, Audio, Label, Number | |
username = 'bvallegc' ## Complete your username | |
model_id = f"{username}/wav2vec2_spoof_dection1-finetuned-spoofing-classifier" | |
pipe = pipeline("audio-classification", model=model_id) | |
def classify_audio(filepath): | |
""" | |
Goes from | |
[{'score': 0.8339303731918335, 'label': 'country'}, | |
{'score': 0.11914275586605072, 'label': 'rock'},] | |
to | |
{"country": 0.8339303731918335, "rock":0.11914275586605072} | |
""" | |
preds = pipe(filepath) | |
classification = [{"label": p["label"], "score": p["score"]} for p in preds] | |
label = classification[0]["label"] | |
number = classification[0]["score"] | |
return label, number | |
examples=['TTS_F_LA_E_7682468.wav', 'TTS_M_LA_E_3371601.wav', 'TTS_M_LA_E_7056254.wav'] | |
examples = [[f"./{f}"] for f in examples] | |
gr.Interface( | |
fn = classify_audio, | |
inputs=[ | |
gr.inputs.Audio(source="microphone", type='filepath', optional=True), | |
gr.inputs.Audio(source="upload", type='filepath', optional=True), | |
gr.Textbox(label="Paste audio here"), | |
], | |
outputs=[ | |
gr.outputs.Textbox(label="Verification"), | |
gr.Number(label="Probability"), | |
], | |
verbose=True, | |
examples = examples, | |
title="Spoofing verification classifier", | |
description="Detect machine created audios from human-speech.", | |
theme="huggingface" | |
).launch() |