# Sing Detect — project context for Claude This file is auto-loaded each session and travels with the folder, so it stays valid even after the folder is renamed (`stream-studio` → `sing_detect_v2`). ## What this project is A Windows desktop app (**Tauri 2**: Rust backend + TypeScript/WebView2 UI) that **detects singing segments** in stream recordings and exports editor markers (EDL / markers CSV / CSV / JSON). It is the **detection-only** spin-off of the former "Stream Studio"; the video-concat feature was split into a **separate project** (`video_concat_v5`, since moved out of this folder). - Crate: `sing-detect` / lib `sing_detect_lib`. Product: **Sing Detect**. - Detection runs a **Python 3.10 sidecar** (`sidecar/detect.py`, inaSpeechSegmenter + TensorFlow). ffmpeg extracts a 16 kHz WAV first. ## Build / run (Windows) - `dev.bat` — hot-reload dev. - `build.bat` — MSI installer → `src-tauri\target\release\bundle\msi\`. - `pack.bat` — **standalone portable** folder → `dist-portable\SingDetect\` (bundles `Sing Detect.exe` + ffmpeg/ffprobe + the Python `sidecar/`). - Requirements on the build machine: Node, Rust (`winget install Rustlang.Rustup`), VS 2022 C++ tools, ffmpeg at `C:\ffmpeg\bin` (or on PATH). ## ⚠️ State left by the rename (READ FIRST if a build fails) - `src-tauri\target\` and `src-tauri\gen\` were **intentionally deleted** before the folder rename, because cargo bakes absolute paths into `target\` and a build under the old path name fails with `os error 3 (系统找不到指定的路径)` referencing the old folder. **The first build after rename is a full ~5–8 min recompile** — this is expected, not an error. - `node_modules\` and `dist-portable\SingDetect\` were kept (relocatable / self-contained). The existing `Sing Detect.exe` in `dist-portable\` works regardless of the folder name. - Do **not** keep `target\` in a Nextcloud-synced location — it re-introduces the stale-absolute-path build failure across machines. ## Detection environment (per-machine) - Needs **Python 3.10** (TensorFlow has no 3.12+ support). The app's in-UI **"Test detection engine"** button checks the env and auto-installs the ML packages + downloads the model on first run (or run `sidecar\setup_sidecar.bat`). - Setup uses **default international PyPI** and does no proxy manipulation — pip and the model download just inherit the system network settings, so a VPN/proxy (e.g. Clash) routes them normally. Keep pip reasonably current: the very old pip 21.2.3 bundled with Python **3.10.0** crashes through an HTTP proxy (`check_hostname requires server_hostname`); installing **Python 3.10.11** (ships a modern pip) or running `py -3.10 -m pip install -U pip` once avoids it. ## Notable backend behavior - Long ops (`detect_songs`, `setup_detection`, `export_segments`) run via `spawn_blocking` so the window stays responsive (not "未响应"). - `cancel` kills the whole **process tree** (`taskkill /F /T`), because `py -3.10` spawns `python.exe` as a child — killing only `py` left it running.