Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from youtube_transcript_api import YouTubeTranscriptApi | |
| def get_transcript(video_id): | |
| try: | |
| # Retrieve the transcript | |
| transcript = YouTubeTranscriptApi.get_transcript(video_id) | |
| # Extract and return the text | |
| text = '\n'.join([entry['text'] for entry in transcript]) | |
| return text | |
| except Exception as e: | |
| return f"Error: {e}" | |
| # Create a Gradio interface | |
| iface = gr.Interface( | |
| fn=get_transcript, | |
| inputs="text", | |
| outputs="text", | |
| layout="vertical", | |
| title="YouTube Video Transcript", | |
| description="Enter a YouTube video ID to get its transcript.", | |
| theme="default", | |
| ) | |
| # Launch the Gradio interface | |
| iface.launch() | |