Files
stemengine_old/SUMMARIES.md
T

9.5 KiB

StemEngine — Session Summaries


2026-03-06

Diarization fix — whisperx.DiarizationPipeline not exposed

Problem: whisperx.DiarizationPipeline raised AttributeError because this version of WhisperX uses a lazy-loader __init__.py that only re-exports a handful of functions (load_model, align, assign_word_speakers, etc.) and never added DiarizationPipeline to the list.

Fix: Import directly from the submodule:

from whisperx.diarize import DiarizationPipeline as _DiarizationPipeline

Diarization fix — use_auth_token renamed to token

Problem: After fixing the import, DiarizationPipeline.__init__() raised TypeError: unexpected keyword argument 'use_auth_token'. The installed version renamed the parameter to match the huggingface_hub convention change.

Fix: Changed constructor call to _DiarizationPipeline(token=hf_token, device=device).

Also noted: this version defaults to pyannote/speaker-diarization-community-1, a community model that does not require accepting HuggingFace terms of use.


Diarization fix — speaker labels not propagated from words to segments

Problem: whisperx.assign_word_speakers in some versions assigns "speaker" only to individual word dicts, not to the parent segment dict. seg.get("speaker") returned None so |sp:SPEAKER_XX| tags were never emitted in LRC/ELRC output.

Fix (already applied in prior session): After assign_word_speakers, iterate segments and propagate the most-frequent word-level speaker to each segment that lacks one:

for _seg in wx_result.get("segments", []):
    if _seg.get("speaker"):
        continue
    _spk_counts = {}
    for _w in _seg.get("words", []):
        _s = _w.get("speaker")
        if _s:
            _spk_counts[_s] = _spk_counts.get(_s, 0) + 1
    if _spk_counts:
        _seg["speaker"] = max(_spk_counts, key=_spk_counts.get)

Timing fix — unaligned words all sharing seg["start"]

Problem: When WhisperX cannot align individual words (returns start=None), all such words in a segment received seg["start"] as their timestamp. In the frontend wordFillPct() function, consecutive words with identical timestamps produce dur = 0 → NaN fill percentage → broken karaoke highlight animation.

Fix: Distribute unaligned words evenly across [seg_start, seg_end] by index:

if _ws is None:
    _ws = _seg_start + (_wi / _n_words) * (_seg_end - _seg_start)
    _we = _seg_start + ((_wi + 1) / _n_words) * (_seg_end - _seg_start)

CUDA OOM — retry with reduced settings

Problem: Loading large, large-v2, or large-v3 models on cards with limited VRAM raised RuntimeError: CUDA out of memory, failing the job entirely.

Fix: Wrapped load_model + transcribe in a 2-attempt retry loop. On first OOM:

  • Clear CUDA cache (gc.collect() + torch.cuda.empty_cache())
  • Reduce batch_size to 4
  • Switch compute_type to "int8"
  • Update job progress to inform the user
  • Retry

On second OOM or any non-OOM error, re-raise. Also added _clear_cuda_cache() at job start to flush leftover allocations from previous jobs.

Added user-friendly error message on OOM failure suggesting smaller model or Eco preset.


WSL2 display stability — VRAM cap + CPU niceness + inter-phase yields

Problem: On WSL2, WhisperX saturates the shared GPU, starving the Windows Display Manager (DWM). This causes TDR timeouts, screen flicker, and display driver restarts.

Fixes added to lyric_transcriber_service.py:

  1. _apply_cuda_limits() called at job start:

    • os.nice(10) — lowers the job thread's CPU scheduling priority
    • torch.cuda.set_per_process_memory_fraction(fraction) — hard-caps VRAM usage, reserving headroom for DWM. Default 80%, configurable via STEMENGINE_GPU_MEMORY_FRACTION env var.
  2. time.sleep(0.15) inserted after each model-unload+cache-clear between the three heavy GPU phases (Whisper → alignment → diarization), giving the GPU scheduler a window to service DWM between compute bursts.

System-level recommendation (Windows host, not in code):

  • Create %UserProfile%\.wslconfig:
    [wsl2]
    memory=8GB
    processors=6
    
  • Set STEMENGINE_GPU_MEMORY_FRACTION=0.75 in Docker compose or .env for tighter cards.

2026-03-06 (continued)

Syllables checkbox + hide Phonemization in Auto Pipeline

Added lsyncAlign checkbox ("Syllables") to Auto Pipeline options (Settings.tsx, AutoPipelineDialog.tsx). Removed Phonemization from both ProjectDetail.tsx (Lyrics Sync tab) and Settings.tsx (Auto Pipeline step editor) — state kept for API compatibility.


Explicit mode — Whisper profanity uncensor

