Skip to main content

Automatically subtitle any video spoken in any language to a language of your choice.

Project description

Subtitler

Automatically subtitle any video spoken in any language to a language of your choice using AI.

Models used:

Tools used:

  • ffmpeg

Please don't forget to star the repository if you find it useful or educational!

Before:

https://github.com/extremq/subtitler/assets/45830561/49f6ecce-cfdc-4f1c-97eb-07a36ac841c9

After (in Romanian - model_type=medium, language_model_type=base):

https://github.com/extremq/subtitler/assets/45830561/20bc5169-0ce3-47cd-adb7-15d75daf27f4

Setup

Install using pip.

pip install gptsubtitler

Install ffmpeg:

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

# MacOS
brew install ffmpeg

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

Quick guide

Example usage for adding subtitles and translating them in Romanian:

You only need to specify the language you want the subtitles to be in, the program will handle the rest of the work.

from gptsubtitler import Transcriber

# I strongly recommend using the "medium" model_type.
Transcriber.transcribe("soldier.mp4", target_language="ro", model_type="medium", language_model_type="base")

# If you want to use the gpu, add device="cuda"
# Transcriber.transcribe("soldier.mp4", target_language="ro", model_type="medium", language_model_type="base", device="cuda") 

You can also use the Translator class from translator.py if you just want to translate some text.

Example usage for translating from English to Romanian:

from gptsubtitler import Translator

print(Translator.translate("Hi!", target_language="ro", source_language="en"))

If you have generated a .srt file and just want to add subtitles:

from gptsubtitler import create_video_with_subtitles
create_video_with_subtitles("video.mp4", "output.srt", "video_subtitled.mp4")

Options

Device (if you have a gpu and have installed pytorch, use "cuda"):

  • cpu - default
  • cuda

Available options for model_type (the audio to text model):

  • tiny
  • base - default
  • small
  • medium
  • large

Available options for language_model_type (the language translator model):

  • base - default
  • large

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gptsubtitler-0.0.6.tar.gz (5.5 kB view details)

Uploaded Source

File details

Details for the file gptsubtitler-0.0.6.tar.gz.

File metadata

  • Download URL: gptsubtitler-0.0.6.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for gptsubtitler-0.0.6.tar.gz
Algorithm Hash digest
SHA256 6b98d0af9470303ec477e53f064ec0510c2a9fad3873aaa748c2776972f3e2a1
MD5 6cd63a21e304a9704c6d5fefb91eecea
BLAKE2b-256 7fa7114266ca13fa9eaaf152e71ef834a855917d1e26e29888a70333b2d9cc71

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page