Lädt...


🔧 Build Your YouTube Video Transcriber with Streamlit & Youtube API's 🚀


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

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:

  1. Fetch Video Details: Get the title and description of a YouTube video.
  2. Transcribe Videos: Extract subtitles/transcripts in seconds (if available).

Cool, right? You don’t even need to leave your browser.

How Does It Work? 🛠️

  1. Enter YouTube API Key 🔑: To access video details, you'll need your YouTube Data API Key.
  2. Paste YouTube URL 🔗: Share the video link you want transcribed.
  3. Hit Transcribe ✨: The app fetches the details and subtitles, displaying them instantly.

Keys Setup 🔑

Step 1: Set Up a Google Cloud Project

1) Go to the Google Cloud Console.
Go to the [Google Cloud Console]

2) Sign in with your Google account.
3) Click Select a Project in the top menu, then click New Project.
Select a Project

4) Enter a project name (e.g., "Video Transcriber") and click Create.

Video Transcriber

Transcriber

Step 2: Enable the YouTube Data API

1) In the Cloud Console, go to the API Library.

[API Library]

2) Search for YouTube Data API v3.
3) Click on the YouTube Data API v3 result, then click Enable.

Enable

Step 3: Create API Credentials

1) Go to the Credentials page.
2) Click + CREATE CREDENTIALS and select API Key.
CREDENTIALS

3) Your API key will be generated. Copy it and save it somewhere safe.

Code Breakdown 💻

Here’s the magic:

Extracting the Video ID 📽️

The get_video_id() function grabs the video ID from URLs like https://www.youtube.com/watch?v=VIDEO_ID.

def get_video_id(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

Fetching Video Details 📝

Using the YouTube Data API, fetch_video_details() pulls video title and description.

youtube = build("youtube", "v3", developerKey=api_key)
request = youtube.videos().list(part="snippet", id=video_id)
response = request.execute()

Fetching the Transcript 🗣️

The YouTubeTranscriptApi library retrieves the transcript for the video (if enabled).

transcript = YouTubeTranscriptApi.get_transcript(video_id)
return "\n".join([item['text'] for item in transcript])

Streamlit Magic 🪄

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! 🚀

GitHub logo Jagroop2001 / video-transcriber

Video Transcriber with Streamlit & Youtube API

YouTube Video Transcriber

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:

pip install -r requirements.txt

Setting Up

  1. Obtain a YouTube Data API key by following the instructions on the Google Developers Console.
  2. Clone or download this repository to your local machine.
  3. Install the required dependencies using the command above.
  4. Run the Streamlit app:
streamlit run app.py

Usage

  1. Open the application in your web browser (usually…




Let’s build something awesome together! 🙌

...

🔧 Build Your YouTube Video Transcriber with Streamlit & Youtube API's 🚀


📈 70.29 Punkte
🔧 Programmierung

📰 Streamlit from Scratch: Build a Data Dashboard with Streamlit's Layout and UI features


📈 35.51 Punkte
🔧 AI Nachrichten

📰 The Streamlit Colour Picker: An Easy Way to Change Chart Colours on Your Streamlit Dashboard


📈 33.59 Punkte
🔧 AI Nachrichten

📰 How to Use Streamlit’s st.write Function to Improve Your Streamlit Dashboard


📈 33.59 Punkte
🔧 AI Nachrichten

🔧 Build An Audio Transcriber and Analyzer using ToolJet and OpenAI


📈 33.18 Punkte
🔧 Programmierung

🔧 Real-Time Transcriber & Translator to 100+ languages


📈 30.54 Punkte
🔧 Programmierung

🔧 Scalable Load Balancing Having Cloud GPU Service Salad Tutorial With Whisper Transcriber Gradio APP


📈 28.58 Punkte
🔧 Programmierung

🔧 Whisper-Groq-Transcriber: Speech-to-Text with Enhanced Features


📈 28.58 Punkte
🔧 Programmierung

🔧 Journal Transcriber: Write journal by dictating it


📈 28.58 Punkte
🔧 Programmierung

🔧 Journal Transcriber: Write journal by dictating it


📈 28.58 Punkte
🔧 Programmierung

📰 Build your own RAG and run it locally on your laptop: ColBERT + DSPy + Streamlit


📈 25.43 Punkte
🔧 AI Nachrichten

🔧 How to Build and Deploy an API-Driven Streamlit/Python Microservice on AWS


📈 24.95 Punkte
🔧 Programmierung

📰 Build Your Own ChatGPT-Like App with Streamlit


📈 22.74 Punkte
🔧 AI Nachrichten

🔧 Build A Covid-19 EDA & Viz App Using Streamlit


📈 22.02 Punkte
🔧 Programmierung

🔧 Build a containerized AI Agent with watsonx.ai & CrewAI (and Streamlit) and Podman


📈 22.02 Punkte
🔧 Programmierung

🔧 Creating a movie finder app with Streamlit and OMDb API


📈 20.34 Punkte
🔧 Programmierung

📰 Create a Specialist Chatbot with a Modern Toolset: Streamlit, GPT-4 and the Assistants API


📈 20.34 Punkte
🔧 AI Nachrichten

📰 Creating an Assistant with OpenAI Assistant API and Streamlit


📈 20.34 Punkte
🔧 AI Nachrichten

🔧 Create an end-to-end personalised AI chatbot🤖 using Llama-3.1🦙 and Streamlit powered by Groq API


📈 20.34 Punkte
🔧 Programmierung

🔧 Building a ChatGPT Lookalike with Streamlit and Anthropic API


📈 20.34 Punkte
🔧 Programmierung

📰 Build Streamlit apps in Amazon SageMaker Studio


📈 20.06 Punkte
🔧 AI Nachrichten

🔧 Build a Streamlit app with LangChain and Amazon Bedrock


📈 20.06 Punkte
🔧 Programmierung

🔧 Build a Streamlit App With LangChain and Amazon Bedrock


📈 20.06 Punkte
🔧 Programmierung

🔧 Build Chat PDF app in Python with LangChain, OpenAI, Streamlit | Full project | Learn Coding


📈 20.06 Punkte
🔧 Programmierung

🔧 Build Eminem Bot App with LangChain, Streamlit, OpenAI | Full Python Project | Tutorial | AI ChatBot


📈 20.06 Punkte
🔧 Programmierung

🔧 Build A Dual-Purpose App: Text-to-Image and Custom Chatbot Using Comet, GPT-3.5, DALL-E 2, and Streamlit


📈 20.06 Punkte
🔧 Programmierung

📰 What You Need To Know To Build Large Streamlit Applications With Stripe Subscriptions And Firestore…


📈 20.06 Punkte
🔧 AI Nachrichten

🔧 Just build it: How we design Streamlit to bias you toward forward progress


📈 20.06 Punkte
🔧 Programmierung

🔧 Build a Route Generator App with Cloudflare Workers AI, LangChain, Streamlit, and Mapbox


📈 20.06 Punkte
🔧 Programmierung

🔧 Streamlit Part 7: Build a Chat Interface


📈 20.06 Punkte
🔧 Programmierung

🔧 🖼️ Build an Image Converter WebApp Using Python and Streamlit


📈 20.06 Punkte
🔧 Programmierung

🔧 Use FLUX, PyTorch, and Streamlit to Build an AI Image Generation App


📈 20.06 Punkte
🔧 Programmierung

matomo