"YouTube Subtitle Whisper" is a Python script for adding subtitles to YouTube videos. Users can enter the URL of the YouTube video they wish to add subtitles to and enter the subtitle language. Thus, native Japanese speakers can input the URL of a YouTube video in English and select Japanese as the subtitle language to watch the video without any language barrier.
Install this repository with the following command:
git clone https://github.com/dodoya1/youtube_subtitle_whisper.git
In order to execute this code, the required modules must be installed:
pip install -r requirements.txt
It also requires the command-line tool ffmpeg
to be installed on your system, which is available from most package managers:
# on Ubuntu or Debian
sudo apt update && sudo apt install ffmpeg
# on Arch Linux
sudo pacman -S ffmpeg
# on MacOS using Homebrew (https://brew.sh/)
brew install ffmpeg
# on Windows using Chocolatey (https://chocolatey.org/)
choco install ffmpeg
# on Windows using Scoop (https://scoop.sh/)
scoop install ffmpeg
Execute main.py with the following command.
python3 main.py
Next, enter the URL of the YouTube video to which you want to add subtitles and enter the language of the subtitles. In addition, you will need to enter the name of the folder where you want to save the output results.
When selecting a language, please refer to the "ISO-639 Code" on the following website.
https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
This Python script allows the user to download a video from a given YouTube URL, transcribe the speech in the video using the whisper library, translate the transcription into a desired language using the deep_translator library, and embed the translated subtitles into the video using ffmpeg. The approach followed by the script can be summarized as follows:
- The user is prompted to enter the YouTube URL and the desired language for the subtitles.
- The video is downloaded using the yt-dlp module.
- The whisper library is used to transcribe the speech in the video, and the transcription is saved as a text file.
- The deep_translator library is used to translate the transcription into the desired language.
- The translated text is formatted with line breaks to improve readability.
- An SRT subtitle object is created for each segment of the transcription.
- The SRT subtitles are written to a file.
- The ffmpeg command is used to convert the SRT subtitles to ASS format and embed them into the video.
- The output video with embedded subtitles is saved as output.mp4.
https://github.com/openai/whisper
https://tt-tsukumochi.com/archives/2028
Please share your ideas and opinions!
If you find a bug in the project, please submit a detailed bug report on the Issues page on Github. Please include steps to reproduce the problem, expected behavior, and actual behavior. Screenshots and error messages are also helpful.
If you have an idea for a new feature, please submit a feature request on the Issues page on Github. Please describe the feature in detail and how it will benefit the project. If possible, please provide examples or mockups.
We welcome pull requests from anyone who would like to contribute to the project. Fork the repository and create a new branch for your changes. Please ensure that your code conforms to our coding standards and include unit tests where appropriate. Once you submit a pull request, it will be reviewed by a maintainer.
We need help improving our project documentation. This includes adding to the README.md file, creating user guides, and updating inline code comments. To contribute to the documentation, please submit a pull request with your changes.
We value the contributions of all contributors highly. If you submit a pull request and it is merged into the project, we will add you to the list of contributors in the README.md file. Additionally, if you contribute significantly to the project, we may invite you to become a maintainer.