Created
April 5, 2023 19:01
-
-
Save mhasbini/628fc85589026da928aaad4b6d4ed8d4 to your computer and use it in GitHub Desktop.
Script to generate srt for a directory that containes videos using https://github.com/ggerganov/whisper.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -Eeuo pipefail | |
msg() { | |
echo >&2 -e "${1-}" | |
} | |
source_dir="${1}" | |
for filename in $source_dir/*; do | |
[ -f "$filename" ] || continue | |
msg "$filename"; | |
msg "Extracting wav"; | |
ffmpeg -i "$filename" \ | |
-hide_banner \ | |
-vn \ | |
-loglevel error \ | |
-ar 16000 \ | |
-ac 1 \ | |
-c:a pcm_s16le \ | |
-y \ | |
"${filename}.wav"; | |
msg "Transcribing to subtitle file"; | |
./main -m models/ggml-tiny.bin -l en -t 4 -osrt -f "${filename}.wav"; | |
msg "cleanup"; | |
rm "${filename}.wav"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment