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.3.tar.gz (330.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.3-py2.py3-none-any.whl (12.3 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: video-subtitles-1.0.3.tar.gz
  • Upload date:
  • Size: 330.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.3.tar.gz
Algorithm Hash digest
SHA256 117ab71fdfef274226d9f91ab77c56ccbb507b51e5ba1496b815e241c5e7fe04
MD5 e1c67e31d6a04d64fffdc98e980de5b5
BLAKE2b-256 f65974392919fd0924e933e9bbadbebe0149aa7877485a7a6c8ecc1d295fc010

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for video_subtitles-1.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bc860ba11caa3f9e1c72d659ce1961d6926b75341588fe321b08cd35831ddf5a
MD5 549763d072367a956e5894b2ea8feca9
BLAKE2b-256 4a73fc29cc1155703efca0147610e084859cff95cd72af49946b7dcd79d740e7

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