From 34e0b4b9ef2059863b310ea77c5b74218d215037 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Thu, 15 Dec 2022 20:15:36 +0200 Subject: [PATCH 1/2] stream : fix build --- examples/stream/stream.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/stream/stream.cpp b/examples/stream/stream.cpp index d281609..1b3586d 100644 --- a/examples/stream/stream.cpp +++ b/examples/stream/stream.cpp @@ -14,6 +14,7 @@ #include #include #include +#include // 500 -> 00:05.000 // 6000 -> 01:00.000 @@ -633,7 +634,7 @@ int main(int argc, char ** argv) { const int64_t t0 = std::max(0.0, t1 - pcmf32.size()*1000.0/WHISPER_SAMPLE_RATE); printf("\n"); - printf("### Transcription %d START | t0 = %lld ms | t1 = %lld ms\n", n_iter, t0, t1); + printf("### Transcription %d START | t0 = %d ms | t1 = %d ms\n", n_iter, (int) t0, (int) t1); printf("\n"); } From 5a5c5ddccaa08427a58a9e0e5208d5896a941b35 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Thu, 15 Dec 2022 20:38:08 +0200 Subject: [PATCH 2/2] Update README.md --- examples/stream/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/examples/stream/README.md b/examples/stream/README.md index 1ca7ee2..6d57734 100644 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -10,6 +10,23 @@ More info is available in [issue #10](https://github.com/ggerganov/whisper.cpp/i https://user-images.githubusercontent.com/1991296/194935793-76afede7-cfa8-48d8-a80f-28ba83be7d09.mp4 +## Slidingwindow mode + +Setting the `--step` argument to `0` enables the sliding window mode: + +```java + ./stream -m ./models/ggml-small.en.bin -t 6 --step 0 --length 30000 -vth 0.6 +``` + +In this mode, the tool will transcribe only after some speech activity is detected. A very +basic VAD detector is used, but in theory a more sophisticated approach can be added. The +`-vth` argument determines the VAD threshold - higher values will make it detect silence more often. +It's best to tune it to the specific use case, but a value around `0.6` should be OK in general. +When silence is detected, it will transcribe the last `--length` milliseconds of audio and output +a transcription block that is suitable for parsing. + +## Building + The `stream` tool depends on SDL2 library to capture audio from the microphone. You can build it like this: ```bash