--- title: Youtube Transcript Tool emoji: 💬 colorFrom: red colorTo: red sdk: gradio sdk_version: 5.13.1 app_file: app.py pinned: false license: apache-2.0 short_description: Transcribe Youtube Video --- # YouTube Transcript SmolAgent Tool ## Overview This is a tool to fetch transcripts for YouTube videos. It attempts to retrieve the official YouTube transcript first, and if that fails or if the user opts to skip it, it falls back to using Whisper ASR to transcribe the audio. ## Project Structure - `app.py`: Main application file that sets up the Gradio interface and handles the transcript fetching logic. - `transcription.py`: Contains functions for downloading audio, converting it to WAV format, and transcribing it using Whisper ASR. - `youtube_utils.py`: Contains utility functions for extracting video IDs and fetching official YouTube transcripts. - `logging_config.py`: Configures logging for the application. - `ffmpeg_setup.py`: Ensures that `ffmpeg` is available in the system path. ## Dependencies - Python - pip - Gradio - yt-dlp - torch - transformers - youtube_transcript_api - ffmpeg ## How It Works 1. **User Input**: The user provides a YouTube URL and optionally chooses to skip the official transcript check. 2. **Transcript Fetching**: - If the user opts to skip the official transcript, the tool directly uses Whisper ASR to transcribe the audio. - Otherwise, it first attempts to fetch the official YouTube transcript. - If the official transcript is not found, it falls back to using Whisper ASR. 3. **Whisper ASR**: - Downloads the best audio track using `yt-dlp`. - Converts the audio to WAV format using `ffmpeg`. - Transcribes the audio using the Whisper ASR model from the `transformers` library. 4. **Output**: The transcript and logs are displayed in the Gradio interface. ## Running the Application 1. Ensure you have all dependencies installed: ```sh pip install gradio yt-dlp torch transformers youtube_transcript_api ``` or ```sh pip install -r requirements.txt ``` 3. Run the application: ```sh python app.py ``` 4. Open the provided URL in your browser to access the Gradio interface.