Skip to content

Instantly share code, notes, and snippets.

@bgrins
Last active March 8, 2023 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgrins/32dbaf1689dd8ee692e5abebb6905e33 to your computer and use it in GitHub Desktop.
Save bgrins/32dbaf1689dd8ee692e5abebb6905e33 to your computer and use it in GitHub Desktop.
#!/bin/bash
# First install whisper.cpp:
# xcode-select --install # if necessary
# git clone https://github.com/ggerganov/whisper.cpp.git
# cd whisper.cpp && make && cd models && bash ./download-ggml-model.sh small
# Next, install ffmpeg if necessary (`brew install ffmpeg`)
if [[ ! -f $1 ]]; then
echo "$1 is not a file."
exit 1
fi
# Convert to 16-bit, 16kHz WAV if necessary
wav_file=$1
stream_info=$(ffprobe -v error -show_entries stream=codec_name,sample_rate -of default=noprint_wrappers=1:nokey=1 $wav_file)
if [ "$stream_info" != "pcm_s16le 16000" ]; then
ffmpeg -y -i $1 -ar 16000 $1.wav
wav_file=$1.wav
fi
~/Code/whisper.cpp/main -m ~/Code/whisper.cpp/models/ggml-small.bin --output-txt -f $wav_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment