Spaces:
Runtime error
Runtime error
File size: 948 Bytes
7ec5198 5f3703f 7ec5198 edb20d9 7ec5198 edb20d9 7ec5198 edb20d9 7ec5198 edb20d9 7ec5198 edb20d9 7ec5198 edb20d9 c161c7d edb20d9 7ec5198 edb20d9 7ec5198 edb20d9 |
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 |
import os
import unicodedata
from transformers import pipeline
import gradio as gr
# Set the Hugging Face token
HF_TOKEN = "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"
os.environ["HF_TOKEN"] = HF_TOKEN
# Define the ASR function
def asr(audio):
asr = pipeline("automatic-speech-recognition", model="kingabzpro/wav2vec2-large-xls-r-300m-Urdu")
prediction = asr(audio, chunk_length_s=30)
return unicodedata.normalize("NFC", prediction[0]["text"])
# Define the Gradio interface
title = "Urdu Automatic Speech Recognition"
description = "This model performs automatic speech recognition for the Urdu language."
input_audio = gr.inputs.Audio(source="microphone", type="numpy", label="Record your voice")
output_text = gr.outputs.Textbox(label="Transcription")
gr.Interface(fn=asr, inputs=input_audio, outputs=output_text, title=title, description=description).launch()
# Ensure to replace "YOUR_HF_TOKEN" with your actual Hugging Face token.
|