|
1 | | -# whisper.cpp/examples/stream |
2 | | - |
3 | | -This is a naive example of performing real-time inference on audio from your microphone. |
4 | | -The `whisper-stream` tool samples the audio every half a second and runs the transcription continously. |
5 | | -More info is available in [issue #10](https://github.com/ggerganov/whisper.cpp/issues/10). |
6 | | - |
7 | | -```bash |
8 | | -./build/bin/whisper-stream -m ./models/ggml-base.en.bin -t 8 --step 500 --length 5000 |
9 | | -``` |
10 | | - |
11 | | -https://user-images.githubusercontent.com/1991296/194935793-76afede7-cfa8-48d8-a80f-28ba83be7d09.mp4 |
12 | | - |
13 | | -## Sliding window mode with VAD |
14 | | - |
15 | | -Setting the `--step` argument to `0` enables the sliding window mode: |
16 | | - |
17 | | -```bash |
18 | | - ./build/bin/whisper-stream -m ./models/ggml-base.en.bin -t 6 --step 0 --length 30000 -vth 0.6 |
19 | | -``` |
20 | | - |
21 | | -In this mode, the tool will transcribe only after some speech activity is detected. A very |
22 | | -basic VAD detector is used, but in theory a more sophisticated approach can be added. The |
23 | | -`-vth` argument determines the VAD threshold - higher values will make it detect silence more often. |
24 | | -It's best to tune it to the specific use case, but a value around `0.6` should be OK in general. |
25 | | -When silence is detected, it will transcribe the last `--length` milliseconds of audio and output |
26 | | -a transcription block that is suitable for parsing. |
27 | | - |
28 | | -## Building |
29 | | - |
30 | | -The `whisper-stream` tool depends on SDL2 library to capture audio from the microphone. You can build it like this: |
31 | | - |
32 | | -```bash |
33 | | -# Install SDL2 |
34 | | -# On Debian based linux distributions: |
35 | | -sudo apt-get install libsdl2-dev |
36 | | - |
37 | | -# On Fedora Linux: |
38 | | -sudo dnf install SDL2 SDL2-devel |
39 | | - |
40 | | -# Install SDL2 on Mac OS |
41 | | -brew install sdl2 |
42 | | - |
43 | | -cmake -B build -DWHISPER_SDL2=ON |
44 | | -cmake --build build --config Release |
45 | | - |
46 | | -./build/bin/whisper-stream |
47 | | -``` |
48 | | - |
49 | | -## Web version |
50 | | - |
51 | | -This tool can also run in the browser: [examples/stream.wasm](/examples/stream.wasm) |
| 1 | +# whisper.cpp/examples/stream |
| 2 | + |
| 3 | +This is a naive example of performing real-time inference on audio from your microphone. |
| 4 | +The `whisper-stream` tool samples the audio every half a second and runs the transcription continously. |
| 5 | +More info is available in [issue #10](https://github.com/ggerganov/whisper.cpp/issues/10). |
| 6 | + |
| 7 | +```bash |
| 8 | +./build/bin/whisper-stream -m ./models/ggml-base.en.bin -t 8 --step 500 --length 5000 |
| 9 | +``` |
| 10 | + |
| 11 | +https://user-images.githubusercontent.com/1991296/194935793-76afede7-cfa8-48d8-a80f-28ba83be7d09.mp4 |
| 12 | + |
| 13 | +## VAD support |
| 14 | + |
| 15 | +VAD support can be enabled by specifying the `--vad` and optionally a `--vad-model` (by default |
| 16 | +`models/for-tests-silero-v5.1.2-ggml.bin` will be used). |
| 17 | + |
| 18 | +## Building |
| 19 | + |
| 20 | +The `whisper-stream` tool depends on SDL2 library to capture audio from the microphone. You can build it like this: |
| 21 | + |
| 22 | +```bash |
| 23 | +# Install SDL2 |
| 24 | +# On Debian based linux distributions: |
| 25 | +sudo apt-get install libsdl2-dev |
| 26 | + |
| 27 | +# On Fedora Linux: |
| 28 | +sudo dnf install SDL2 SDL2-devel |
| 29 | + |
| 30 | +# Install SDL2 on Mac OS |
| 31 | +brew install sdl2 |
| 32 | + |
| 33 | +cmake -B build -DWHISPER_SDL2=ON |
| 34 | +cmake --build build --config Release |
| 35 | + |
| 36 | +./build/bin/whisper-stream |
| 37 | +``` |
| 38 | + |
| 39 | +## Web version |
| 40 | + |
| 41 | +This tool can also run in the browser: [examples/stream.wasm](/examples/stream.wasm) |
0 commit comments