INNER CODE UNIT · Python
transcribe_youtube
sanchit-gandhi/whisper-jax · app/app.py:190
def transcribe_youtube(yt_url, task, return_timestamps, progress=gr.Progress()):
progress(0, desc="Loading audio file...")
logger.info("loading youtube file...")
html_embed_str = _return_yt_html_embed(yt_url)
with tempfile.TemporaryDirectory() as tmpdirname:
filepath = os.path.join(tmpdirname, "video.mp4")
download_yt_audio(yt_url, filepath)
with open(filepath, "rb") as f:
inputs = f.read()
inputs = ffmpeg_read(inputs, pipeline.feature_extractor.sampling_rate)
inputs = {"array": inputs, "sampling_rate": pipeline.feature_extractor.sampling_rate}
logger.info("done loading...")
text, runtime = tqdm_generate(inputs, task=task, return_timestamps=return_timestamps, progress=progress)
return html_embed_str, text, runtime
microphone_chunked = gr.Interface(