import gradio as gr from transformers import pipeline # Load the ASR model model = pipeline("automatic-speech-recognition", model="tarteel-ai/whisper-base-ar-quran") def transcribe(audio): # Get the output from the model output = model(audio) # Extract only the text return output['text'] # Define Gradio Interface iface = gr.Interface( fn=transcribe, inputs=gr.Audio(sources=["microphone", "upload"], type="filepath"), # Allow both microphone and file upload outputs=gr.Textbox(), title="Arabic Quran ASR", description="Record your audio or upload a file to transcribe Quranic verses to text.", ) # Launch the Gradio app iface.launch()