Skip to main content

Creates Video Subtitles

Project description

video-subtitles

Adds subtitles to a movie.

Linting

MacOS_Tests Ubuntu_Tests Win_Tests

Run tox until it's correct.

To develop software, run . ./activate.sh

Install

Install Python 3.10

Install videosubtitles tool

  • Open up a windows command terminal
    • Hit the "Windows Key" + r
    • type in cmd and hit enter on the keyboard
    • type in pip install video-subtitles
    • Close the windows command terminal

It should now be installed.

First run

  • Keep in mind that the first run will take a lot of time as it downloads the proper drivers for your computer. But this will only be done once. Also there is an API key that you will be asked about, you can skip this by putting in free as the key.

Running

  • Open up a windows command terminal, as described in the previous step
  • cd to your video directory where you video is at
  • type in the following videosubtitles myvideo.mp4 --languages es,fr,zh,it
    • This will generate English, French, Chinese, Italian subtitles
    • For other subtitle languages see the language reference below
  • On the first run, you will be asked to enter in an API key from DeepL, the english -> Language X translation service. This KEY is free for upto 500,000 characters per month. If you don't like this then you can use the word free instead and special code will attempt to interact with the website and use point and clicks to get free translations. However this is extremely slow as pages need to be clicked by a bot. Also the translations are uploaded in chunks so you might get weird translations at the cutoff point. While the API key will be lightning fast and the translations have been verified to be excellent quality. Also, this free mode may break unexpectadly in the future.
  • After the translations are done, you'll get a new folder that is the name of the video with "test_" prepended to it. So myvideo.mp4 will generate a "text_myvideo" with srt files for all the languages
    • in the example above, you would get
      • text_myvideo/en.srt
      • text_myvideo/es.srt
      • text_myvideo/fr.srt
      • text_myvideo/zh.srt
      • text_myvideo/it.srt

How it works

  • Translation from audio -> en.srt is performed by transcribe-anything
    • Sadly, transcribe-anything can only translate to english subtitles.
  • After the english is generated, DeepL is used as a backend service to translate to english to all other languages.

Language Reference

Short hand language codes

af,am,ar,as,az,ba,be,bg,bn,bo,br,bs,ca,cs,cy,da,
de,el,en,es,et,eu,fa,fi,fo,fr,gl,gu,ha,haw,he,hi,
hr,ht,hu,hy,id,is,it,ja,jw,ka,kk,km,kn,ko,la,lb,
ln,lo,lt,lv,mg,mi,mk,ml,mn,mr,ms,mt,my,ne,nl,nn,
no,oc,pa,pl,ps,pt,ro,ru,sa,sd,si,sk,sl,sn,so,sq,
sr,su,sv,sw,ta,te,tg,th,tk,tl,tr,tt,uk,ur,uz,vi,
yi,yo,zh

Full Language codes will also work

Afrikaans,Albanian,Amharic,Arabic,Armenian,Assamese,Azerbaijani,
Bashkir,Basque,Belarusian,Bengali,Bosnian,Breton,Bulgarian,Burmese,
Castilian,Catalan,Chinese,Croatian,Czech,Danish,Dutch,English,
Estonian,Faroese,Finnish,Flemish,French,Galician,Georgian,German,
Greek,Gujarati,Haitian,Haitian Creole,Hausa,Hawaiian,Hebrew,Hindi,
Hungarian,Icelandic,Indonesian,Italian,Japanese,Javanese,Kannada,
Kazakh,Khmer,Korean,Lao,Latin,Latvian,Letzeburgesch,Lingala,
Lithuanian,Luxembourgish,Macedonian,Malagasy,Malay,Malayalam,
Maltese,Maori,Marathi,Moldavian,Moldovan,Mongolian,Myanmar,Nepali,
Norwegian,Nynorsk,Occitan,Panjabi,Pashto,Persian,Polish,Portuguese,
Punjabi,Pushto,Romanian,Russian,Sanskrit,Serbian,Shona,Sindhi,
Sinhala,Sinhalese,Slovak,Slovenian,Somali,Spanish,Sundanese,Swahili,
Swedish,Tagalog,Tajik,Tamil,Tatar,Telugu,Thai,Tibetan,Turkish,
Turkmen,Ukrainian,Urdu,Uzbek,Valencian,Vietnamese,Welsh,Yiddish,
Yoruba

Language code -> cononical name

{
  "af": "Afrikaans",
  "am": "Amharic",
  "ar": "Arabic",
  "as": "Assamese",
  "az": "Azerbaijani",
  "ba": "Bashkir",
  "be": "Belarusian",
  "bg": "Bulgarian",
  "bn": "Bengali",
  "bo": "Tibetan",
  "br": "Breton",
  "bs": "Bosnian",
  "ca": "Catalan",
  "cs": "Czech",
  "cy": "Welsh",
  "da": "Danish",
  "de": "German",
  "el": "Greek",
  "en": "English",
  "es": "Spanish",
  "et": "Estonian",
  "eu": "Basque",
  "fa": "Persian",
  "fi": "Finnish",
  "fo": "Faroese",
  "fr": "French",
  "gl": "Galician",
  "gu": "Gujarati",
  "ha": "Hausa",
  "haw": "Hawaiian",
  "he": "Hebrew",
  "hi": "Hindi",
  "hr": "Croatian",
  "ht": "Haitian Creole",
  "hu": "Hungarian",
  "hy": "Armenian",
  "id": "Indonesian",
  "is": "Icelandic",
  "it": "Italian",
  "ja": "Japanese",
  "jw": "Javanese",
  "ka": "Georgian",
  "kk": "Kazakh",
  "km": "Khmer",
  "kn": "Kannada",
  "ko": "Korean",
  "la": "Latin",
  "lb": "Luxembourgish",
  "ln": "Lingala",
  "lo": "Lao",
  "lt": "Lithuanian",
  "lv": "Latvian",
  "mg": "Malagasy",
  "mi": "Maori",
  "mk": "Macedonian",
  "ml": "Malayalam",
  "mn": "Mongolian",
  "mr": "Marathi",
  "ms": "Malay",
  "mt": "Maltese",
  "my": "Burmese",
  "ne": "Nepali",
  "nl": "Dutch",
  "nn": "Norwegian Nynorsk",
  "no": "Norwegian",
  "oc": "Occitan",
  "pa": "Punjabi",
  "pl": "Polish",
  "ps": "Pashto",
  "pt": "Portuguese",
  "ro": "Romanian",
  "ru": "Russian",
  "sa": "Sanskrit",
  "sd": "Sindhi",
  "si": "Sinhalese",
  "sk": "Slovak",
  "sl": "Slovene",
  "sn": "Shona",
  "so": "Somali",
  "sq": "Albanian",
  "sr": "Serbian",
  "su": "Sundanese",
  "sv": "Swedish",
  "sw": "Swahili",
  "ta": "Tamil",
  "te": "Telugu",
  "tg": "Tajik",
  "th": "Thai",
  "tk": "Turkmen",
  "tl": "Tagalog",
  "tr": "Turkish",
  "tt": "Tatar",
  "uk": "Ukrainian",
  "ur": "Urdu",
  "uz": "Uzbek",
  "vi": "Vietnamese",
  "yi": "Yiddish",
  "yo": "Yoruba",
  "zh": "Chinese",
}

Windows

This environment requires you to use git-bash.

Linting

Run ./lint.sh to find linting errors using ruff, pylint, flake8 and mypy.

Releases

  • 1.0.5: Adds webvtt format option.
  • 1.0.4: Adds thread processor so that multiple files can be done one at a time.
  • 1.0.3: Adds gui.
  • 1.0.2: Fix bug.
  • 1.0.1: Adds retry to translation step. Also alerts when the video is done.
  • 1.0.0: Initial release.

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

video-subtitles-1.0.5.tar.gz (334.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

video_subtitles-1.0.5-py2.py3-none-any.whl (15.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file video-subtitles-1.0.5.tar.gz.

File metadata

  • Download URL: video-subtitles-1.0.5.tar.gz
  • Upload date:
  • Size: 334.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for video-subtitles-1.0.5.tar.gz
Algorithm Hash digest
SHA256 fa3137406de5c68dc4c041ae1e5815331202c00b7f16b6155cdd175137c36580
MD5 0bde684ddd8215275e4eb19adf570398
BLAKE2b-256 96321f1f85ebbe16485da525415a8719115629ec5deac9042e416b21fb55a74d

See more details on using hashes here.

File details

Details for the file video_subtitles-1.0.5-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for video_subtitles-1.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 cb21749814d8d70cf743e724916d90add81acdf7c6d56d1ec5d0c85df17d3183
MD5 7758624e8c831034bb857d452928d442
BLAKE2b-256 4b78b391826d65c37029173429355cb520b1dd2bb9c77d71856a4fc48ada69a2

See more details on using hashes here.

Supported by

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