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.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.2.tar.gz (329.8 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.2-py2.py3-none-any.whl (10.8 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: video-subtitles-1.0.2.tar.gz
  • Upload date:
  • Size: 329.8 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.2.tar.gz
Algorithm Hash digest
SHA256 13efe9911858416ddb27ba5f1c96e1bb3b24636801268534972ffba42263e2c5
MD5 2e6d09d434099349a60947fa0ebdd588
BLAKE2b-256 1e1f2a5967de32e833bf2ec393defb304720bbdc406794b3978ea311d47ed6c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for video_subtitles-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7c8f35284884b44528274d3ed708103da0023cec7806ae7b56e201e954128687
MD5 69f703a7baca7861956c4854b7b0afca
BLAKE2b-256 749623a3ca25b100671da2c29bed0775571bb748f47766a9db390771727a63b6

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