auto-subtitle

repository·main·Indexed 25 days ago

https://github.com/m1guelpf/auto-subtitle

A Python-based tool that uses ffmpeg and OpenAI's Whisper model to automatically generate and overlay subtitles onto video files. It supports transcription in multiple languages, translation to English, and the generation of .srt files.

Tokens
954
Snippets
6
Records
9
Agent score
31%

What's inside auto-subtitle

  1. Install ffmpeg dependency

    main

    The tool requires ffmpeg to process video files. Install it using your operating system's package manager:

    • Ubuntu/Debian: Use apt.
    • MacOS: Use brew.
    • Windows: Use choco.
    # on Ubuntu or Debian
    sudo apt update && sudo apt install ffmpeg
    
    # on MacOS using Homebrew
    brew install ffmpeg
    
    # on Windows using Chocolatey
    choco install ffmpeg
  2. Configure transcription task and language

    main

    You can control whether the tool performs standard transcription or translation to English using the --task flag. If you specify a language, it will be used for the source audio; otherwise, the tool attempts to detect it automatically.

    • Transcribe (Default): Speech recognition in the original language.
    • Translate: Translates the speech from the source language into English.

    Note: If you use an English-only Whisper model (e.g., a model ending in .en), the tool will force the language to en regardless of your input.

  3. Configure the Whisper model size

    main

    You can specify a different OpenAI Whisper model using the --model flag to improve transcription accuracy, especially for non-English languages.

    Available models:

    • tiny
    • tiny.en
    • base
    • base.en
    • small (default)
    • small.en
    • medium
    • medium.en
    • large
    auto_subtitle /path/to/video.mp4 --model medium
  4. Use auto-subtitle to overlay subtitles on a video

    main

    Run the auto_subtitle command followed by the path to your video file. Use the -o flag to specify the output directory. By default, the tool uses the small Whisper model, which is optimized for English.

    auto_subtitle /path/to/video.mp4 -o subtitled/
  5. Reference: auto-subtitle CLI arguments and flags

    main

    The following arguments and flags are available for the auto-subtitle command:

    ArgumentFlagDefaultDescription
    video(positional)N/APaths to video files to transcribe (supports multiple files).
    --modelsmallName of the Whisper model to use (e.g., tiny, base, small, medium, large).
    --output_dir-o.Directory to save the outputs.
    --output_srtFalseWhether to output the .srt file along with the video files.
    --srt_onlyFalseOnly generate the .srt file and not create overlayed video.
    --verboseFalseWhether to print out the progress and debug messages.
    --tasktranscribeTask type: transcribe (X->X speech recognition) or translate (X->English translation).
    --languageautoThe origin language of the video. If auto, it is detected automatically. Supports ISO 639-1 codes (e.g., en, es, fr, zh).
  6. Use the auto-subtitle CLI

    main

    The auto-subtitle CLI tool allows you to transcribe video files or translate them into English, generating either .srt subtitle files or new video files with subtitles overlaid. You can process multiple video files in a single command.

    Basic Usage:

    auto-subtitle path/to/video.mp4