Skip to content

Make your videos accessible to a wider audience by adding subtitles in your target language, with support for any language vedio. (For example, add Chinese subtitle of English vedio)

License

Notifications You must be signed in to change notification settings

Zth9730/AnySubtitle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AnySubtitle

Make your videos accessible to a wider audience by adding subtitles in your target language, with support for any language vedio.

Automatic subtitles in your videos

This repository uses ffmpeg, OpenAI's Whisper and Fairseq's NLLB to automatically generate, translate and overlay subtitles on any language video.

Installation

To get started, you'll need install the binary by running the following command:

pip install git+https://github.com/huggingface/transformers.git

pip install git+https://github.com/Zth9730/AnySubtitle.git

You'll also need to install ffmpeg, which is available from most package managers:

# on Ubuntu or Debian
sudo apt update && sudo apt install ffmpeg

# on MacOS using Homebrew (https://brew.sh/)
brew install ffmpeg

# on Windows using Chocolatey (https://chocolatey.org/)
choco install ffmpeg

Usage

The following command will generate a subtitled/video.mp4 file contained the input video with overlayed subtitles.

any-subtitle /path/to/video.mp4 -o subtitled/

The default whisper model setting (which selects the small model) works well for transcribing English. You can optionally use a bigger model for better results (especially with other languages). The available models are tiny, tiny.en, base, base.en, small, small.en, medium, medium.en, large.

any-subtitle /path/to/video.mp4 --whis_model medium

Adding -t True to use nllb model to translate the subtitles, you can specific the nllb model with --nllb_model and set the target translation language with -l zho_Hans, or the language codes can be found in here.

any-subtitle /path/to/video.mp4 --whisper_model medium -t True --nllb_model small -l zho_Hans

if you want to use whisper to translate the subtitles into English, you can add --task translate and set -t False (as default).

any-subtitle /path/to/video.mp4 --task translate

Run the following to view all available options:

any-subtitle --help

Acknowledge

AnySubtitle refer to auto-subtitle.

License

This script is open-source and licensed under the MIT License. For more details, check the LICENSE file.

About

Make your videos accessible to a wider audience by adding subtitles in your target language, with support for any language vedio. (For example, add Chinese subtitle of English vedio)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages