Skip to content

Stream Python speech to text output live instead of after the process exits#12247

Merged
niksedk merged 1 commit into
SubtitleEdit:mainfrom
muaz978:fix/python-stt-unbuffered-output
Jul 7, 2026
Merged

Stream Python speech to text output live instead of after the process exits#12247
niksedk merged 1 commit into
SubtitleEdit:mainfrom
muaz978:fix/python-stt-unbuffered-output

Conversation

@muaz978

@muaz978 muaz978 commented Jul 7, 2026

Copy link
Copy Markdown

Problem

Python based speech to text engines (Whisper CTranslate2, MLX Whisper) showed a completely empty console while transcribing; all output appeared at once when the process finished. A 45 minute file decodes for many minutes with a blank console, which reads as frozen, and several users assumed the engine was looping without transcribing.

Cause and fix

Without a terminal attached, Python block buffers stdout (about 8 KB), so newline terminated progress lines sit in the buffer until the process exits. Running the same command in a terminal is line buffered, which is why the problem never reproduces there.

Verified against the shipped whisper-ctranslate2 bundle with output piped the same way Subtitle Edit reads it: without PYTHONUNBUFFERED the first line arrives only when the process ends; with it, lines arrive the moment they are printed.

The fix sets PYTHONUNBUFFERED=1 wherever PYTHONIOENCODING is already set (the generic engine path and the MLX helper path), so all Python based engines stream their progress live.

The CTranslate2 engine got --verbose True so its segment lines stream to the
console, but they still never appeared during the run: without a terminal
attached Python block-buffers stdout (about 8 KB), so every line sat in the
buffer until the process exited. A 45 minute file decodes for many minutes
with a completely empty console, which reads as frozen.

Verified against the shipped whisper-ctranslate2 bundle with output piped the
same way Subtitle Edit reads it: without PYTHONUNBUFFERED the first line
arrives only when the process ends; with it, lines arrive the moment they are
printed. Set PYTHONUNBUFFERED=1 wherever PYTHONIOENCODING is already set (the
generic engine path and the MLX helper path), so all Python-based engines
stream their progress live.
@niksedk niksedk merged commit d4e86d0 into SubtitleEdit:main Jul 7, 2026
2 checks passed
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