Skip to content

Instantly share code, notes, and snippets.

@mttjohnson
Last active September 8, 2024 14:09
Show Gist options
  • Select an option

  • Save mttjohnson/31e9fe018c39bde826ae543bcd0007a7 to your computer and use it in GitHub Desktop.

Select an option

Save mttjohnson/31e9fe018c39bde826ae543bcd0007a7 to your computer and use it in GitHub Desktop.

Revisions

  1. mttjohnson revised this gist Feb 14, 2023. 2 changed files with 6 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -25,6 +25,10 @@ Run the script

    ./vprocess.sh

    # Run Time Expectations

    I ran this on a 15 minute video file and it took about 2 hours to process.

    # Special Thanks

    To [Alex](https://github.com/djpain) for figuring all this out in the first place and writing the script
    2 changes: 2 additions & 0 deletions vprocess.sh
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,8 @@ for file in input/*; do
    rm -rf "$(basename "$file")".srt
    rm -rf "$(basename "$file")".vtt
    rm -rf "$(basename "$file")".txt
    rm -rf "$(basename "$file")".json
    rm -rf "$(basename "$file")".tsv
    done
    }

  2. mttjohnson revised this gist Feb 14, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -27,4 +27,4 @@ Run the script

    # Special Thanks

    To (Alex)[https://github.com/djpain] for figuring all this out in the first place and writing the script
    To [Alex](https://github.com/djpain) for figuring all this out in the first place and writing the script
  3. mttjohnson created this gist Feb 14, 2023.
    30 changes: 30 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    # Dependencies

    Install the following dependencies

    brew install pipenv
    brew install ffmpeg
    pipenv install --python 3.10

    # Instructions

    Activate a pipenv shell and make sure the following python packages are installed

    pipenv shell --python 3.10
    pip3 install ffmpeg-python
    pip3 install git+https://github.com/openai/whisper.git

    Setup input/output directories

    mkdir -p input
    mkdir -p output

    Move files you want to process to a directory called "input"

    Run the script

    ./vprocess.sh

    # Special Thanks

    To (Alex)[https://github.com/djpain] for figuring all this out in the first place and writing the script
    29 changes: 29 additions & 0 deletions vprocess.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    #!/bin/zsh
    set -xe

    language=Turkish
    model_size=large

    filenamefunc () {
    for file in input/*; do
    echo "$(date) ---------- starting whisper ----------"
    whisper --model $model_size "$file" --language $language --task translate --fp16 False
    echo "$(date) ---------- starting ffmpeg ----------"
    ffmpeg -i "$file" -vf subtitles="$(basename "$file")".srt output/"$(basename "$file" .mp4)"_engsub.mp4
    done
    }

    cleanup () {
    for file in input/*; do
    rm -rf "$(basename "$file")".srt
    rm -rf "$(basename "$file")".vtt
    rm -rf "$(basename "$file")".txt
    done
    }

    echo "$(date) ---------- starting filenamefunc ----------"
    filenamefunc
    echo "$(date) ---------- starting cleanup ----------"
    cleanup

    echo "$(date) ---------- finished ----------"