fix: Improve Whisper model status verification and PyInstaller builds

- Add robust model cache verification (check model.bin + config.json)
- Add new status messages: model_cached, incomplete_cache, model_error
- Forward model status events to frontend for better UI feedback
- Add clean_build_cache() to remove stale spec files before build
- Add --clean flag to PyInstaller commands
- Change sidecar from --onefile to --onedir for faster startup
- Add missing hidden imports: onnxruntime, wave, huggingface_hub.utils

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
egg
2025-12-17 20:33:59 +08:00
parent 012cdaf5f3
commit d75789f23e
5 changed files with 136 additions and 15 deletions

View File

@@ -423,6 +423,21 @@ function startSidecar() {
if (msg.status === "model_loaded" && mainWindow) {
mainWindow.webContents.send("model-download-progress", msg);
}
// Forward model cached status (model was already downloaded)
if (msg.status === "model_cached" && mainWindow) {
mainWindow.webContents.send("model-download-progress", msg);
}
// Forward incomplete cache status
if (msg.status === "incomplete_cache" && mainWindow) {
mainWindow.webContents.send("model-download-progress", msg);
}
// Forward model error status
if (msg.status === "model_error" && mainWindow) {
mainWindow.webContents.send("model-download-progress", msg);
}
} catch (e) {
console.log("Sidecar output:", line);
}

View File

@@ -319,16 +319,25 @@
whisperStatusEl.textContent = `⬇️ Downloading ${progress.model}: ${percent}% (${downloadedMb}/${totalMb} MB)`;
whisperStatusEl.style.color = '#ff9800';
} else if (progress.status === 'model_downloaded') {
whisperStatusEl.textContent = `${progress.model} downloaded`;
whisperStatusEl.textContent = `${progress.model} downloaded, loading...`;
whisperStatusEl.style.color = '#28a745';
} else if (progress.status === 'model_cached') {
whisperStatusEl.textContent = `${progress.model} cached, loading...`;
whisperStatusEl.style.color = '#28a745';
} else if (progress.status === 'incomplete_cache') {
whisperStatusEl.textContent = `⚠️ ${progress.model} cache incomplete, re-downloading...`;
whisperStatusEl.style.color = '#ff9800';
} else if (progress.status === 'loading_model') {
whisperStatusEl.textContent = `⏳ Loading ${progress.model}...`;
whisperStatusEl.style.color = '#ffc107';
} else if (progress.status === 'model_loaded') {
whisperStatusEl.textContent = `Ready`;
whisperStatusEl.textContent = `Model ready`;
whisperStatusEl.style.color = '#28a745';
// Trigger a status refresh
updateWhisperStatus();
} else if (progress.status === 'model_error') {
whisperStatusEl.textContent = `❌ Error: ${progress.error || 'Model load failed'}`;
whisperStatusEl.style.color = '#dc3545';
}
});