|
from transformers import pipeline |
|
import gradio as gr |
|
import time |
|
import unicodedata |
|
p = pipeline("automatic-speech-recognition",model="Yehor/wav2vec2-xls-r-base-uk-with-small-lm") |
|
|
|
def transcribe(audio, state=""): |
|
time.sleep(2) |
|
text = p(audio)["text"] |
|
state += unicodedata.normalize("NFC",text) + " " |
|
return state, state |
|
|
|
|
|
|
|
title = "Real-Time Urdu ASR" |
|
|
|
description = """ |
|
<p> |
|
<center> |
|
This model is a fine-tuned version of facebook/wav2vec2-xls-r-300m on the common_voice dataset. |
|
</center> |
|
</p> |
|
<center> |
|
<img src="https://huggingface.co/spaces/kingabzpro/real-time-Urdu-ASR/resolve/main/Images/cover.jpg" alt="logo" width="550"/> |
|
</center> |
|
""" |
|
|
|
article = "<p style='text-align: center'><a href='https://dagshub.com/kingabzpro/Urdu-ASR-SOTA' target='_blank'>Source Code on DagsHub</a></p><p style='text-align: center'><a href='https://huggingface.co/blog/fine-tune-xlsr-wav2vec2' target='_blank'>Fine-tuning XLS-R for Multi-Lingual ASR with π€ Transformers</a></p></center><center><img src='https://visitor-badge.glitch.me/badge?page_id=kingabzpro/real-time-Urdu-ASR' alt='visitor badge'></center></p>" |
|
|
|
|
|
gr.Interface( |
|
fn=transcribe, |
|
inputs=[ |
|
gr.Audio(source="microphone", type="filepath", streaming=True), |
|
"state" |
|
], |
|
outputs=[ |
|
"textbox", |
|
"state" |
|
], |
|
title=title, |
|
description=description, |
|
article=article, |
|
theme='EveryPizza/Cartoony-Gradio-Theme', |
|
live=True).launch() |