File size: 1,067 Bytes
c6f2536
5b9992a
adb03d1
c6f2536
adb03d1
 
 
 
 
 
 
28868d4
adb03d1
 
c6f2536
adb03d1
 
 
 
 
c6f2536
adb03d1
5b9992a
adb03d1
5b9992a
adb03d1
 
5b9992a
adb03d1
5b9992a
c6f2536
adb03d1
5b9992a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import gradio as gr
from youtube_transcript_api import YouTubeTranscriptApi
from youtube_transcript_api.proxies import WebshareProxyConfig

# Initialize the YouTubeTranscriptApi with proxy configuration
ytt_api = YouTubeTranscriptApi(
    proxy_config=WebshareProxyConfig(
        proxy_username="tlaukrdr",  # Replace with your proxy username
        proxy_password="mc1aumn9xbhb"  # Replace with your proxy password
    )
)

# Function to fetch YouTube transcript using the video ID
def fetch_transcript(video_id: str):
    try:
        # Fetch transcript
        transcript = ytt_api.fetch(video_id)
        # Format the transcript into a readable text
        transcript_text = "\n".join([entry['text'] for entry in transcript])
        return transcript_text
    except Exception as e:
        return f"Error fetching transcript: {str(e)}"

# Gradio Interface
iface = gr.Interface(
    fn=fetch_transcript,
    inputs=gr.Textbox(label="Enter YouTube Video ID"),
    outputs=gr.Textbox(label="Transcript"),
    live=True
)

# Launch the Gradio app
iface.launch()