Skip to content

stream : add interactive start/stop mode (-i)#3926

Open
ailakshya wants to merge 2 commits into
ggml-org:masterfrom
ailakshya:feature/stream-interactive-start-stop
Open

stream : add interactive start/stop mode (-i)#3926
ailakshya wants to merge 2 commits into
ggml-org:masterfrom
ailakshya:feature/stream-interactive-start-stop

Conversation

@ailakshya

Copy link
Copy Markdown

Closes #969.

What

Adds an -i / --interactive flag to the stream example. Instead of transcribing continuously from launch, stream starts paused; the user presses SPACE to start/stop microphone capture and Q to quit.

Why

The request in #969 — "press space bar to start and stop recording … rather than [it doing] automatic speech recognition." The always-on default is awkward for real dictation/push-to-talk: you transcribe ambient audio and can't cleanly delimit an utterance. It's also related to the duplicate-lines discussion in #1056 / #3866 — several users just want the audio they chose to record.

How

  • New -i / --interactive flag — default off, so existing behavior is unchanged.
  • Minimal non-blocking keyboard read: termios (raw, no-echo) on POSIX, conio (_kbhit/_getch) on Windows. Guarded by isatty(STDIN_FILENO) → no-ops on pipes/redirects, so scripted use is unaffected.
  • Terminal state is saved and restored on exit and via atexit(), so the shell is never left in raw mode (even on Ctrl+C).
  • In interactive mode capture starts paused (audio.pause()); SPACE toggles audio.resume()/pause() (with audio.clear() on start to drop buffered silence); while paused the loop sleeps and skips inference. Works in both sliding-window and VAD (--step 0) modes.

Scope

  • 1 file, +76 / −1. No new dependencies (SDL already present; termios is POSIX-standard).
  • Deliberately terminal-based rather than SDL keyboard: stream opens only an SDL audio device (no video window), so SDL key events aren't delivered — stdin is the right channel for a console app.

Testing

  • Compile-tested on Linux (CPU and Vulkan builds).
  • Interactive flow verified end-to-end (SPACErecording, SPACEstopped, Q → clean exit, status 0), driven through a PTY with injected keystrokes.

Usage

./build/bin/whisper-stream -m models/ggml-base.en.bin -i
# [Interactive mode: press SPACE to start/stop recording, Q to quit]

ailakshya added 2 commits July 4, 2026 18:18
Press SPACE to start/stop microphone capture and Q to quit, instead of
transcribing continuously from launch. Closes ggml-org#969.

Uses non-blocking terminal input (termios on POSIX, conio on Windows),
only active with -i and when stdin is a TTY; default behaviour unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Start/stop recording in stream

1 participant