Spaces:
Running
Running
File size: 1,344 Bytes
a52df70 689d594 6ee728c 689d594 a52df70 9793d07 a52df70 689d594 5903c30 689d594 f56de01 689d594 f56de01 8dba6e1 689d594 f56de01 689d594 9793d07 f56de01 538b9f3 689d594 9793d07 689d594 |
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 |
import gradio as gr
import os
from sidlingvo import wav_to_dvector
from huggingface_hub import hf_hub_download
title = "Speaker Recognition Demo"
description = """
A demo of conformer-based speaker recognition.
Paper: https://arxiv.org/abs/2104.02125
Model: https://huggingface.co/tflite-hub/conformer-speaker-encoder
"""
repo_id = "tflite-hub/conformer-speaker-encoder"
model_path = "models"
hf_hub_download(repo_id=repo_id, filename="vad_long_model.tflite", local_dir=model_path)
hf_hub_download(repo_id=repo_id, filename="vad_long_mean_stddev.csv", local_dir=model_path)
hf_hub_download(repo_id=repo_id, filename="conformer_tisid_medium.tflite", local_dir=model_path)
runner = wav_to_dvector.WavToDvectorRunner(
vad_model_file=os.path.join(model_path, "vad_long_model.tflite"),
vad_mean_stddev_file=os.path.join(model_path, "vad_long_mean_stddev.csv"),
tisid_model_file=os.path.join(model_path, "conformer_tisid_medium.tflite"))
def predict(enroll_audio, test_audio):
score = runner.compute_score([enroll_audio], test_audio)
return "Speaker similarity score: " + str(score)
if __name__ == "__main__":
demo = gr.Interface(
fn=predict,
inputs=[gr.Audio(type="filepath"), gr.Audio(type="filepath")],
outputs="text",
title=title,
description=description,)
demo.launch() |