Spaces:
Running
Running
import torch | |
from transformers import pipeline | |
import gradio as gr | |
device = 0 if torch.cuda.is_available() else -1 | |
pipe = pipeline( | |
model='Aizazayyubi/khowar-whisper-asr', | |
tokenizer='Aizazayyubi/khowar-whisper-asr', | |
task='automatic-speech-recognition', | |
device=device | |
) | |
def transcribe(audio): | |
result = pipe(audio) | |
return result.get('text', 'Transcription failed.') | |
iface = gr.Interface( | |
fn=transcribe, | |
inputs=gr.Audio(sources=['microphone', 'upload'], type='filepath'), | |
outputs='text' | |
) | |
iface.launch(share=True) | |