whisper-khowar / app.py
Aizazayyubi's picture
Update app.py
4b7fedb verified
raw
history blame contribute delete
552 Bytes
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)