This project allows you to download a YouTube video, split it into parts, extract audio from each part, and transcribe the audio using the OpenAI Whisper API.
- Python 3.x
- OpenAI API key
- Clone the repository:
git clone https://github.com/your-username/yt_transcriptor.git
- Navigate to the project directory:
cd yt_transcriptor
- Run the
install.batscript to create a virtual environment and install the required packages:
install.bat
This script will create a virtual environment named myenv, activate it, and install the packages listed in the requirements.txt file.
- Create a
.envfile in the project directory and add your OpenAI API key:
OPENAI_API_KEY=your-api-key
Replace your-api-key with your actual OpenAI API key.
- Make sure the virtual environment is activated. If not, activate it by running:
myenv\Scripts\activate
- Run the
main.pyscript:
python main.py
-
Enter the YouTube video URL when prompted.
-
The script will download the video, split it into parts, extract audio from each part, and save the audio files in the "downloads" folder.
-
The audio from each part will be transcribed using the OpenAI Whisper API, and the transcription will be saved as a text file in the "downloads" folder.
-
You can customize the duration of each video part by modifying the
part_durationvariable in themain.pyscript. By default, it is set to 10 minutes (600 seconds). -
The video parts are saved as black screens instead of the original video content to reduce file size. If you want to include the original video content, you can modify the
split_video_into_partsfunction in themain.pyscript.
The project relies on the following Python packages:
pytube: For downloading YouTube videosmoviepy: For splitting the video into parts and extracting audiopython-dotenv: For loading the OpenAI API key from the.envfileopenai: For transcribing the audio using the OpenAI Whisper API
These dependencies are listed in the requirements.txt file and will be automatically installed during the installation process.
This project is licensed under the MIT License.