### Install all supported features Source: https://github.com/baxtree/subaligner/blob/master/site/source/installation.rst Installs the 'harmony' extra to enable all supported features. ```bash $ pip install 'subaligner[harmony]' ``` -------------------------------- ### Install from GitHub via Pipenv Source: https://github.com/baxtree/subaligner/blob/master/site/source/installation.rst Installs Subaligner and its stretch/dev extras using Pipenv. ```bash $ pipenv install subaligner $ pipenv install 'subaligner[stretch]' $ pipenv install 'subaligner[dev]' ``` -------------------------------- ### Install ffmpeg with APT Source: https://github.com/baxtree/subaligner/blob/master/site/source/installation.rst Install ffmpeg on Debian/Ubuntu-based systems. Required dependency for Subaligner. ```bash $ apt-get install ffmpeg ``` -------------------------------- ### Install dependencies for development environment Source: https://github.com/baxtree/subaligner/blob/master/site/source/installation.rst Installs Subaligner with the 'dev' extra to set up a development environment. ```bash $ pip install 'subaligner[dev]' ``` -------------------------------- ### Install Subaligner via PyPI with pre-emptive NumPy Source: https://github.com/baxtree/subaligner/blob/master/site/source/installation.rst Upgrades pip and setuptools first to avoid dependency conflicts, then installs Subaligner from PyPI. ```bash $ pip install -U pip && pip install -U setuptools $ pip install subaligner ``` -------------------------------- ### Install Subaligner from source Source: https://github.com/baxtree/subaligner/blob/master/site/source/installation.rst Clones the GitHub repository and installs Subaligner from source, after upgrading pip and setuptools. ```bash $ git clone git@github.com:baxtree/subaligner.git && cd subaligner $ pip install -U pip && pip install -U setuptools $ python setup.py install ``` -------------------------------- ### Install Subaligner via pipx Source: https://github.com/baxtree/subaligner/blob/master/site/source/installation.rst Installs Subaligner and its stretch/dev extras using pipx. ```bash $ pipx install subaligner $ pipx install 'subaligner[stretch]' $ pipx install 'subaligner[dev]' ``` -------------------------------- ### Pre-install espeak with Homebrew Source: https://github.com/baxtree/subaligner/blob/master/site/source/installation.rst Alternative to the apt-get command for installing espeak on macOS before installing stretch or dev extras. ```bash $ brew install espeak ``` -------------------------------- ### Install ffmpeg with Homebrew Source: https://github.com/baxtree/subaligner/blob/master/site/source/installation.rst Install ffmpeg on macOS. Alternative to the apt-get command. Homebrew is required. ```bash $ brew install ffmpeg ``` -------------------------------- ### Install dependencies for translation Source: https://github.com/baxtree/subaligner/blob/master/site/source/installation.rst Installs Subaligner with the 'llm' extra to enable translation features. ```bash $ pip install 'subaligner[llm]' ``` -------------------------------- ### Install dependencies for setting up the development environment Source: https://github.com/baxtree/subaligner/blob/master/README.md Installs optional dependencies for development. Requires eSpeak to be pre-installed. ```bash pip install --no-build-isolation 'subaligner[dev]' ``` -------------------------------- ### Install subaligner from source Source: https://github.com/baxtree/subaligner/blob/master/README.md Clone the repository and install from source. Commands: clone repo, update pip, and install the package. ```bash git clone git@github.com:baxtree/subaligner.git && cd subaligner ``` ```bash pip install -U pip ``` ```bash pip install . ``` -------------------------------- ### Install all extra dependencies Source: https://github.com/baxtree/subaligner/blob/master/README.md Installs all optional dependencies using the 'harmony' extra. Requires eSpeak to be pre-installed. ```bash pip install --no-build-isolation 'subaligner[harmony]' ``` -------------------------------- ### Pre-install espeak with APT Source: https://github.com/baxtree/subaligner/blob/master/site/source/installation.rst Pre-install espeak packages on Debian/Ubuntu before installing subaligner[stretch] or subaligner[dev]. ```bash $ apt-get install espeak libespeak1 libespeak-dev espeak-data ``` -------------------------------- ### Install dependencies for forced alignment Source: https://github.com/baxtree/subaligner/blob/master/site/source/installation.rst Installs Subaligner with the 'stretch' extra to enable forced alignment features. ```bash $ pip install 'subaligner[stretch]' ``` -------------------------------- ### Install subaligner from PyPI with pip Source: https://github.com/baxtree/subaligner/blob/master/README.md First update pip and install wheel, then install the subaligner package from PyPI. ```bash pip install -U pip && pip install wheel ``` ```bash pip install subaligner ``` -------------------------------- ### Install eSpeak via apt-get Source: https://github.com/baxtree/subaligner/blob/master/README.md Install eSpeak and its libraries on Debian-based Linux. Required for 'stretch', 'dev', and 'harmony' extras. ```bash apt-get install espeak libespeak1 libespeak-dev espeak-data ``` -------------------------------- ### Check Subaligner CLI availability Source: https://github.com/baxtree/subaligner/blob/master/site/source/installation.rst Verifies that the Subaligner CLI is on the PATH and displays help for each available command. ```bash (.venv) $ subaligner --help (.venv) $ subaligner_1pass --help # shortcut for "subaligner -m single" (.venv) $ subaligner_2pass --help # shortcut for "subaligner -m dual" (.venv) $ subaligner_batch --help (.venv) $ subaligner_convert --help (.venv) $ subaligner_train --help (.venv) $ subaligner_tune --help ``` -------------------------------- ### Install FFmpeg via apt-get Source: https://github.com/baxtree/subaligner/blob/master/README.md Install FFmpeg on Debian-based Linux distributions. Required for basic installation of subaligner. ```bash apt-get install ffmpeg ``` -------------------------------- ### Run Subaligner with Docker Container (Linux/macOS) Source: https://github.com/baxtree/subaligner/blob/master/README.md Starts an interactive bash shell in the Subaligner Docker image, mounting the current directory and setting it as the working directory. Use when you prefer a containerized environment over local installation. ```bash docker run -v `pwd`:`pwd` -w `pwd` -it baxtree/subaligner bash ``` -------------------------------- ### Install FFmpeg via brew Source: https://github.com/baxtree/subaligner/blob/master/README.md Install FFmpeg using Homebrew on macOS. ```bash brew install ffmpeg ``` -------------------------------- ### Pull and run Subaligner Docker container on Windows Source: https://github.com/baxtree/subaligner/blob/master/site/source/installation.rst Pulls the Subaligner Docker image and runs it with the 'd:\media' directory mapped to '/media'. Docker Desktop is required. ```bash docker pull baxtree/subaligner docker run -v "/d/media":/media -w "/media" -it baxtree/subaligner bash ``` -------------------------------- ### Get help for CLI tools Source: https://github.com/baxtree/subaligner/blob/master/README.md Display help for the subaligner CLI tools. ```bash subaligner -h ``` ```bash subaligner_batch -h ``` ```bash subaligner_convert -h ``` ```bash subaligner_train -h ``` ```bash subaligner_tune -h ``` -------------------------------- ### Run Subaligner container Source: https://github.com/baxtree/subaligner/blob/master/site/source/installation.rst Runs the Subaligner Docker container with the current directory mounted for access to local files. ```bash $ docker run -v `pwd`:`pwd` -w `pwd` -it baxtree/subaligner bash ``` -------------------------------- ### Switch on stretching when aligning subtitles Source: https://github.com/baxtree/subaligner/blob/master/site/source/usage.rst Enable experimental stretching with -so (or --stretch_on). Requires subaligner[stretch] to be installed. ```bash (.venv) $ subaligner -m dual -v video.mp4 -s subtitle.srt -so ``` -------------------------------- ### Install dependencies for enabling translation and transcription Source: https://github.com/baxtree/subaligner/blob/master/README.md Installs optional dependencies for translation and transcription features. Requires a virtual environment is recommended. ```bash pip install 'subaligner[llm]' ``` -------------------------------- ### Install eSpeak via brew Source: https://github.com/baxtree/subaligner/blob/master/README.md Install eSpeak using Homebrew on macOS. Required for 'stretch', 'dev', and 'harmony' extras. ```bash brew install espeak ``` -------------------------------- ### helm install subaligner with directory parameters Source: https://github.com/baxtree/subaligner/blob/master/charts/subaligner/README.md Installs the Subaligner Helm chart, setting the host node paths for video, subtitle, and output directories via the --set flags. ```bash helm install subaligner . --set videoDirectory=$VIDEO_DIRECTORY,subtitleDirectory=$SUBTITLE_DIRECTORY,outputDirectory=$OUTPUT_DIRECTORY ``` -------------------------------- ### Install dependencies for enabling forced alignment Source: https://github.com/baxtree/subaligner/blob/master/README.md Installs optional dependencies for forced alignment. Requires eSpeak to be pre-installed. ```bash pip install --no-build-isolation 'subaligner[stretch]' ``` -------------------------------- ### Convert subtitle format and translate - command sequence Source: https://github.com/baxtree/subaligner/blob/master/site/source/advanced_usage.rst Shows how to convert a subtitle to another format and translate it. First get list of supported languages, then run conversion with translation. The example converts English SRT to Chinese VTT with translation. ```default $ subaligner_convert --languages $ subaligner_convert -i subtitle_en.srt -o subtitle_zh.vtt -t eng,zho ``` -------------------------------- ### Re-configure timeouts Source: https://github.com/baxtree/subaligner/blob/master/site/source/usage.rst Options to set maximum waiting times for media processing and segment alignment. Use -mpt for media processing and -sat for segment alignment. ```bash -mpt MEDIA_PROCESS_TIMEOUT, --media_process_timeout MEDIA_PROCESS_TIMEOUT Maximum waiting time in seconds when processing media files -sat SEGMENT_ALIGNMENT_TIMEOUT, --segment_alignment_timeout SEGMENT_ALIGNMENT_TIMEOUT Maximum waiting time in seconds when aligning each segment ``` -------------------------------- ### Run alignments with pipx Source: https://github.com/baxtree/subaligner/blob/master/README.md Run subaligner using pipx without installing it permanently. Supports single and dual modes. ```bash pipx run subaligner -m single -v video.mp4 -s subtitle.srt ``` ```bash pipx run subaligner -m dual -v video.mp4 -s subtitle.srt ``` -------------------------------- ### Install patched aeneas for Python 3.12+ Source: https://github.com/baxtree/subaligner/blob/master/README.md Install a patched version of aeneas for Python 3.12+ to ensure full functionality of the specified extras. ```bash pip install --no-build-isolation -r requirements-py312-patched.txt ``` -------------------------------- ### Translate subtitle without changing format Source: https://github.com/baxtree/subaligner/blob/master/site/source/advanced_usage.rst Translates a subtitle file while keeping the same format. First get list of supported languages, then run conversion with translation. The example translates English SRT to Spanish SRT. ```default $ subaligner_convert --languages $ subaligner_convert -i subtitle_en.srt -o subtitle_es.srt -t eng,spa ``` -------------------------------- ### Start fresh training with subaligner_train Source: https://github.com/baxtree/subaligner/blob/master/site/source/advanced_usage.rst Initializes a new model training run. Requires that each subtitle file and its companion audiovisual file share the same base filename (e.g., awesome.mp4 and awesome.srt) and are in separate folders for -vd and -sd. Specify a writable output directory with -tod. ```default $ subaligner_train -vd av_directory -sd subtitle_directory -tod training_output_directory ``` -------------------------------- ### Docker alignment commands (single and dual) Source: https://github.com/baxtree/subaligner/blob/master/site/source/usage.rst Run subtitle alignment with Docker, mounting the current directory. Options: -m single or -m dual, video and subtitle inputs, optional output. The aligned subtitle is saved to subtitle_aligned.srt by default. ```bash docker run -v `pwd`:`pwd` -w `pwd` -it baxtree/subaligner subaligner -m single -v video.mp4 -s subtitle.srt ``` ```bash docker run -v `pwd`:`pwd` -w `pwd` -it baxtree/subaligner subaligner -m dual -v video.mp4 -s subtitle.srt ``` ```bash docker run -it baxtree/subaligner subaligner -m single -v https://example.com/video.mp4 -s https://example.com/subtitle.srt -o subtitle_aligned.srt ``` ```bash docker run -it baxtree/subaligner subaligner -m dual -v https://example.com/video.mp4 -s https://example.com/subtitle.srt -o subtitle_aligned.srt ``` -------------------------------- ### Transcribe audiovisual files and generate translated subtitles Source: https://github.com/baxtree/subaligner/blob/master/site/source/usage.rst Transcribe and translate in one step using a translation model (e.g., helsinki-nlp) with language pair. ```bash (.venv) $ subaligner -m transcribe -v video.mp4 -ml src -mr whisper -mf small -tr helsinki-nlp -o subtitle_aligned.srt -t src,tgt ``` -------------------------------- ### Save aligned subtitle to specific location Source: https://github.com/baxtree/subaligner/blob/master/site/source/usage.rst Use -o to specify the output subtitle file path. ```bash (.venv) $ subaligner -m dual -v video.mp4 -s subtitle.srt -o /path/to/the/output/subtitle.srt ``` -------------------------------- ### Run batch alignment against directories Source: https://github.com/baxtree/subaligner/blob/master/site/source/usage.rst Batch align subtitles in directories. Supports single and dual modes, with optional output format (e.g., ttml). ```bash (.venv) $ subaligner_batch -m single -vd videos/ -sd subtitles/ -od aligned_subtitles/ (.venv) $ subaligner_batch -m dual -vd videos/ -sd subtitles/ -od aligned_subtitles/ (.venv) $ subaligner_batch -m dual -vd videos/ -sd subtitles/ -od aligned_subtitles/ -of ttml ``` -------------------------------- ### Generate subtitles by transcribing audiovisual files Source: https://github.com/baxtree/subaligner/blob/master/site/source/usage.rst Transcribe audio/video using LLMs (e.g., whisper) with model size and language options. Supports initial prompt, word time codes, and optional existing subtitle for alignment. ```bash (.venv) $ subaligner -m transcribe -v video.mp4 -ml eng -mr whisper -mf small -o subtitle_aligned.srt (.venv) $ subaligner -m transcribe -v video.mp4 -ml zho -mr whisper -mf medium -o subtitle_aligned.srt (.venv) $ subaligner -m transcribe -v video.mp4 -ml eng -mr whisper -mf turbo -ip "your initial prompt" -o subtitle_aligned.srt (.venv) $ subaligner -m transcribe -v video.mp4 -ml eng -mr whisper -mf turbo -ip "your initial prompt" --word_time_codes -o raw_subtitle.json (.venv) $ subaligner -m transcribe -v video.mp4 -s subtitle.srt -ml eng -mr whisper -mf turbo -o subtitle_aligned.srt (.venv) $ subaligner -m transcribe -v video.mp4 -s subtitle.srt --use_prior_prompting -ml eng -mr whisper -mf turbo -o subtitle_aligned.srt ``` -------------------------------- ### Convert subtitle format with subaligner_convert Source: https://github.com/baxtree/subaligner/blob/master/site/source/advanced_usage.rst Converts a subtitle file from one format to another. Example converts subtitle.srt to subtitle.vtt. ```default $ subaligner_convert -i subtitle.srt -o subtitle.vtt ``` -------------------------------- ### Re-configure FFmpeg/Libav path Source: https://github.com/baxtree/subaligner/blob/master/site/source/usage.rst Set the FFMPEG_PATH environment variable to use a custom ffmpeg or avconv (Libav) executable. Lower case 'ffmpeg_path' is also supported. ```bash (.venv) $ export FFMPEG_PATH=/path/to/ffmpeg (.venv) $ subaligner -m dual -v video.mp4 -s subtitle.srt or (.venv) $ FFMPEG_PATH=/path/to/ffmpeg subaligner -m dual -v video.mp4 -s subtitle.srt or when using `Libav`_ (.venv) $ FFMPEG_PATH=/path/to/avconv subaligner -m dual -v video.mp4 -s subtitle.srt ``` -------------------------------- ### Single-stage alignment (high-level shift with lower latency) Source: https://github.com/baxtree/subaligner/blob/master/site/source/usage.rst Use for global subtitle shifting with lower latency. Supports local files or URLs, with optional output file. ```bash (.venv) $ subaligner -m single -v video.mp4 -s subtitle.srt (.venv) $ subaligner -m single -v https://example.org/video.mp4 -s https://example.org/subtitle.srt -o subtitle_aligned.srt ``` -------------------------------- ### Shift subtitle manually by offset in seconds Source: https://github.com/baxtree/subaligner/blob/master/site/source/usage.rst Manually shift subtitles by a positive or negative offset in seconds. Optionally specify output file. ```bash (.venv) $ subaligner -m shift --subtitle_path subtitle.srt -os 5.5 (.venv) $ subaligner -m shift --subtitle_path subtitle.srt -os -5.5 -o subtitle_shifted.srt ``` -------------------------------- ### Dual-stage alignment (low-level shift with higher latency) Source: https://github.com/baxtree/subaligner/blob/master/site/source/usage.rst Use for individual segment shifting with higher latency. Supports local files or URLs, with optional output file. ```bash (.venv) $ subaligner -m dual -v video.mp4 -s subtitle.srt (.venv) $ subaligner -m dual -v https://example.org/video.mp4 -s https://example.org/subtitle.srt -o subtitle_aligned.srt ``` -------------------------------- ### Alignment on embedded subtitles Source: https://github.com/baxtree/subaligner/blob/master/site/source/usage.rst Align embedded subtitle streams from media files using the 'embedded:stream_index' syntax. Works with single and dual modes. ```bash (.venv) $ subaligner -m single -v video.mkv -s embedded:stream_index=0 -o subtitle_aligned.srt (.venv) $ subaligner -m dual -v video.mkv -s embedded:stream_index=0 -o subtitle_aligned.srt ``` -------------------------------- ### Alignment on multiple subtitles against the single media file Source: https://github.com/baxtree/subaligner/blob/master/site/source/usage.rst Align multiple subtitle files against one media file. Subtitles can be specified with repeated -s flags or as a space-separated list. ```bash (.venv) $ subaligner -m script -v video.mp4 -s subtitle_lang_1.txt -s subtitle_lang_2.txt (.venv) $ subaligner -m script -v video.mp4 -s subtitle_lang_1.txt subtitle_lang_2.txt ``` -------------------------------- ### Alignment on segmented plain texts (double newlines as the delimiter) Source: https://github.com/baxtree/subaligner/blob/master/site/source/usage.rst Align plain text subtitles with double newline delimiters. Supports word time codes and URL inputs. ```bash (.venv) $ subaligner -m script -v video.mp4 -s subtitle.txt -o subtitle_aligned.srt (.venv) $ subaligner -m script -v video.mp4 -s subtitle.txt --word_time_codes -o raw_subtitle.json (.venv) $ subaligner -m script -v https://example.com/video.mp4 -s https://example.com/subtitle.txt -o subtitle_aligned.srt ``` -------------------------------- ### Translative alignment with the ISO 639-3 language code pair (src,tgt) Source: https://github.com/baxtree/subaligner/blob/master/site/source/usage.rst Align and translate subtitles using language code pairs. Supports listing languages, specifying translation models (helsinki-nlp, facebook-mbart, facebook-m2m100, whisper) and model sizes. ```bash (.venv) $ subaligner --languages (.venv) $ subaligner -m single -v video.mp4 -s subtitle.srt -t src,tgt (.venv) $ subaligner -m dual -v video.mp4 -s subtitle.srt -t src,tgt (.venv) $ subaligner -m script -v video.mp4 -s subtitle.txt -o subtitle_aligned.srt -t src,tgt (.venv) $ subaligner -m dual -v video.mp4 -s subtitle.srt -tr helsinki-nlp -o subtitle_aligned.srt -t src,tgt (.venv) $ subaligner -m dual -v video.mp4 -s subtitle.srt -tr facebook-mbart -tf large -o subtitle_aligned.srt -t src,tgt (.venv) $ subaligner -m dual -v video.mp4 -s subtitle.srt -tr facebook-m2m100 -tf small -o subtitle_aligned.srt -t src,tgt (.venv) $ subaligner -m dual -v video.mp4 -s subtitle.srt -tr whisper -tf small -o subtitle_aligned.srt -t src,eng ``` -------------------------------- ### Ignore sound effects in subtitles with markers Source: https://github.com/baxtree/subaligner/blob/master/site/source/advanced_usage.rst Filters out subtitle lines that contain sound effects, e.g., text starting with '(' and ending with ')', so the model focuses on vocal subtitles. Specify markers with -sesm and/or -seem, using strings that delimit the sound effect patterns. ```default $ subaligner_train -vd av_directory -sd subtitle_directory -tod training_output_directory --sound_effect_start_marker "(" --sound_effect_end_marker ")" ``` -------------------------------- ### Train a custom model Source: https://github.com/baxtree/subaligner/blob/master/README.md Command to train a new model with your own audiovisual and subtitle files. Specify video directory, subtitle directory, and training output directory. For more details, refer to Subaligner Docs. ```bash subaligner_train -vd VIDEO_DIRECTORY -sd SUBTITLE_DIRECTORY -tod TRAINING_OUTPUT_DIRECTORY ``` -------------------------------- ### Run batch alignment against directories Source: https://github.com/baxtree/subaligner/blob/master/README.md Run batch alignment against directories for video and subtitle files. Supports single and dual modes, and can output to a specific format like ttml. ```bash subaligner_batch -m single -vd videos/ -sd subtitles/ -od aligned_subtitles/ ``` ```bash subaligner_batch -m dual -vd videos/ -sd subtitles/ -od aligned_subtitles/ ``` ```bash subaligner_batch -m dual -vd videos/ -sd subtitles/ -od aligned_subtitles/ -of ttml ``` -------------------------------- ### Generate JSON Raw Subtitle with Per-word Timings (Script) Source: https://github.com/baxtree/subaligner/blob/master/README.md Aligns subtitle.txt and outputs raw_subtitle.json with per-word timings, using 'script' mode. ```bash subaligner -m script -v video.mp4 -s subtitle.txt --word_time_codes -o raw_subtitle.json ``` -------------------------------- ### Run unit tests Source: https://github.com/baxtree/subaligner/blob/master/site/source/test.rst Execute the unit test suite. ```default make test ``` -------------------------------- ### Run the module as a script Source: https://github.com/baxtree/subaligner/blob/master/README.md Run subaligner as a Python module using python -m. Supports single and dual modes. ```bash python -m subaligner -m single -v video.mp4 -s subtitle.srt ``` ```bash python -m subaligner -m dual -v video.mp4 -s subtitle.srt ``` -------------------------------- ### Transcribe with Global Initial Prompt Source: https://github.com/baxtree/subaligner/blob/master/README.md Passes a custom initial prompt to the Whisper turbo model for the entire transcription. Use -ip to set the prompt. ```bash subaligner -m transcribe -v video.mp4 -ml eng -mr whisper -mf turbo -ip "your initial prompt" -o subtitle_aligned.srt ``` -------------------------------- ### Single-stage Alignment (Remote URLs) Source: https://github.com/baxtree/subaligner/blob/master/README.md High-level shift alignment using remote video and subtitle URLs. Specify an output file with -o. ```bash subaligner -m single -v https://example.com/video.mp4 -s https://example.com/subtitle.srt -o subtitle_aligned.srt ``` -------------------------------- ### Run Subaligner batch dual mode via kubectl exec Source: https://github.com/baxtree/subaligner/blob/master/charts/subaligner/templates/NOTES.txt Uses the subaligner_batch CLI to process all videos and subtitles in the /videos and /subtitles directories, respectively, in dual mode. Output is written to /output. ```bash kubectl exec -it subaligner-**-* -- subaligner_batch -m dual -vd /videos -sd /subtitles -od /output ``` -------------------------------- ### Dual-stage Alignment (Local Files) Source: https://github.com/baxtree/subaligner/blob/master/README.md Performs low-level shift alignment with higher latency using 'dual' mode. Aligns subtitle.srt to video.mp4. ```bash subaligner -m dual -v video.mp4 -s subtitle.srt ``` -------------------------------- ### Transcribe and Generate Subtitles (English) Source: https://github.com/baxtree/subaligner/blob/master/README.md Transcribes video.mp4 using Whisper small model for English, outputting subtitle_aligned.srt. ```bash subaligner -m transcribe -v video.mp4 -ml eng -mr whisper -mf small -o subtitle_aligned.srt ``` -------------------------------- ### Run Subaligner dual mode via kubectl exec Source: https://github.com/baxtree/subaligner/blob/master/charts/subaligner/templates/NOTES.txt Uses the subaligner CLI in dual mode to align a single video/subtitle pair. Input video is taken from /videos, subtitle from /subtitles, and output is written to /output/subtitle_aligned.srt. ```bash kubectl exec -it subaligner-**-* -- subaligner -m dual -v /videos/video.mp4 -s /subtitles/subtitle.srt -o /output/subtitle_aligned.srt ``` -------------------------------- ### Align Segmented Plain Texts (Remote) Source: https://github.com/baxtree/subaligner/blob/master/README.md Aligns remote subtitle.txt to remote video.mp4, outputting subtitle_aligned.srt. ```bash subaligner -m script -v https://example.com/video.mp4 -s https://example.com/subtitle.txt -o subtitle_aligned.srt ``` -------------------------------- ### Generate JSON Raw Subtitle with Per-word Timings (Transcribe) Source: https://github.com/baxtree/subaligner/blob/master/README.md Transcribes with Whisper turbo and outputs raw_subtitle.json with per-word timings, using an initial prompt. ```bash subaligner -m transcribe -v video.mp4 -ml eng -mr whisper -mf turbo -ip "your initial prompt" --word_time_codes -o raw_subtitle.json ``` -------------------------------- ### Run alignments with the docker image Source: https://github.com/baxtree/subaligner/blob/master/README.md Pull and run the subaligner Docker image. Commands support local files with volume mounting or remote URLs. ```bash docker pull baxtree/subaligner ``` ```bash docker run -v `pwd`:`pwd` -w `pwd` -it baxtree/subaligner subaligner -m single -v video.mp4 -s subtitle.srt ``` ```bash docker run -v `pwd`:`pwd` -w `pwd` -it baxtree/subaligner subaligner -m dual -v video.mp4 -s subtitle.srt ``` ```bash docker run -it baxtree/subaligner subaligner -m single -v https://example.com/video.mp4 -s https://example.com/subtitle.srt -o subtitle_aligned.srt ``` ```bash docker run -it baxtree/subaligner subaligner -m dual -v https://example.com/video.mp4 -s https://example.com/subtitle.srt -o subtitle_aligned.srt ``` -------------------------------- ### Resume training with -r and -e Source: https://github.com/baxtree/subaligner/blob/master/site/source/advanced_usage.rst Continues a previously stopped training process to enhance an existing model in the training output directory. Use -r (or --resume) and -e (or --epochs) with a value greater than previously completed epochs. If unsure of the epoch count, use -dde to display it. ```default $ subaligner_train -vd av_directory -sd subtitle_directory -tod training_output_directory -e 200 -r ``` -------------------------------- ### Run integration tests Source: https://github.com/baxtree/subaligner/blob/master/site/source/test.rst Execute the integration test suite. ```default make test-int ``` -------------------------------- ### Run Subaligner on Windows with Docker Desktop Source: https://github.com/baxtree/subaligner/blob/master/site/source/advanced_usage.rst Docker command to run Subaligner on Windows with Docker Desktop. Mapping local drive to media directory and executing a command. ```default docker run -v "/d/media":/media -w "/media" -it baxtree/subaligner COMMAND ``` -------------------------------- ### Run tests with target Python versions Source: https://github.com/baxtree/subaligner/blob/master/site/source/test.rst Run the test suite against each configured Python version. ```default make test-all ``` -------------------------------- ### List supported language codes Source: https://github.com/baxtree/subaligner/blob/master/README.md Lists the ISO 639-3 language codes supported by the subaligner tool. ```bash subaligner --languages ``` -------------------------------- ### Transcribe and Generate Subtitles (Chinese) Source: https://github.com/baxtree/subaligner/blob/master/README.md Transcribes video.mp4 using Whisper medium model for Chinese (zho), outputting subtitle_aligned.srt. ```bash subaligner -m transcribe -v video.mp4 -ml zho -mr whisper -mf medium -o subtitle_aligned.srt ``` -------------------------------- ### Align Segmented Plain Texts (Local) Source: https://github.com/baxtree/subaligner/blob/master/README.md Aligns segmented subtitle.txt (delimited by double newlines) to video.mp4, outputting subtitle_aligned.srt. Uses 'script' mode. ```bash subaligner -m script -v video.mp4 -s subtitle.txt -o subtitle_aligned.srt ``` -------------------------------- ### Transcribe Using Full Subtitle Content as Prompt Source: https://github.com/baxtree/subaligner/blob/master/README.md Uses the content of subtitle.srt as the prompt for transcription, with Whisper turbo model. ```bash subaligner -m transcribe -v video.mp4 -s subtitle.srt -ml eng -mr whisper -mf turbo -o subtitle_aligned.srt ``` -------------------------------- ### Run test coverage Source: https://github.com/baxtree/subaligner/blob/master/site/source/test.rst Generate a test coverage report. ```default make coverage ``` -------------------------------- ### Dual-stage Alignment (Remote URLs) Source: https://github.com/baxtree/subaligner/blob/master/README.md Low-level shift alignment with remote inputs, output to subtitle_aligned.srt. ```bash subaligner -m dual -v https://example.com/video.mp4 -s https://example.com/subtitle.srt -o subtitle_aligned.srt ``` -------------------------------- ### Single-stage Alignment (Local Files) Source: https://github.com/baxtree/subaligner/blob/master/README.md Performs high-level shift alignment with lower latency using the 'single' mode. Aligns subtitle.srt to video.mp4, output is saved to subtitle_aligned.srt by default. ```bash subaligner -m single -v video.mp4 -s subtitle.srt ``` -------------------------------- ### Align Multiple Subtitles (Space-separated -s) Source: https://github.com/baxtree/subaligner/blob/master/README.md Alternative syntax for multiple subtitles: passes both files as a space-separated list after a single -s. ```bash subaligner -m script -v video.mp4 -s subtitle_lang_1.txt subtitle_lang_2.txt ``` -------------------------------- ### Transcribe and translate subtitles Source: https://github.com/baxtree/subaligner/blob/master/README.md Transcribe audiovisual files and generate translated subtitles using Whisper for transcription and Helsinki-NLP for translation. ```bash subaligner -m transcribe -v video.mp4 -ml src -mr whisper -mf small -tr helsinki-nlp -o subtitle_aligned.srt -t src,tgt ``` -------------------------------- ### Run Subaligner transcribe mode via kubectl exec Source: https://github.com/baxtree/subaligner/blob/master/charts/subaligner/templates/NOTES.txt Uses the subaligner CLI in transcribe mode to generate subtitles for a video using a specified model. Model language is English (eng), speech recognition is Whisper (mr whisper), and the model file is small (mf small). Output is written to /output/subtitle_aligned.srt. ```bash kubectl exec -it subaligner-**-* -- subaligner -m transcribe -v /videos/video.mp4 -ml eng -mr whisper -mf small -o /output/subtitle_aligned.srt ``` -------------------------------- ### Translative alignment with ISO 639-3 language pair Source: https://github.com/baxtree/subaligner/blob/master/README.md Run translative alignment with a source and target language code pair. Modes include single, dual, and script. Various translation models can be specified with -tr and -tf flags. ```bash subaligner -m single -v video.mp4 -s subtitle.srt -t src,tgt ``` ```bash subaligner -m dual -v video.mp4 -s subtitle.srt -t src,tgt ``` ```bash subaligner -m script -v video.mp4 -s subtitle.txt -o subtitle_aligned.srt -t src,tgt ``` ```bash subaligner -m dual -v video.mp4 -s subtitle.srt -tr helsinki-nlp -o subtitle_aligned.srt -t src,tgt ``` ```bash subaligner -m dual -v video.mp4 -s subtitle.srt -tr facebook-mbart -tf large -o subtitle_aligned.srt -t src,tgt ``` ```bash subaligner -m dual -v video.mp4 -s subtitle.srt -tr facebook-m2m100 -tf small -o subtitle_aligned.srt -t src,tgt ``` ```bash subaligner -m dual -v video.mp4 -s subtitle.srt -tr whisper -tf small -o subtitle_aligned.srt -t src,tgt ``` -------------------------------- ### Align Multiple Subtitles (Repeated -s) Source: https://github.com/baxtree/subaligner/blob/master/README.md Aligns two subtitles (subtitle_lang_1.txt, subtitle_lang_2.txt) against a single video, using repeated -s flags. ```bash subaligner -m script -v video.mp4 -s subtitle_lang_1.txt -s subtitle_lang_2.txt ``` -------------------------------- ### Transcribe with Previous Segment as Prompt Source: https://github.com/baxtree/subaligner/blob/master/README.md When transcribing, uses the previous subtitle segment as the prompt for the following segment. Enabled via --use_prior_prompting. ```bash subaligner -m transcribe -v video.mp4 -s subtitle.srt --use_prior_prompting -ml eng -mr whisper -mf turbo -o subtitle_aligned.srt ``` -------------------------------- ### Run hyperparameter tuning with subaligner_tune Source: https://github.com/baxtree/subaligner/blob/master/site/source/advanced_usage.rst Invokes Subaligner's automatic hyperparameter tuning using the Tree-structured Parzen Estimator approach. Takes video directory, subtitle directory, and output directory as arguments. ```default $ subaligner_tune -vd av_directory -sd subtitle_directory -tod training_output_directory ``` -------------------------------- ### Shift subtitle manually by offset Source: https://github.com/baxtree/subaligner/blob/master/README.md Shift subtitle timing by a specified offset in seconds. Multiple commands are shown for different cases. ```bash subaligner -m shift --subtitle_path subtitle.srt -os 5.5 ``` ```bash subaligner -m shift --subtitle_path subtitle.srt -os -5.5 -o subtitle_shifted.srt ``` -------------------------------- ### Re-configure timeout options Source: https://github.com/baxtree/subaligner/blob/master/site/source/advanced_usage.rst Options to customize maximum waiting times for media file processing and feature embedding. The -fet option sets the feature embedding timeout in seconds, and -mpt sets the media processing timeout. ```default -fet FEATURE_EMBEDDING_TIMEOUT, --feature_embedding_timeout FEATURE_EMBEDDING_TIMEOUT Maximum waiting time in seconds when embedding features of media files -mpt MEDIA_PROCESS_TIMEOUT, --media_process_timeout MEDIA_PROCESS_TIMEOUT Maximum waiting time in seconds when processing media files ``` -------------------------------- ### Display completed epochs with -dde Source: https://github.com/baxtree/subaligner/blob/master/site/source/advanced_usage.rst Shows the number of epochs already completed for a model in the training output directory, useful before resuming training with -r. ```default $ subaligner_train -dde -tod training_output_directory ``` -------------------------------- ### Run alignments after training (single and dual modes) Source: https://github.com/baxtree/subaligner/blob/master/site/source/advanced_usage.rst Applies a trained model to align subtitles in single or dual mode. The -tod parameter points to the training output directory containing the trained model. ```default $ subaligner -m single -v video.mp4 -s subtitle.srt -tod training_output_directory ``` ```default $ subaligner -m dual -v video.mp4 -s subtitle.srt -tod training_output_directory ``` -------------------------------- ### Subaligner hyperparameter flags - CLI help text Source: https://github.com/baxtree/subaligner/blob/master/site/source/advanced_usage.rst Shows the flags for manually setting hyperparameters when training Subaligner. Includes batch size, dropout, epochs, patience, hidden sizes, learning rate, network type, validation split, and optimizer. ```default -bs BATCH_SIZE, --batch_size BATCH_SIZE Number of 32ms samples at each training step -do DROPOUT, --dropout DROPOUT Dropout rate between 0 and 1 used at the end of each intermediate hidden layer -e EPOCHS, --epochs EPOCHS Total training epochs -p PATIENCE, --patience PATIENCE Number of epochs with no improvement after which training will be stopped -fhs FRONT_HIDDEN_SIZE, --front_hidden_size FRONT_HIDDEN_SIZE Number of neurons in the front LSTM or Conv1D layer -bhs BACK_HIDDEN_SIZE, --back_hidden_size BACK_HIDDEN_SIZE Comma-separated numbers of neurons in the back Dense layers -lr LEARNING_RATE, --learning_rate LEARNING_RATE Learning rate of the optimiser -nt {lstm,bi_lstm,conv_1d}, --network_type {lstm,bi_lstm,conv_1d} Network type -vs VALIDATION_SPLIT, --validation_split VALIDATION_SPLIT Fraction between 0 and 1 of the training data to be used as validation data -o {adadelta,adagrad,adam,adamax,ftrl,nadam,rmsprop,sgd}, --optimizer {adadelta,adagrad,adam,adamax,ftrl,nadam,rmsprop,sgd} TensorFlow optimizer ``` -------------------------------- ### Optional custom flags for subaligner_tune Source: https://github.com/baxtree/subaligner/blob/master/site/source/advanced_usage.rst Flags to customize hyperparameter tuning: epochs per trial, number of trials, network type, and whether to use training dump. ```default -ept EPOCHS_PER_TRAIL, --epochs_per_trail EPOCHS_PER_TRAIL Number of training epochs for each trial -t TRAILS, --trails TRAILS Number of tuning trials -nt {lstm,bi_lstm,conv_1d}, --network_type {lstm,bi_lstm,conv_1d} Network type -utd, --use_training_dump Use training dump instead of files in the video or subtitle directory ``` -------------------------------- ### Align Embedded Subtitles (Dual-stage) Source: https://github.com/baxtree/subaligner/blob/master/README.md Aligns embedded subtitle stream 0 from video.mkv using 'dual' mode, outputting subtitle_aligned.srt. ```bash subaligner -m dual -v video.mkv -s embedded:stream_index=0 -o subtitle_aligned.srt ``` -------------------------------- ### Align Embedded Subtitles (Single-stage) Source: https://github.com/baxtree/subaligner/blob/master/README.md Aligns embedded subtitle stream 0 from video.mkv using 'single' mode, outputting subtitle_aligned.srt. ```bash subaligner -m single -v video.mkv -s embedded:stream_index=0 -o subtitle_aligned.srt ``` -------------------------------- ### Reuse precomputed embeddings with -utd Source: https://github.com/baxtree/subaligner/blob/master/site/source/advanced_usage.rst Trains a new model using stored feature embeddings from a previous run, avoiding re-extraction that can be time-consuming for large datasets. The -utd (or --use_training_dump) flag enables this reuse. ```default $ subaligner_train -utd -tod training_output_directory ``` -------------------------------- ### Train with embedded subtitles using -ess Source: https://github.com/baxtree/subaligner/blob/master/site/source/advanced_usage.rst Trains using subtitles embedded in the audiovisual files. Omit -sd and pass a subtitle selector to -ess (or --embedded_subtitle_selector) such as 'embedded:stream_index=0,file_extension=srt'. If -sd is present, the folder must be empty. ```default $ subaligner_train -vd av_directory -ess embedded:stream_index=0,file_extension=srt -tod training_output_directory ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.