Spaces:
Sleeping
Sleeping
File size: 1,141 Bytes
a355d31 b89d1a0 a355d31 b89d1a0 a355d31 b89d1a0 a355d31 780f607 a355d31 780f607 a355d31 b89d1a0 780f607 a355d31 b89d1a0 a355d31 780f607 |
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 |
import gradio as gr
from transformers import pipeline, Wav2Vec2ProcessorWithLM
import os
def transcribe(audio, model_id, model_revison):
# load processor
p = Wav2Vec2ProcessorWithLM.from_pretrained(model_id, revision=model_revison)
# load eval pipeline
asr = pipeline("automatic-speech-recognition", model=model_id, tokenizer=p.tokenizer, feature_extractor=p.feature_extractor, decoder=p.decoder, token=os.getenv('HF_TOKEN'))
text = asr(audio)["text"]
return text
asr_app = gr.Interface(
fn=transcribe,
inputs=[
gr.Audio(sources=["upload", "microphone"], type="filepath"),
gr.Dropdown(
[
"asr-africa/wav2vec2-xls-r-1b-naijavoices-hausa-500hr-v0",
"asr-africa/wav2vec2-xls-r-1b-naijavoices-igbo-500hr-v0",
"asr-africa/wav2vec2-xls-r-1b-naijavoices-yoruba-500hr-v0"
]
),
gr.Radio(["main","lm"])
],
outputs="text",
title="NaijaVoices ASR",
description="Realtime demo for Hausa, Igbo and Yoruba speech recognition using a fine-tuned Wav2Vec2-XLS-R 1B model.",
)
asr_app.launch(share=True)
|