javedali99 / audio-to-text-transcription

This repository contains a Python script that allows users to download the audio from a YouTube video, transcribe it into text, detect the language and save the transcription in txt file automatically.
https://www.javedali.net/post/2023-04-audio-to-text/
MIT License
117 stars 18 forks source link
audio audio-to-text open-source openai python transcription whisper youtube

🤖🎬 YouTube Audio-to-Text Transcription 🎧📝

A sophisticated and user-friendly automation that downloads audio from YouTube videos, transcribes the content into text, detects the language of the transcribed text, and saves the transcription to a text file. Save time, effort, and resources by harnessing cutting-edge technology to streamline the transcription process.

Table of Contents

Description

This script is designed to facilitate the transcription of YouTube videos into text format. It eliminates the need for time-consuming manual transcription by automating the process through a series of well-defined steps. The user-friendly interface allows users to input a YouTube video URL, which is then processed to extract the audio, convert it into text, and save the transcription as a text file. This efficient and convenient solution is ideal for those who require quick and accurate transcriptions for various purposes, such as research, content creation, or accessibility.

Key Features

Prerequisites

  1. Python 3.6+
  2. pip to install required libraries

Required Libraries

Installation

  1. Clone this repository or download the script.
  2. Install the required libraries:

    pip install pytube
    pip install git+https://github.com/openai/whisper.git
    pip install langdetect
    1. Download FFmpeg and add it to environment variables.

Usage

  1. Run the script:

    python youtube_audio_to_text.py
  2. When prompted, enter the YouTube video URL you wish to transcribe:

    Enter the YouTube video URL: https://www.youtube.com/watch?v=XXXXXXXXXXX
  3. The script will download the audio, transcribe it, detect language, and save the transcription to a text file called output_{language}.txt.

  4. Access the transcription by opening the output_{language}.txt file located in the same directory as the script.

Workflow

  1. The user inputs a YouTube video URL when prompted.
  2. The pytube library is used to create a YouTube object and filter the audio stream.
  3. The audio stream is downloaded as an MP3 file and saved in the YoutubeAudios folder.
  4. The whisper library loads a base model and transcribes the downloaded audio into text.
  5. The langdetect library detects the language of the transcribed text.
  6. The transcription is saved to a text file named output_{language}.txt with the language code as part of the filename and opened for the user to view.

Contributing 🤝🌱

Contributions from users are highly valued and appreciated. There are two main ways to contribute to this project: through pull requests and issues.

Pull Requests

  1. Fork the repository and create a branch from the main branch.
  2. Make changes or additions to the code.
  3. Commit the changes, and push them to the branch.
  4. Open a pull request to the main branch with a clear and concise description of the changes.

Issues

  1. Navigate to the Issues section of the repository.
  2. Check if there is an existing issue similar to the one you'd like to create.
  3. If there isn't an existing issue, create a new issue by clicking the "New issue" button.
  4. Provide a descriptive title and detailed information about the proposed changes that you want to potentially add to the current script.

🎓🌟 Feel free to contribute, share, and spread the love 💖💬🌍