Skip to content

Whisper-stream: Add --pausable / -p — live **Pause / Resume** control #3325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

bogdoslavik
Copy link

@bogdoslavik bogdoslavik commented Jul 15, 2025

✨ Add --pausable / -p — live Pause / Resume control

Overview

Enabling --pausable lets you temporarily suspend and resume real-time transcription without restarting the program.

Action Stdin command
Pause p followed by a newline (p\n)
Resume r followed by a newline (r\n)

The control thread reads from stdin.
Most terminals add \n automatically when you press Enter, so type p⏎ or r⏎.


Why it matters

  • Pause long sessions to save CPU/GPU and keep the transcript clean.
  • Prevent residual words from the previous utterance from leaking into the next one.
  • Convenient when Whisper is part of an interactive pipeline that needs on-demand control.

Implementation details

  • CLI — new flag --pausable (-p), default off (backward-compatible).
  • Control thread — listens on stdin for p\n / r\n; unknown commands print a warning and are ignored.
  • Pause workflow
    audio.pause();            // stop capture
    audio.clear();            // flush ring buffer
    
    pcmf32.clear();
    pcmf32_new.clear();
    pcmf32_old.clear();
    prompt_tokens.clear();
    
    whisper_reset_timings(ctx);
    t_last = std::chrono::high_resolution_clock::now();
    is_paused = true;

Copy link
Member

@danbev danbev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem to work when I tested it (using Ubuntu). Pausing seems to work but not resuming.

@@ -112,6 +116,7 @@ void whisper_print_usage(int /*argc*/, char ** argv, const whisper_params & para
fprintf(stderr, " -sa, --save-audio [%-7s] save the recorded audio to a file\n", params.save_audio ? "true" : "false");
fprintf(stderr, " -ng, --no-gpu [%-7s] disable GPU inference\n", params.use_gpu ? "false" : "true");
fprintf(stderr, " -fa, --flash-attn [%-7s] flash attention during inference\n", params.flash_attn ? "true" : "false");
fprintf(stderr, " --pausable [%-7s] allow stdin commands p,n (PAUSE)/(RESUME)\n", params.pausable ? "true" : "false");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the short option -p is missing here.

And should this be r and not n:

Suggested change
fprintf(stderr, " --pausable [%-7s] allow stdin commands p,n (PAUSE)/(RESUME)\n", params.pausable ? "true" : "false");
fprintf(stderr, " --pausable [%-7s] allow stdin commands p,r (PAUSE)/(RESUME)\n", params.pausable ? "true" : "false");

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

continue;
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before exit the control_thread should probably join the main thread.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

joined

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.

2 participants