#!/bin/sh # this script relies on a bunch of stuff # # 1. ffmpeg has been installed by brew # 2. The instructions from https://blog.castopod.org/install-whisper-cpp-on-your-mac-in-5mn-and-transcribe-all-your-podcasts-for-free/ # have been followed to install whisper.cpp and the models. These are: # cd ~/co # git clone https://github.com/ggerganov/whisper.cpp.git # cd whisper.cpp # make # cd models # ./download-ggml-model.sh small # Create a temporary file tempfile="$(mktemp).wav" # convert the file into a wav file that whisper.cpp can read and put it there ffmpeg -i "$1" -ar 16000 $tempfile 2>/dev/null # use whisper to transcribe it ~/co/whisper.cpp/main \ -nt \ -m ~/co/whisper.cpp/models/ggml-small.bin \ -f $tempfile \ 2>/dev/null \ | perl -e '$_ = join "", <>; s/^\s+//ms; s/\s+$//ms; print' # Delete the temp file manually at the end of the script rm -f $tempfile