denis-kazakov commited on
Commit
a9135f5
1 Parent(s): b380b8a

from transformers import pipeline import gradio as gr import torch device = 'cuda' if torch.cuda.is_available else 'cpu' model = pipeline( "automatic-speech-recognition", device=device, model='openai/whisper-large-v3', chunk_length_s=30, generate_kwargs={"task": "transcribe"} ) def transcribe_audio(mic=None, file=None, return_timestamps=False): if mic is not None: audio = mic elif file is not None: audio = file else: return "You must either provide a mic recording or a file" gr.Info(f"Device: {device}") with torch.no_grad(): result = model(audio, return_timestamps=return_timestamps, batch_size=8) if return_timestamps: return result['chunks'] else: return result['text'] gr.Interface( fn=transcribe_audio, inputs=[ gr.Audio(sources=["microphone"], type="filepath"), gr.Audio(sources=["upload"], type="filepath"), gr.Checkbox(label="Add timestamps?") ], outputs="text", ).launch()

Browse files
Files changed (1) hide show
  1. app.py +0 -0
app.py ADDED
File without changes