From b04b2e54f79e86838f16c449b58893985348be4b Mon Sep 17 00:00:00 2001 From: seclusionenthusiast <117418352+seclusionenthusiast@users.noreply.github.com> Date: Tue, 3 Mar 2026 22:27:53 +0900 Subject: [PATCH] Updated speaker keys for diarized lyrics. --- backend/routers/projects.py | 20 +++++++++-- backend/static/index.html | 4 +-- frontend/src/components/LyricsLivePreview.tsx | 34 ++++++++++++++++--- frontend/src/pages/ProjectDetail.tsx | 24 ++++++++++--- frontend/src/pages/Settings.tsx | 25 +++++++------- 5 files changed, 82 insertions(+), 25 deletions(-) diff --git a/backend/routers/projects.py b/backend/routers/projects.py index 472381d..909379e 100755 --- a/backend/routers/projects.py +++ b/backend/routers/projects.py @@ -185,13 +185,29 @@ def delete_project(project_id: str): if upload_dir.exists(): shutil.rmtree(upload_dir, ignore_errors=True) + # Collect all job IDs associated with this project so they don't get + # re-adopted by list_projects() on the next poll cycle. + job_ids_to_delete = {project["sep_job_id"]} + for jid in (project.get("trans_jobs") or {}).values(): + job_ids_to_delete.add(jid) + for jid in (project.get("abc_jobs") or {}).values(): + job_ids_to_delete.add(jid) + for jid in (project.get("lrc_jobs") or {}).values(): + job_ids_to_delete.add(jid) + if project.get("mix_job_id"): + job_ids_to_delete.add(project["mix_job_id"]) + from sqlalchemy.orm import Session - from ..job_manager import engine, ProjectRecord + from ..job_manager import engine, ProjectRecord, JobRecord with Session(engine) as session: record = session.get(ProjectRecord, project_id) if record: session.delete(record) - session.commit() + for jid in job_ids_to_delete: + job_record = session.get(JobRecord, jid) + if job_record: + session.delete(job_record) + session.commit() return {"detail": "Project deleted"} diff --git a/backend/static/index.html b/backend/static/index.html index 40461d1..29787bd 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -19,8 +19,8 @@ - - + +
diff --git a/frontend/src/components/LyricsLivePreview.tsx b/frontend/src/components/LyricsLivePreview.tsx index 766ae34..d85d8f3 100755 --- a/frontend/src/components/LyricsLivePreview.tsx +++ b/frontend/src/components/LyricsLivePreview.tsx @@ -34,6 +34,8 @@ interface Props { styleOptions?: Partial defaultStyle?: LyricsVisualStyle onLrcChange?: (newLrc: string) => void + /** Stable key used to persist speaker names/colours in localStorage. */ + storageKey?: string } // ─── Visual style definitions ───────────────────────────────────────────────── @@ -459,7 +461,7 @@ function LrcEditor({ // ─── Main component ─────────────────────────────────────────────────────────── -export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, styleOptions, defaultStyle, onLrcChange }: Props) { +export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, styleOptions, defaultStyle, onLrcChange, storageKey }: Props) { // Internal lrc override from editor const [editedLrc, setEditedLrc] = useState(null) const activeLrc = editedLrc ?? lrcText @@ -503,9 +505,21 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty const [soloedStems, setSoloedStems] = useState>({}) // User-overrideable speaker colours (keyed by speaker ID e.g. "SPEAKER_00") - const [speakerColors, setSpeakerColors] = useState>({}) + const [speakerColors, setSpeakerColors] = useState>(() => { + if (!storageKey) return {} + try { + const raw = localStorage.getItem(`stemengine-spk-${storageKey}`) + return raw ? (JSON.parse(raw).colors ?? {}) : {} + } catch { return {} } + }) // User-editable speaker display names (keyed by speaker ID) - const [speakerNames, setSpeakerNames] = useState>({}) + const [speakerNames, setSpeakerNames] = useState>(() => { + if (!storageKey) return {} + try { + const raw = localStorage.getItem(`stemengine-spk-${storageKey}`) + return raw ? (JSON.parse(raw).names ?? {}) : {} + } catch { return {} } + }) /** Returns the speaker colour: user override first, then auto-palette. */ function getSpeakerColor(speakerId: string): string { @@ -608,6 +622,14 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty setEditedLrc(null) }, [lrcText]) + // ── Persist speaker names and colours to localStorage ───────────────────── + useEffect(() => { + if (!storageKey) return + try { + localStorage.setItem(`stemengine-spk-${storageKey}`, JSON.stringify({ names: speakerNames, colors: speakerColors })) + } catch { /* ignore quota errors */ } + }, [storageKey, speakerNames, speakerColors]) + // ── Duration from last lyric line when no audio ─────────────────────────── useEffect(() => { if (!audioUrl && !isMultiStem && lines.length > 0) { @@ -1296,7 +1318,11 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty )}