23 lines
742 B
Shell
Executable file
23 lines
742 B
Shell
Executable file
#! /usr/bin/bash
|
|
#
|
|
# run captioning of a video with whisperx
|
|
#
|
|
# note: virtualenv caches the downloaded models by default in ~/cache
|
|
# if whisperx had ran previously with that model, the cache will be reused
|
|
# otherwise, the behavior may be weird when many jobs start in parallel
|
|
# however, reusing the default cache seems favourable over downloading models in each job
|
|
|
|
set -e -u
|
|
|
|
VIDEO=$1
|
|
OUTDIR=$2
|
|
|
|
# ensure that the output directory exists
|
|
mkdir -p $OUTDIR
|
|
|
|
# extract sound track and save alongside video (we don't intend to keep it)
|
|
audio=${VIDEO%.webm}.opus
|
|
ffmpeg -y -i $VIDEO -map 0:a -c copy $audio
|
|
|
|
# run whisperx
|
|
whisperx --model turbo --device cpu --compute_type int8 --output_dir $OUTDIR --output_format vtt --language en $audio
|