Hey there! ๐ Imagine watching a YouTube video and thinking, "I wish I could have the transcript in seconds." Well, this handy YouTube Video Transcriber app does just that! Letโs dive straight in and see how it works. ๐
Here is the demo of this application :
What Does This App Do? ๐ฅโ๏ธ
This app lets you:
Fetch Video Details: Get the title and description of a YouTube video.
Transcribe Videos: Extract subtitles/transcripts in seconds (if available).
Cool, right? You donโt even need to leave your browser.
How Does It Work? ๐ ๏ธ
Enter YouTube API Key ๐: To access video details, you'll need your YouTube Data API Key.
Paste YouTube URL ๐: Share the video link you want transcribed.
Hit Transcribe โจ: The app fetches the details and subtitles, displaying them instantly.
Finally, Streamlit makes the app interactive and easy to use:
Accept inputs for API key and video URL.
Show video details and transcript on the same page.
Here is the final code details :
import streamlit as st
from googleapiclient.discovery import build
from youtube_transcript_api import YouTubeTranscriptApi
def get_video_id(url):
"""Extracts video ID from a YouTube URL."""
if "watch?v=" in url:
return url.split("watch?v=")[1].split("&")[0]
elif "youtu.be/" in url:
return url.split("youtu.be/")[1].split("?")[0]
return None
def fetch_video_details(api_key, video_id):
"""Fetches video details using the YouTube Data API."""
youtube = build("youtube", "v3", developerKey=api_key)
request = youtube.videos().list(part="snippet", id=video_id)
response = request.execute()
if "items" in response and len(response["items"]) > 0:
snippet = response["items"][0]["snippet"]
title = snippet["title"]
description = snippet["description"]
return title, description
return None, None
def fetch_transcript(video_id):
"""Fetches the transcript for a YouTube video."""
try:
transcript = YouTubeTranscriptApi.get_transcript(video_id)
return "\n".join([item['text'] for item in transcript])
except Exception as e:
return f"Error fetching transcript: {str(e)}"
# Streamlit UI
st.title("YouTube Video Transcriber")
youtube_api_key = st.text_input("Enter your YouTube Data API Key:", type="password")
youtube_url = st.text_input("Enter YouTube Video URL:")
if st.button("Transcribe"):
if not youtube_api_key or not youtube_url:
st.error("Please provide both API Key and Video URL.")
else:
video_id = get_video_id(youtube_url)
if not video_id:
st.error("Invalid YouTube URL.")
else:
with st.spinner("Fetching video details..."):
title, description = fetch_video_details(youtube_api_key, video_id)
if not title:
st.error("Unable to fetch video details. Check API Key and URL.")
else:
st.success("Video details fetched successfully!")
st.write(f"**Title:** {title}")
st.write(f"**Description:** {description}")
with st.spinner("Fetching transcript..."):
transcript = fetch_transcript(video_id)
st.text_area("Transcript:", value=transcript, height=300)
st.success("Transcript fetched successfully!")
Setup in 3 Steps โก
1) Install the dependencies:
pip install-r requirements.txt
2) Run the app:
streamlit run app.py
3) Enjoy your transcripts instantly! ๐
Future Features? ๐ค
Here are some cool ideas you can add:
Download Transcript as a text file. ๐
Summarize Transcript using AI. ๐ค
Translate Transcript to other languages. ๐
Feel inspired? Head over to the GitHub Repo and contribute your ideas! ๐
This is a Streamlit application that allows you to fetch and transcribe the content of a YouTube video using the YouTube Data API and YouTube Transcript API.
Features
Extracts the video ID from a YouTube URL.
Fetches the title and description of the YouTube video using the YouTube Data API.
Retrieves and displays the transcript of the YouTube video.
User-friendly interface built with Streamlit.
Requirements
This project requires the following Python packages:
streamlit
google-api-python-client
youtube-transcript-api
To install the necessary dependencies, create a virtual environment and install the packages from the requirements.txt file: