Skip to content

Commit 8549a1e

Browse files
committed
ref ggml-org#4 : added transcription timestamps
Can be turned off with "-nt" argument. Performance has also improved.
1 parent 62c65f2 commit 8549a1e

File tree

2 files changed

+235
-56
lines changed

2 files changed

+235
-56
lines changed

README.md

Lines changed: 75 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ $ make base.en
3131

3232
gcc -pthread -O3 -mavx -mavx2 -mfma -mf16c -c ggml.c
3333
g++ -pthread -O3 -std=c++11 -c main.cpp
34-
g++ -o main ggml.o main.o
34+
g++ -pthread -o main ggml.o main.o
3535
./main -h
3636

3737
usage: ./main [options]
@@ -40,22 +40,17 @@ options:
4040
-h, --help show this help message and exit
4141
-s SEED, --seed SEED RNG seed (default: -1)
4242
-t N, --threads N number of threads to use during computation (default: 4)
43-
-T N, --tokens N maximum number of tokens to generate per iteration (default: 64)
4443
-v, --verbose verbose output
4544
--translate translate from source language to english
4645
-ps, --print_special print special tokens
46+
-nt, --no_timestamps do not print timestamps
4747
-l LANG, --language LANG spoken language (default: en)
4848
-m FNAME, --model FNAME model path (default: models/ggml-base.en.bin)
4949
-f FNAME, --file FNAME input WAV file path (default: samples/jfk.wav)
5050

5151
bash ./download-ggml-model.sh base.en
5252
Downloading ggml model base.en ...
53-
models/ggml-base.en.bin 100%[=====================================>] 141.11M 7.84MB/s in 18s
54-
Done! Model 'base.en' saved in 'models/ggml-base.en.bin'
55-
You can now use it like this:
56-
57-
$ ./main -m models/ggml-base.en.bin -f samples/jfk.wav
58-
53+
Model base.en already exists. Skipping download.
5954

6055
===============================================
6156
Running base.en on all samples in ./samples ...
@@ -86,16 +81,17 @@ whisper_model_load: model size = 140.54 MB
8681
log_mel_spectrogram: n_sample = 176000, n_len = 1100
8782
log_mel_spectrogram: recording length: 11.000000 s
8883

89-
main: processing 176000 samples (11.0 sec), 4 threads, lang = english, task = transcribe ...
84+
main: processing 176000 samples (11.0 sec), 4 threads, lang = english, task = transcribe, timestamps = 1 ...
9085

91-
And so my fellow Americans ask not what your country can do for you. Ask what you can do for your country.
86+
[00:00.000 --> 00:11.000] And so my fellow Americans ask not what your country can do for you. Ask what you can do for your country.
9287

93-
main: load time = 71.89 ms
94-
main: mel time = 36.95 ms
88+
89+
main: load time = 61.78 ms
90+
main: mel time = 41.74 ms
9591
main: sample time = 2.10 ms
96-
main: encode time = 700.94 ms / 116.82 ms per layer
97-
main: decode time = 86.14 ms
98-
main: total time = 898.72 ms
92+
main: encode time = 718.60 ms / 119.77 ms per layer
93+
main: decode time = 83.55 ms
94+
main: total time = 908.15 ms
9995
```
10096

10197
The command downloads the `base.en` model converted to custom `ggml` format and runs the inference on all `.wav` samples in the folder `samples`.
@@ -131,10 +127,73 @@ For example, you can use `ffmpeg` like this:
131127
ffmpeg -i input.mp3 -ar 16000 -ac 1 -c:a pcm_s16le output.wav
132128
```
133129

130+
Here is another example of transcribing a [3:24 min speech](https://upload.wikimedia.org/wikipedia/commons/1/1f/George_W_Bush_Columbia_FINAL.ogg) in less than a minute, using `medium.en` model:
131+
132+
```bash
133+
$ ./main -m models/ggml-medium.en.bin -f samples/gb1.wav -t 8
134+
whisper_model_load: loading model from 'models/ggml-medium.en.bin'
135+
whisper_model_load: n_vocab = 51864
136+
whisper_model_load: n_audio_ctx = 1500
137+
whisper_model_load: n_audio_state = 1024
138+
whisper_model_load: n_audio_head = 16
139+
whisper_model_load: n_audio_layer = 24
140+
whisper_model_load: n_text_ctx = 448
141+
whisper_model_load: n_text_state = 1024
142+
whisper_model_load: n_text_head = 16
143+
whisper_model_load: n_text_layer = 24
144+
whisper_model_load: n_mels = 80
145+
whisper_model_load: f16 = 1
146+
whisper_model_load: type = 4
147+
whisper_model_load: mem_required = 2786.00 MB
148+
whisper_model_load: adding 1607 extra tokens
149+
whisper_model_load: ggml ctx size = 1644.97 MB
150+
whisper_model_load: memory size = 182.62 MB
151+
whisper_model_load: model size = 1462.12 MB
152+
log_mel_spectrogram: n_sample = 3179750, n_len = 19873
153+
log_mel_spectrogram: recording length: 198.734375 s
154+
155+
main: processing 3179750 samples (198.7 sec), 8 threads, lang = english, task = transcribe, timestamps = 1 ...
156+
157+
[00:00.000 --> 00:08.000] My fellow Americans, this day has brought terrible news and great sadness to our country.
158+
[00:08.000 --> 00:17.000] At 9 o'clock this morning, Mission Control in Houston lost contact with our Space Shuttle Columbia.
159+
[00:17.000 --> 00:24.000] A short time later, debris was seen falling from the skies above Texas.
160+
[00:24.000 --> 00:29.000] The Columbia's lost. There are no survivors.
161+
[00:29.000 --> 00:32.000] On board was a crew of seven.
162+
[00:32.000 --> 00:43.000] Colonel Rick Husband, Lieutenant Colonel Michael Anderson, Commander Laurel Clark, Captain David Brown, Commander William McCool,
163+
[00:43.000 --> 00:52.000] Dr. Kultner Aschavla, and Elon Ramon, a Colonel in the Israeli Air Force.
164+
[00:52.000 --> 00:58.000] These men and women assumed great risk in the service to all humanity.
165+
[00:58.000 --> 01:06.000] In an age when space flight has come to seem almost routine, it is easy to overlook the dangers of travel by rocket
166+
[01:06.000 --> 01:12.000] and the difficulties of navigating the fierce outer atmosphere of the Earth.
167+
[01:12.000 --> 01:22.000] These astronauts knew the dangers, and they faced them willingly, knowing they had a high and noble purpose in life.
168+
[01:22.000 --> 01:30.000] Because of their courage, endearing, and idealism, we will miss them all the more.
169+
[01:30.000 --> 01:40.000] All Americans today are thinking as well of the families of these men and women who have been given this sudden shock and grief.
170+
[01:40.000 --> 01:45.000] You're not alone. Our entire nation agrees with you.
171+
[01:45.000 --> 01:52.000] And those you love will always have the respect and gratitude of this country.
172+
[01:52.000 --> 01:56.000] The cause in which they died will continue.
173+
[01:56.000 --> 02:07.000] Mankind is led into the darkness beyond our world by the inspiration of discovery and the longing to understand.
174+
[02:07.000 --> 02:11.000] Our journey into space will go on.
175+
[02:11.000 --> 02:16.000] In the skies today, we saw destruction and tragedy.
176+
[02:16.000 --> 02:22.000] Yet farther than we can see, there is comfort and hope.
177+
[02:22.000 --> 02:31.000] In the words of the prophet Isaiah, "Lift your eyes and look to the heavens who created all these.
178+
[02:31.000 --> 02:39.000] He who brings out the starry hosts one by one and calls them each by name."
179+
[02:39.000 --> 02:46.000] Because of his great power and mighty strength, not one of them is missing.
180+
[02:46.000 --> 02:55.000] The same creator who names the stars also knows the names of the seven souls we mourn today.
181+
[02:55.000 --> 03:05.000] The crew of the shuttle Columbia did not return safely to Earth, yet we can pray that all are safely home.
182+
[03:05.000 --> 03:14.000] May God bless the grieving families and may God continue to bless America.
183+
[03:14.000 --> 03:24.000] [Music]
184+
185+
186+
main: load time = 438.55 ms
187+
main: mel time = 440.22 ms
188+
main: sample time = 32.23 ms
189+
main: encode time = 42329.63 ms / 1763.73 ms per layer
190+
main: decode time = 15190.00 ms
191+
main: total time = 58444.63 ms
192+
```
193+
134194
## Limitations
135195
136196
- Very basic greedy sampling scheme - always pick up the top token
137-
- No timestamps
138197
- Inference only
139198
- Runs on the CPU
140199
- Only mono-channel 16-bit WAV is supported

0 commit comments

Comments
 (0)