From 8929a1ce7bd8afb9da6a34443b71c2816c40c680 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Sun, 23 Oct 2022 08:32:04 -0400 Subject: Captioning tools --- roles/caption/templates/caption.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 roles/caption/templates/caption.sh (limited to 'roles/caption/templates/caption.sh') diff --git a/roles/caption/templates/caption.sh b/roles/caption/templates/caption.sh new file mode 100755 index 0000000..9600a3c --- /dev/null +++ b/roles/caption/templates/caption.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# {{ ansible_managed }} +FILE="$1" +MODEL="${2:small}" +AUDIO=$(basename "$FILE" | sed s/\\.[a-z][a-z][a-z][a-z]?$//).ogg +if [[ ! -f $AUDIO ]]; then + if [[ "$FILE" == *webm ]]; then + ffmpeg -y -i "$FILE" -acodec copy -vn $AUDIO + else + ffmpeg -y -i "$FILE" -acodec libvorbis -vn $AUDIO + fi +fi +date > $AUDIO-$MODEL.log +time whisper $AUDIO --model $MODEL --threads 12 >> $AUDIO-$MODEL.log +for EXT in vtt txt srt; do + mv $AUDIO.$EXT $(basename -s .webm.$EXT $AUDIO.$EXT) +done +date >> $AUDIO-$MODEL.log -- cgit v1.2.3