Spaces:
Running
Running
Create README.md
Browse files
Makefile
CHANGED
|
@@ -19,7 +19,7 @@ run: main
|
|
| 19 |
.PHONY: samples
|
| 20 |
samples:
|
| 21 |
@echo "Downloading samples..."
|
| 22 |
-
mkdir -p samples
|
| 23 |
@wget --quiet --show-progress -O samples/gb0.ogg https://upload.wikimedia.org/wikipedia/commons/2/22/George_W._Bush%27s_weekly_radio_address_%28November_1%2C_2008%29.oga
|
| 24 |
@wget --quiet --show-progress -O samples/gb1.ogg https://upload.wikimedia.org/wikipedia/commons/1/1f/George_W_Bush_Columbia_FINAL.ogg
|
| 25 |
@wget --quiet --show-progress -O samples/hp0.ogg https://upload.wikimedia.org/wikipedia/en/d/d4/En.henryfphillips.ogg
|
|
@@ -31,10 +31,11 @@ samples:
|
|
| 31 |
.PHONY: tiny.en
|
| 32 |
tiny.en: main
|
| 33 |
@echo "Downloading tiny.en (75 MB just once)"
|
| 34 |
-
mkdir -p models
|
| 35 |
@if [ ! -f models/ggml-tiny.en.bin ]; then \
|
| 36 |
wget --quiet --show-progress -O models/ggml-tiny.en.bin https://ggml.ggerganov.com/ggml-model-whisper-tiny.en.bin ; \
|
| 37 |
fi
|
|
|
|
| 38 |
@echo "==============================================="
|
| 39 |
@echo "Running tiny.en on all samples in ./samples ..."
|
| 40 |
@echo "==============================================="
|
|
@@ -51,10 +52,11 @@ tiny.en: main
|
|
| 51 |
.PHONY: base.en
|
| 52 |
base.en: main
|
| 53 |
@echo "Downloading base.en (142 MB just once)"
|
| 54 |
-
mkdir -p models
|
| 55 |
@if [ ! -f models/ggml-base.en.bin ]; then \
|
| 56 |
wget --quiet --show-progress -O models/ggml-base.en.bin https://ggml.ggerganov.com/ggml-model-whisper-base.en.bin ; \
|
| 57 |
fi
|
|
|
|
| 58 |
@echo "==============================================="
|
| 59 |
@echo "Running base.en on all samples in ./samples ..."
|
| 60 |
@echo "==============================================="
|
|
@@ -71,10 +73,11 @@ base.en: main
|
|
| 71 |
.PHONY: small.en
|
| 72 |
small.en: main
|
| 73 |
@echo "Downloading small.en (466 MB just once)"
|
| 74 |
-
mkdir -p models
|
| 75 |
@if [ ! -f models/ggml-small.en.bin ]; then \
|
| 76 |
wget --quiet --show-progress -O models/ggml-small.en.bin https://ggml.ggerganov.com/ggml-model-whisper-small.en.bin ; \
|
| 77 |
fi
|
|
|
|
| 78 |
@echo "==============================================="
|
| 79 |
@echo "Running small.en on all samples in ./samples ..."
|
| 80 |
@echo "==============================================="
|
|
@@ -91,10 +94,11 @@ small.en: main
|
|
| 91 |
.PHONY: medium.en
|
| 92 |
medium.en: main
|
| 93 |
@echo "Downloading medium.en (1.5 GB just once)"
|
| 94 |
-
mkdir -p models
|
| 95 |
@if [ ! -f models/ggml-medium.en.bin ]; then \
|
| 96 |
wget --quiet --show-progress -O models/ggml-medium.en.bin https://ggml.ggerganov.com/ggml-model-whisper-medium.en.bin ; \
|
| 97 |
fi
|
|
|
|
| 98 |
@echo "==============================================="
|
| 99 |
@echo "Running medium.en on all samples in ./samples ..."
|
| 100 |
@echo "==============================================="
|
|
|
|
| 19 |
.PHONY: samples
|
| 20 |
samples:
|
| 21 |
@echo "Downloading samples..."
|
| 22 |
+
@mkdir -p samples
|
| 23 |
@wget --quiet --show-progress -O samples/gb0.ogg https://upload.wikimedia.org/wikipedia/commons/2/22/George_W._Bush%27s_weekly_radio_address_%28November_1%2C_2008%29.oga
|
| 24 |
@wget --quiet --show-progress -O samples/gb1.ogg https://upload.wikimedia.org/wikipedia/commons/1/1f/George_W_Bush_Columbia_FINAL.ogg
|
| 25 |
@wget --quiet --show-progress -O samples/hp0.ogg https://upload.wikimedia.org/wikipedia/en/d/d4/En.henryfphillips.ogg
|
|
|
|
| 31 |
.PHONY: tiny.en
|
| 32 |
tiny.en: main
|
| 33 |
@echo "Downloading tiny.en (75 MB just once)"
|
| 34 |
+
@mkdir -p models
|
| 35 |
@if [ ! -f models/ggml-tiny.en.bin ]; then \
|
| 36 |
wget --quiet --show-progress -O models/ggml-tiny.en.bin https://ggml.ggerganov.com/ggml-model-whisper-tiny.en.bin ; \
|
| 37 |
fi
|
| 38 |
+
@echo ""
|
| 39 |
@echo "==============================================="
|
| 40 |
@echo "Running tiny.en on all samples in ./samples ..."
|
| 41 |
@echo "==============================================="
|
|
|
|
| 52 |
.PHONY: base.en
|
| 53 |
base.en: main
|
| 54 |
@echo "Downloading base.en (142 MB just once)"
|
| 55 |
+
@mkdir -p models
|
| 56 |
@if [ ! -f models/ggml-base.en.bin ]; then \
|
| 57 |
wget --quiet --show-progress -O models/ggml-base.en.bin https://ggml.ggerganov.com/ggml-model-whisper-base.en.bin ; \
|
| 58 |
fi
|
| 59 |
+
@echo ""
|
| 60 |
@echo "==============================================="
|
| 61 |
@echo "Running base.en on all samples in ./samples ..."
|
| 62 |
@echo "==============================================="
|
|
|
|
| 73 |
.PHONY: small.en
|
| 74 |
small.en: main
|
| 75 |
@echo "Downloading small.en (466 MB just once)"
|
| 76 |
+
@mkdir -p models
|
| 77 |
@if [ ! -f models/ggml-small.en.bin ]; then \
|
| 78 |
wget --quiet --show-progress -O models/ggml-small.en.bin https://ggml.ggerganov.com/ggml-model-whisper-small.en.bin ; \
|
| 79 |
fi
|
| 80 |
+
@echo ""
|
| 81 |
@echo "==============================================="
|
| 82 |
@echo "Running small.en on all samples in ./samples ..."
|
| 83 |
@echo "==============================================="
|
|
|
|
| 94 |
.PHONY: medium.en
|
| 95 |
medium.en: main
|
| 96 |
@echo "Downloading medium.en (1.5 GB just once)"
|
| 97 |
+
@mkdir -p models
|
| 98 |
@if [ ! -f models/ggml-medium.en.bin ]; then \
|
| 99 |
wget --quiet --show-progress -O models/ggml-medium.en.bin https://ggml.ggerganov.com/ggml-model-whisper-medium.en.bin ; \
|
| 100 |
fi
|
| 101 |
+
@echo ""
|
| 102 |
@echo "==============================================="
|
| 103 |
@echo "Running medium.en on all samples in ./samples ..."
|
| 104 |
@echo "==============================================="
|
README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# whisper.cpp
|
| 2 |
+
|
| 3 |
+
C/C++ port of [OpenAI's Whisper](https://github.com/openai/whisper) speech-to-text model
|
| 4 |
+
|
| 5 |
+
- Plain C/C++ implementation without dependencies
|
| 6 |
+
- ARM_NEON and AVX intrinsics support
|
| 7 |
+
- F16 support
|
| 8 |
+
|
| 9 |
+
## Usage
|
| 10 |
+
|
| 11 |
+
For a quick demo, simply run `make base.en`:
|
| 12 |
+
|
| 13 |
+
```bash
|
| 14 |
+
$ make base.en
|
| 15 |
+
|
| 16 |
+
Downloading base.en (142 MB just once)
|
| 17 |
+
mkdir -p models
|
| 18 |
+
models/ggml-base.en.bin 100%[=================================>] 141.11M 7.50MB/s in 19s
|
| 19 |
+
|
| 20 |
+
===============================================
|
| 21 |
+
Running base.en on all samples in ./samples ...
|
| 22 |
+
===============================================
|
| 23 |
+
|
| 24 |
+
----------------------------------------------
|
| 25 |
+
[+] Running base.en on samples/jfk.wav ... (run 'ffplay samples/jfk.wav' to listen)
|
| 26 |
+
----------------------------------------------
|
| 27 |
+
|
| 28 |
+
whisper_model_load: loading model from 'models/ggml-base.en.bin'
|
| 29 |
+
whisper_model_load: n_vocab = 51864
|
| 30 |
+
whisper_model_load: n_audio_ctx = 1500
|
| 31 |
+
whisper_model_load: n_audio_state = 512
|
| 32 |
+
whisper_model_load: n_audio_head = 8
|
| 33 |
+
whisper_model_load: n_audio_layer = 6
|
| 34 |
+
whisper_model_load: n_text_ctx = 448
|
| 35 |
+
whisper_model_load: n_text_state = 512
|
| 36 |
+
whisper_model_load: n_text_head = 8
|
| 37 |
+
whisper_model_load: n_text_layer = 6
|
| 38 |
+
whisper_model_load: n_mels = 80
|
| 39 |
+
whisper_model_load: f16 = 1
|
| 40 |
+
whisper_model_load: type = 2
|
| 41 |
+
whisper_model_load: mem_required = 782.00 MB
|
| 42 |
+
whisper_model_load: adding 1607 extra tokens
|
| 43 |
+
whisper_model_load: ggml ctx size = 186.26 MB
|
| 44 |
+
whisper_model_load: memory size = 45.66 MB
|
| 45 |
+
whisper_model_load: model size = 140.54 MB
|
| 46 |
+
log_mel_spectrogram: n_sample = 176000, n_len = 1100
|
| 47 |
+
log_mel_spectrogram: recording length: 11.000000 s
|
| 48 |
+
|
| 49 |
+
And so my fellow Americans ask not what your country can do for you. Ask what you can do for your country.
|
| 50 |
+
|
| 51 |
+
main: load time = 60.62 ms
|
| 52 |
+
main: mel time = 38.69 ms
|
| 53 |
+
main: sample time = 2.36 ms
|
| 54 |
+
main: encode time = 875.63 ms / 145.94 ms per layer
|
| 55 |
+
main: decode time = 103.17 ms
|
| 56 |
+
main: total time = 1081.13 ms
|
| 57 |
+
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
The command downloads the `base.en` model converted to custom `ggml` format and runs the inference on all `.wav` samples in the folder `samples`.
|
| 61 |
+
|
| 62 |
+
If you want some extra audio samples to play with, simply run:
|
| 63 |
+
|
| 64 |
+
```
|
| 65 |
+
make samples
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
This will download a few more audio files from Wikipedia and convert them to 16-bit WAV format via `ffmpeg`.
|
| 69 |
+
|
| 70 |
+
You can download and run the other `.en` models as follows:
|
| 71 |
+
|
| 72 |
+
```
|
| 73 |
+
make tiny.en
|
| 74 |
+
make base.en
|
| 75 |
+
make small.en
|
| 76 |
+
make medium.en
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
For detailed usage instructions, run: `./main -h`
|
| 80 |
+
|
| 81 |
+
Note that `whisper.cpp` runs only with 16-bit WAV files, so make sure to convert your input before running the tool.
|
| 82 |
+
For example, you can use `ffmpeg` like this:
|
| 83 |
+
|
| 84 |
+
```bash
|
| 85 |
+
ffmpeg -i input.mp3 -ar 16000 -ac 1 -c:a pcm_s16le output.wav
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
## Limitations
|
| 89 |
+
|
| 90 |
+
- Only `.en` models are supported
|
| 91 |
+
- Very basic greedy sampling scheme - always pick up the top token
|
| 92 |
+
- No timestamps
|
| 93 |
+
- English only
|
| 94 |
+
- Inference only
|
| 95 |
+
- Runs on the CPU
|
| 96 |
+
- Only mono-channel 16-bit WAV is supported
|
| 97 |
+
|
| 98 |
+
## Memory usage
|
| 99 |
+
|
| 100 |
+
| Model | Mem |
|
| 101 |
+
| --- | --- |
|
| 102 |
+
| tiny.en | ~600 MB |
|
| 103 |
+
| base.en | ~800 MB |
|
| 104 |
+
| small.en | ~1.6 GB |
|
| 105 |
+
| medium.en | ~3.5 GB |
|
| 106 |
+
|
| 107 |
+
## ggml format
|
| 108 |
+
|
| 109 |
+
The original models are converted to a custom binary format. This allows to pack everything needed into a single file:
|
| 110 |
+
|
| 111 |
+
- model parameters
|
| 112 |
+
- mel filters
|
| 113 |
+
- vocabulary
|
| 114 |
+
- weights
|
| 115 |
+
|
| 116 |
+
For more details, see the conversion script [convert-pt-to-ggml.py](convert-pt-to-ggml.py)
|