File size: 778 Bytes
532b398
 
 
484083d
 
 
 
 
 
 
532b398
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os

def fetch_transcript(url, name):
    transcript_filename = f"{name}.txt"
    os.system(f"youtube-dl --write-auto-sub --skip-download --sub-format txt {url} -o {transcript_filename}")
    
    if os.path.exists(transcript_filename):
        return transcript_filename
    else:
        raise FileNotFoundError(f"Transcript file '{transcript_filename}' could not be found.")

import gradio as gr

gr.Interface(
    fetch_transcript,
    [gr.Textbox(label="YouTube Video URL", placeholder="URL goes here..."),
     gr.Textbox(label="Transcript file name", placeholder="transcript")],
    gr.outputs.File(label="Download Transcript"),
    description="Fetch and download the transcript of a YouTube video as a human readable text file.",
    enable_queue=True
).launch()