Updated speaker keys for diarized lyrics.
This commit is contained in:
1 parent
eb4d0356f6
commit
b04b2e54f7
5 files changed
+82
-25
No files matched your search
@@ -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"}
|
||||
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
<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-C-wBpkte.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-Bnj-3oQ_.css">
|
||||
<script type="module" crossorigin src="/assets/index-DCENRxjR.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-BWSEN_1A.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -34,6 +34,8 @@ interface Props {
|
||||
styleOptions?: Partial<LyricsStyleOptions>
|
||||
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<string | null>(null)
|
||||
const activeLrc = editedLrc ?? lrcText
|
||||
@@ -503,9 +505,21 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty
|
||||
const [soloedStems, setSoloedStems] = useState<Record<string, boolean>>({})
|
||||
|
||||
// User-overrideable speaker colours (keyed by speaker ID e.g. "SPEAKER_00")
|
||||
const [speakerColors, setSpeakerColors] = useState<Record<string, string>>({})
|
||||
const [speakerColors, setSpeakerColors] = useState<Record<string, string>>(() => {
|
||||
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<Record<string, string>>({})
|
||||
const [speakerNames, setSpeakerNames] = useState<Record<string, string>>(() => {
|
||||
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
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
onClick={() => { setSpeakerColors({}); setSpeakerNames({}) }}
|
||||
onClick={() => {
|
||||
setSpeakerColors({})
|
||||
setSpeakerNames({})
|
||||
if (storageKey) localStorage.removeItem(`stemengine-spk-${storageKey}`)
|
||||
}}
|
||||
className="ml-auto text-[10px] text-slate-500 hover:text-slate-300 transition-colors"
|
||||
title="Reset speaker colours and names to defaults"
|
||||
>
|
||||
|
||||
@@ -1028,12 +1028,13 @@ const WHISPER_LANGS = [
|
||||
{ id: 'hi', label: 'Hindi' },
|
||||
]
|
||||
|
||||
function LrcPreview({ file, jobId, originalAudioUrl, stems, title }: {
|
||||
function LrcPreview({ file, jobId, originalAudioUrl, stems, title, storageKey }: {
|
||||
file: JobFile
|
||||
jobId: string
|
||||
originalAudioUrl?: string
|
||||
stems?: { name: string; label: string; url: string }[]
|
||||
title?: string
|
||||
storageKey?: string
|
||||
}) {
|
||||
const [open, setOpen] = useState(false)
|
||||
const [text, setText] = useState<string | null>(null)
|
||||
@@ -1091,6 +1092,7 @@ function LrcPreview({ file, jobId, originalAudioUrl, stems, title }: {
|
||||
stems={stems && stems.length > 0 ? stems : undefined}
|
||||
audioUrl={(!stems || stems.length === 0) ? originalAudioUrl : undefined}
|
||||
title={title}
|
||||
storageKey={storageKey}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
@@ -1181,7 +1183,12 @@ function StemLyricsRow({
|
||||
// Speaker diarization data from the transcription JSON
|
||||
type TxSeg = { text: string; start: number; end: number; speaker?: string }
|
||||
const [transcriptSegs, setTranscriptSegs] = useState<TxSeg[] | null>(null)
|
||||
const [speakerNames, setSpeakerNames] = useState<Record<string, string>>({})
|
||||
const [speakerNames, setSpeakerNames] = useState<Record<string, string>>(() => {
|
||||
try {
|
||||
const raw = localStorage.getItem(`stemengine-tx-spk-${projectId}-${stemName}`)
|
||||
return raw ? JSON.parse(raw) : {}
|
||||
} catch { return {} }
|
||||
})
|
||||
|
||||
// Auto-fetch the .txt + .json files when a lyric-transcribe job finishes
|
||||
useEffect(() => {
|
||||
@@ -1203,7 +1210,7 @@ function StemLyricsRow({
|
||||
const ids = [...new Set<string>(
|
||||
json.segments.map((s: TxSeg) => s.speaker).filter(Boolean) as string[]
|
||||
)]
|
||||
if (ids.length) setSpeakerNames(Object.fromEntries(ids.map((id) => [id, ''])))
|
||||
if (ids.length) setSpeakerNames(prev => Object.fromEntries(ids.map((id) => [id, prev[id] ?? ''])))
|
||||
}
|
||||
})
|
||||
.catch(() => {})
|
||||
@@ -1216,9 +1223,18 @@ function StemLyricsRow({
|
||||
setTranscriptText(null)
|
||||
setTranscriptSegs(null)
|
||||
setSpeakerNames({})
|
||||
try { localStorage.removeItem(`stemengine-tx-spk-${projectId}-${stemName}`) } catch { /* ignore */ }
|
||||
}
|
||||
}, [whisperJob?.id, whisperJob?.status])
|
||||
|
||||
// ── Persist transcription speaker names ───────────────────────────────────
|
||||
useEffect(() => {
|
||||
if (!Object.keys(speakerNames).length) return
|
||||
try {
|
||||
localStorage.setItem(`stemengine-tx-spk-${projectId}-${stemName}`, JSON.stringify(speakerNames))
|
||||
} catch { /* ignore */ }
|
||||
}, [projectId, stemName, speakerNames])
|
||||
|
||||
// Helpers for speaker display
|
||||
const uniqueSpeakers = transcriptSegs
|
||||
? [...new Set<string>(transcriptSegs.map((s) => s.speaker).filter(Boolean) as string[])]
|
||||
@@ -1385,7 +1401,7 @@ function StemLyricsRow({
|
||||
{activeJob.files
|
||||
.filter((f) => f.name.endsWith('.elrc') || f.name.endsWith('.lrc'))
|
||||
.map((f) => (
|
||||
<LrcPreview key={f.name} file={f} jobId={activeJob.id} originalAudioUrl={originalAudioUrl} stems={stems} title={projectName} />
|
||||
<LrcPreview key={f.name} file={f} jobId={activeJob.id} originalAudioUrl={originalAudioUrl} stems={stems} title={projectName} storageKey={`${activeJob.id}-${f.name}`} />
|
||||
))}
|
||||
{/* Inline transcript display for lyric-transcribe jobs */}
|
||||
{activeJob.job_type === 'lyric-transcribe' && (
|
||||
|
||||
@@ -665,7 +665,7 @@ function ModelDownloader() {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between pb-4 border-b border-slate-200 dark:border-gray-700">
|
||||
<div className="pb-4 border-b border-slate-200 dark:border-gray-700">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="p-2 bg-purple-100 dark:bg-purple-900/30 rounded-lg">
|
||||
<HardDrive className="w-5 h-5 text-purple-600 dark:text-purple-400" />
|
||||
@@ -675,18 +675,17 @@ function ModelDownloader() {
|
||||
<p className="text-sm text-slate-500 dark:text-gray-400">
|
||||
Download and manage AI models for audio separation
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Stats */}
|
||||
<div className="flex items-center gap-4 text-sm">
|
||||
<div className="px-3 py-1.5 bg-slate-100 dark:bg-gray-800 rounded-lg">
|
||||
<span className="text-slate-500 dark:text-gray-400">Downloaded:</span>{' '}
|
||||
<span className="font-medium text-slate-700 dark:text-gray-200">{downloadedModels}/{totalModels}</span>
|
||||
</div>
|
||||
<div className="px-3 py-1.5 bg-slate-100 dark:bg-gray-800 rounded-lg">
|
||||
<span className="text-slate-500 dark:text-gray-400">Disk Usage:</span>{' '}
|
||||
<span className="font-medium text-slate-700 dark:text-gray-200">{totalSize.toFixed(0)} MB</span>
|
||||
{/* Stats */}
|
||||
<div className="flex items-center gap-3 mt-1.5 text-sm">
|
||||
<div className="px-3 py-1 bg-slate-100 dark:bg-gray-800 rounded-lg">
|
||||
<span className="text-slate-500 dark:text-gray-400">Downloaded:</span>{' '}
|
||||
<span className="font-medium text-slate-700 dark:text-gray-200">{downloadedModels}/{totalModels}</span>
|
||||
</div>
|
||||
<div className="px-3 py-1 bg-slate-100 dark:bg-gray-800 rounded-lg">
|
||||
<span className="text-slate-500 dark:text-gray-400">Disk Usage:</span>{' '}
|
||||
<span className="font-medium text-slate-700 dark:text-gray-200">{totalSize.toFixed(0)} MB</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user