Spaces:
Sleeping
Sleeping
File size: 1,034 Bytes
db8820b 530d48b db8820b 4495bf5 db8820b 699571b 530d48b db8820b 99023df db8820b |
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 36 37 38 39 40 41 |
import gradio as gr
import wespeaker
model = wespeaker.load_model("vblinkp")
def speaker_verification(audio_path1, audio_path2, threshold):
if audio_path1 is None or audio_path2 is None:
gr.warning("Please enter two audios")
return ""
cos_score = model.compute_similarity(audio_path1, audio_path2)
return f"語者相似機率: {cos_score * 100:.2f}%\n是否為相同語者: {'是' if cos_score > threshold else '否'}"
inputs = [
gr.Audio(sources=["upload", "microphone"], type="filepath", label="Speaker#1"),
gr.Audio(sources=["upload", "microphone"], type="filepath", label="Speaker#2"),
gr.Slider(
minimum=0,
maximum=1,
step=0.01,
label="Similarity Threshold",
value=0.5,
interactive=True,
),
]
output = gr.Textbox(label="")
interface = gr.Interface(
fn=speaker_verification,
inputs=inputs,
outputs=output,
title="Speaker Verification",
flagging_mode="never",
)
interface.queue(max_size=20)
interface.launch()
|