stream : add interactive start/stop mode (-i)#3926
Open
ailakshya wants to merge 2 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #969.
What
Adds an
-i/--interactiveflag to thestreamexample. Instead of transcribing continuously from launch,streamstarts 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
-i/--interactiveflag — default off, so existing behavior is unchanged.termios(raw, no-echo) on POSIX,conio(_kbhit/_getch) on Windows. Guarded byisatty(STDIN_FILENO)→ no-ops on pipes/redirects, so scripted use is unaffected.atexit(), so the shell is never left in raw mode (even onCtrl+C).audio.pause()); SPACE togglesaudio.resume()/pause()(withaudio.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
termiosis POSIX-standard).streamopens 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
SPACE→ recording,SPACE→ stopped,Q→ clean exit, status 0), driven through a PTY with injected keystrokes.Usage