Wired WhisperX into global power settings.

This commit is contained in:
seclusionenthusiast committed 2026-03-03 22:34:52 +09:00
1 parent b04b2e54f7
commit a877061aab
5 files changed
+22 -4

No files matched your search

+2
View File
@@ -75,6 +75,7 @@ class LyricTranscribeRequest(BaseModel):
condition_on_previous_text: bool = False # if True, pass previous output as prompt; can cause hallucination loops
engine: str = "whisperx" # 'whisperx' (only supported engine)
diarize: bool = False # run speaker diarization (WhisperX only)
lrc_power_preset: str = "standard" # 'eco' | 'standard' | 'performance'
# ---------------------------------------------------------------------------
@@ -434,6 +435,7 @@ def lyric_transcribe_project(project_id: str, body: LyricTranscribeRequest):
output_dir=str(output_dir),
engine=body.engine,
diarize=body.diarize,
power_preset=body.lrc_power_preset,
)
return {"job_id": job_id, "output_dir": str(output_dir)}
+15 -3
View File
@@ -643,6 +643,15 @@ def _ensure_vocals(audio_path: str, job_id: str) -> str:
return audio_path
# Batch size and compute precision per power tier.
# 'compute_type_cuda' is used on GPU; CPU always falls back to 'int8'.
_WHISPERX_POWER_PRESETS: dict = {
'eco': {'batch_size': 4, 'compute_type_cuda': 'int8_float16'},
'standard': {'batch_size': 8, 'compute_type_cuda': 'float16'},
'performance': {'batch_size': 16, 'compute_type_cuda': 'float16'},
}
def run_lyric_transcription(
job_id: str,
audio_path: str,
@@ -658,6 +667,7 @@ def run_lyric_transcription(
output_dir: Optional[str] = None,
engine: str = "whisperx",
diarize: bool = False,
power_preset: str = "standard",
):
"""
Background task: transcribe vocals/lyrics from audio.
@@ -706,7 +716,9 @@ def run_lyric_transcription(
return
device = "cuda" if torch.cuda.is_available() else "cpu"
compute_type = "float16" if device == "cuda" else "int8"
_wx_preset = _WHISPERX_POWER_PRESETS.get(power_preset, _WHISPERX_POWER_PRESETS['standard'])
batch_size = _wx_preset['batch_size']
compute_type = _wx_preset['compute_type_cuda'] if device == "cuda" else "int8"
# Auto-ensure vocals stem for best transcription quality.
audio_path = _ensure_vocals(audio_path, job_id)
@@ -715,8 +727,8 @@ def run_lyric_transcription(
audio_arr = whisperx.load_audio(audio_path)
duration = float(len(audio_arr)) / 16000.0
jm.update_job(job_id, progress=f"Transcribing with WhisperX ({model})...")
wx_result = wx_model.transcribe(audio_arr, batch_size=16)
jm.update_job(job_id, progress=f"Transcribing with WhisperX ({model}, {power_preset})...")
wx_result = wx_model.transcribe(audio_arr, batch_size=batch_size)
detected_lang = wx_result.get("language") or language or "unknown"
if jm.should_cancel(job_id):
+1 -1
View File
@@ -19,7 +19,7 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="StemEngine" />
<link rel="apple-touch-icon" href="/icon.svg" />
<script type="module" crossorigin src="/assets/index-DCENRxjR.js"></script>
<script type="module" crossorigin src="/assets/index-D2-wLUWj.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BWSEN_1A.css">
</head>
<body>
+2
View File
@@ -387,6 +387,7 @@ export const lyricTranscribeProject = (
conditionOnPreviousText?: boolean
beamSize?: number
diarize?: boolean
lrcPowerPreset?: string
}
) => {
const wordTs = opts?.wordTimestamps ?? true
@@ -406,6 +407,7 @@ export const lyricTranscribeProject = (
beam_size: opts?.beamSize ?? undefined,
engine: 'whisperx',
diarize: opts?.diarize ?? false,
lrc_power_preset: opts?.lrcPowerPreset ?? 'standard',
}),
})
}
+2
View File
@@ -1290,6 +1290,7 @@ function StemLyricsRow({
try {
const wordTs = localStorage.getItem('stemengine-whisper-word-ts') !== 'false'
const condPrev = localStorage.getItem('stemengine-whisper-condition-prev') !== 'false'
const powerPreset = localStorage.getItem('stemengine-sep-power') ?? 'standard'
const res = await lyricTranscribeProject(projectId, stemName, {
model: whisperModel,
language: whisperLang || undefined,
@@ -1297,6 +1298,7 @@ function StemLyricsRow({
wordTimestamps: wordTs,
conditionOnPreviousText: condPrev,
diarize,
lrcPowerPreset: powerPreset,
})
sessionJobIds.current.add(res.job_id)
onAction()