@@ -4,7 +4,8 @@ C/C++ port of [OpenAI's Whisper](https://github.com/openai/whisper) speech-to-te
4
4
5
5
- Plain C/C++ implementation without dependencies
6
6
- ARM_NEON and AVX intrinsics support
7
- - F16 support
7
+ - Mixed F16 / F32 support
8
+ - Low memory usage (Flash Attention + Flash Forward)
8
9
9
10
## Usage
10
11
@@ -27,9 +28,33 @@ For a quick demo, simply run `make base.en`:
27
28
``` bash
28
29
$ make base.en
29
30
30
- Downloading base.en (142 MB just once)
31
- mkdir -p models
32
- models/ggml-base.en.bin 100%[=================================> ] 141.11M 7.50MB/s in 19s
31
+ gcc -pthread -O3 -mavx -mavx2 -mfma -mf16c -c ggml.c
32
+ g++ -pthread -O3 -std=c++11 -c main.cpp
33
+ g++ -o main ggml.o main.o
34
+ ./main -h
35
+
36
+ usage: ./main [options]
37
+
38
+ options:
39
+ -h, --help show this help message and exit
40
+ -s SEED, --seed SEED RNG seed (default: -1)
41
+ -t N, --threads N number of threads to use during computation (default: 4)
42
+ -T N, --tokens N maximum number of tokens to generate per iteration (default: 64)
43
+ -v, --verbose verbose output
44
+ --translate translate from source language to english
45
+ -ps, --print_special print special tokens
46
+ -l LANG, --language LANG spoken language (default: en)
47
+ -m FNAME, --model FNAME model path (default: models/ggml-base.en.bin)
48
+ -f FNAME, --file FNAME input WAV file path (default: samples/jfk.wav)
49
+
50
+ bash ./download-ggml-model.sh base.en
51
+ Downloading ggml model base.en ...
52
+ models/ggml-base.en.bin 100%[=====================================> ] 141.11M 7.84MB/s in 18s
53
+ Done! Model ' base.en' saved in ' models/ggml-base.en.bin'
54
+ You can now use it like this:
55
+
56
+ $ ./main -m models/ggml-base.en.bin -f samples/jfk.wav
57
+
33
58
34
59
===============================================
35
60
Running base.en on all samples in ./samples ...
@@ -52,23 +77,24 @@ whisper_model_load: n_text_layer = 6
52
77
whisper_model_load: n_mels = 80
53
78
whisper_model_load: f16 = 1
54
79
whisper_model_load: type = 2
55
- whisper_model_load: mem_required = 782 .00 MB
80
+ whisper_model_load: mem_required = 611 .00 MB
56
81
whisper_model_load: adding 1607 extra tokens
57
- whisper_model_load: ggml ctx size = 186.26 MB
58
- whisper_model_load: memory size = 45.66 MB
82
+ whisper_model_load: ggml ctx size = 163.43 MB
83
+ whisper_model_load: memory size = 22.83 MB
59
84
whisper_model_load: model size = 140.54 MB
60
85
log_mel_spectrogram: n_sample = 176000, n_len = 1100
61
86
log_mel_spectrogram: recording length: 11.000000 s
62
87
63
- And so my fellow Americans ask not what your country can do for you. Ask what you can do for your country .
88
+ main: processing 176000 samples (11.0 sec), 4 threads, lang = english, task = transcribe .. .
64
89
65
- main: load time = 60.62 ms
66
- main: mel time = 38.69 ms
67
- main: sample time = 2.36 ms
68
- main: encode time = 875.63 ms / 145.94 ms per layer
69
- main: decode time = 103.17 ms
70
- main: total time = 1081.13 ms
90
+ And so my fellow Americans ask not what your country can do for you. Ask what you can do for your country.
71
91
92
+ main: load time = 71.89 ms
93
+ main: mel time = 36.95 ms
94
+ main: sample time = 2.10 ms
95
+ main: encode time = 700.94 ms / 116.82 ms per layer
96
+ main: decode time = 86.14 ms
97
+ main: total time = 898.72 ms
72
98
```
73
99
74
100
The command downloads the ` base.en ` model converted to custom ` ggml ` format and runs the inference on all ` .wav ` samples in the folder ` samples ` .
@@ -81,13 +107,18 @@ make samples
81
107
82
108
This will download a few more audio files from Wikipedia and convert them to 16-bit WAV format via ` ffmpeg ` .
83
109
84
- You can download and run the other ` .en ` models as follows:
110
+ You can download and run the other models as follows:
85
111
86
112
```
87
113
make tiny.en
114
+ make tiny
88
115
make base.en
116
+ make base
89
117
make small.en
118
+ make small
90
119
make medium.en
120
+ make medium
121
+ make large
91
122
```
92
123
93
124
For detailed usage instructions, run: ` ./main -h `
@@ -101,10 +132,8 @@ ffmpeg -i input.mp3 -ar 16000 -ac 1 -c:a pcm_s16le output.wav
101
132
102
133
## Limitations
103
134
104
- - Only ` .en ` models are supported
105
135
- Very basic greedy sampling scheme - always pick up the top token
106
136
- No timestamps
107
- - English only
108
137
- Inference only
109
138
- Runs on the CPU
110
139
- Only mono-channel 16-bit WAV is supported
@@ -113,10 +142,11 @@ ffmpeg -i input.mp3 -ar 16000 -ac 1 -c:a pcm_s16le output.wav
113
142
114
143
| Model | Disk | Mem |
115
144
| --- | --- | --- |
116
- | tiny.en | 75 MB | ~ 600 MB |
117
- | base.en | 142 MB | ~ 800 MB |
118
- | small.en | 466 MB | ~ 1.6 GB |
119
- | medium.en | 1.5 GB | ~ 3.5 GB |
145
+ | tiny | 75 MB | ~ 460 MB |
146
+ | base | 142 MB | ~ 620 MB |
147
+ | small | 466 MB | ~ 1.3 GB |
148
+ | medium | 1.5 GB | ~ 2.8 GB |
149
+ | large | 2.9 GB | ~ 4.9 GB |
120
150
121
151
## ggml format
122
152
0 commit comments