Added explicit: bool to LyricTranscribeRequest, run_lyric_transcription(), and frontend (ProjectDetail.tsx, AutoPipelineDialog.tsx, client.ts).

_uncensor_segments() in lyric_transcriber_service.py applies regex post-processing after transcription to restore censored words (f*** → fuck, etc.). Initial-prompt primer approach was discarded — it caused Whisper to reproduce the prompt text verbatim at the start of the transcription.


Hip-hop vocal style

Added vocal_style: str = "general" parameter throughout the stack. When "hiphop":

  • VAD thresholds: vad_onset=0.25, vad_offset=0.15, no_speech_threshold=0.35, hallucination_silence_threshold=1.0
  • Monkeypatches Silero.__call__ in try/finally to inject min_speech_duration_ms=100, min_silence_duration_ms=150 (these params are commented out in whisperx's wrapper, so they must be injected at call time).

GlobalAudioBar fixes + X button

  • Bar not appearing: isActiveRef is a ref so changing it doesn't trigger effects. Fixed by calling publishMeta(...) immediately after isActiveRef.current = true in both DynamicMixPlayer and LyricsLivePreview togglePlay branches.
  • Audio continuing after navigation: unregisterPlayback only removes the registry reference, not the audio element. Fixed by calling stopPlayback() before unregisterPlayback() in unmount cleanup of both players.
  • X button: Added stopCurrent() export to audioRegistry.ts (calls registered stop callback + clears _current). Added X (lucide-react) button to GlobalAudioBar.tsx.

Karaoke fill/pop mode + Open Foundry fonts

LyricsLivePreview.tsx:

  • Added karaokeMode: 'fill' | 'pop' to StyleState (default 'fill').
  • KaraokeWord now accepts isActive?: boolean and mode?: 'fill' | 'pop':
    • fill: existing left-to-right gradient sweep.
    • pop: active word bright + 15% larger; already-sung words stay bright; future words dim. Line accumulates highlighted words as sung — no gradient, no fill.
  • All three KaraokeWord call sites (karaoke, glow, blur styles) pass isActive and mode.
  • Added Fill/Pop toggle buttons to StylePicker.
  • Replaced FONT_OPTIONS with 10 Open Foundry fonts (Archivo, EB Garamond, Inter, Libre Baskerville, Oswald, Poppins, Roboto, Work Sans, Young Serif + System fallback).

package.json: Added @fontsource/* packages for all 9 named fonts — self-hosted, no Google CDN calls. Installed automatically by start.sh at container start.

main.tsx: Imports each @fontsource/* package so Vite bundles the font files.


Font dropdown dark background + bold toggle

  • Dropdown white background fix: Added colorScheme: 'dark' on the <select> and background: '#1e293b', color: '#e2e8f0' on each <option> so the native OS dropdown renders dark.
  • Bold toggle: Added fontBold: boolean to StyleState (default false). B button in StylePicker next to the font selector. Applied as fontWeight: 700 / 400 on the lyrics container so it cascades to all rendered text.

Pop mode rendering bug fix

Problem: In pop mode, WebkitTextFillColor: 'transparent' set by a previous fill-mode render persisted on the DOM element (React doesn't always clear vendor-prefixed style properties when they're removed from the style object). This made text invisible while the gradient background showed as a colored rectangle.

Fix: In the KaraokeWord pop-mode branch, explicitly reset all gradient/clip properties:

backgroundImage: 'none',
WebkitBackgroundClip: 'border-box',
WebkitTextFillColor: 'currentColor',  // key: restores text color rendering
backgroundClip: 'border-box',

WebkitTextFillColor: 'currentColor' makes the text use the CSS color property again, which is what pop mode sets per-word.


Pop mode — RAF loop still writing gradient to DOM

Problem: Even after the React CSS resets in KaraokeWord, a fill bar kept appearing in pop mode. The real cause: a requestAnimationFrame loop writes backgroundImage directly to activeWordSpanRef.current.style every frame (to avoid 60fps React re-renders). This direct DOM write completely bypassed React's style reconciliation and overwrote the pop-mode resets on every tick.

Fix:

  • Added karaokeModeRef = useRef(karaokeMode) alongside the other RAF refs.
  • Updated it inline each render: karaokeModeRef.current = karaokeMode (outside any effect, so it's always current without restarting the loop).
  • Gated the gradient write in the RAF loop: if (activeWordSpanRef.current && lastLineIdx >= 0 && karaokeModeRef.current !== 'pop').

Pop mode — done words should stay bright

Corrected pop mode behavior: sung (done) words stay bright, not dim. Only future words are dim. Active word is bright + 15% larger.

Changed color: isActive ? bright : dim → color: (isActive || done) ? bright : dim in KaraokeWord.