]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
stream : stop on ^C when no audio is received (#2822)
authorpetterreinholdtsen <redacted>
Thu, 27 Feb 2025 06:59:51 +0000 (07:59 +0100)
committerGitHub <redacted>
Thu, 27 Feb 2025 06:59:51 +0000 (08:59 +0200)
Add check for ctrl-c in potentially endless loop while calling audio.get()
to receive sound.

Co-authored-by: Petter Reinholdtsen <redacted>
examples/stream/stream.cpp

index 833c240edd74b54754d57c0dc968191bbdc7c5d5..19d421387f864c7e539491d3203d9f584dd28e27 100644 (file)
@@ -244,6 +244,11 @@ int main(int argc, char ** argv) {
 
         if (!use_vad) {
             while (true) {
+                // handle Ctrl + C
+                is_running = sdl_poll_events();
+                if (!is_running) {
+                    break;
+                }
                 audio.get(params.step_ms, pcmf32_new);
 
                 if ((int) pcmf32_new.size() > 2*n_samples_step) {