Generate subtitles with whisper-cli
You can install whisper-cli on your mac using homebrew
brew install whisper-cli
This will use hombrew to install whisper cli.
Verify installation
You can verify that whisper-cli has been installed correctly by running the following command:
whisper-cli --version
On my machine it gives me the following output
whisper-cli --version
load_backend: loaded BLAS backend from /opt/homebrew/Cellar/ggml/0.15.3/libexec/libggml-blas.so
ggml_metal_device_init: tensor API disabled for pre-M5 and pre-A19 devices
ggml_metal_library_init: using embedded metal library
ggml_metal_library_init: loaded in 0.043 sec
ggml_metal_rsets_init: creating a residency set collection (keep_alive = 180 s)
ggml_metal_device_init: GPU name: MTL0 (Apple M2 Pro)
ggml_metal_device_init: GPU family: MTLGPUFamilyApple8 (1008)
ggml_metal_device_init: GPU family: MTLGPUFamilyCommon3 (3003)
ggml_metal_device_init: GPU family: MTLGPUFamilyMetal4 (5002)
ggml_metal_device_init: simdgroup reduction = true
ggml_metal_device_init: simdgroup matrix mul. = true
ggml_metal_device_init: has unified memory = true
ggml_metal_device_init: has bfloat = true
ggml_metal_device_init: has tensor = false
ggml_metal_device_init: use residency sets = true
ggml_metal_device_init: use shared buffers = true
ggml_metal_device_init: recommendedMaxWorkingSetSize = 12713.12 MB
load_backend: loaded MTL backend from /opt/homebrew/Cellar/ggml/0.15.3/libexec/libggml-metal.so
load_backend: loaded CPU backend from /opt/homebrew/Cellar/ggml/0.15.3/libexec/libggml-cpu-apple_m2_m3.so
whisper.cpp version: 1.9.1
Downloading Models
The Homebrew package does not include any models, so you’ll need to download one separately. You can download models from huggingface website
mkdir -p ~/whisper-models
curl -L \
https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.en.bin \
-o ~/whisper-models/ggml-base.en.bin
Using whisper-cli
You can use the following command but it did not work for me :(
whisper-cli -m ./ggml-large-v1.bin -f input.mp4
My research suggested that I need to extract the audio into a wav file format first using ffmpeg.
ffmpeg -i input.mp4 -ar 16000 input.wav
This assumes that you have ffmpeg installed on your system. You can install it using brew install ffmpeg.
Once the audio is extracted, you can use the following command to generate subtitles:
whisper-cli \
-m ./ggml-large-v1.bin \
-f input.wav \
--language auto \
-osrt
If you know that language code (for example, en for English), you can specify it using the --language flag.
According to this github issue, this file contains the list of supported languages.
In my experience, results have been hit or miss. The transcription quality varies alot.