|
import gradio as gr |
|
import yt_dlp as youtube_dl |
|
import tempfile |
|
import os |
|
|
|
|
|
YT_LENGTH_LIMIT_S = 3600 |
|
FILE_LIMIT_MB = 1000 |
|
MODEL_NAME = "Wisper" |
|
|
|
|
|
def _return_yt_html_embed(yt_url): |
|
video_id = yt_url.split("?v=")[-1] |
|
HTML_str = ( |
|
f'<center> <iframe width="500" height="320" src="https://www.youtube.com/embed/{video_id}"> </iframe>' |
|
" </center>" |
|
) |
|
return HTML_str |
|
|
|
def yt_transcribe(yt_url, max_filesize=75.0): |
|
html_embed_str = _return_yt_html_embed(yt_url) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return html_embed_str |
|
|
|
demo = gr.Blocks() |
|
|
|
url = gr.Textbox(lines=1, placeholder="Paste the URL to a YouTube video here", label="YouTube URL"), |
|
|
|
yt_transcribe = gr.Interface( |
|
fn=yt_transcribe, |
|
inputs=[ |
|
|
|
url |
|
|
|
], |
|
|
|
outputs=["html"], |
|
layout="horizontal", |
|
theme="huggingface", |
|
title="YouTube Video Viwer", |
|
description=( |
|
"Transcribe long-form YouTube videos with the click of a button! Demo uses the checkpoint" |
|
f" [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) and π€ Transformers to transcribe video files of" |
|
" arbitrary length." |
|
), |
|
allow_flagging="never", |
|
).launch(enable_queue=True) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|