Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(transcription): stop the background pass transcribing music
EtienneLescot80e716dad0a7
diff --git a/src/lib/ai-edition/store/transcriptionStore.ts b/src/lib/ai-edition/store/transcriptionStore.tsindex 4e55bca3e..19aeff9b6 100644--- a/src/lib/ai-edition/store/transcriptionStore.ts+++ b/src/lib/ai-edition/store/transcriptionStore.ts@@ -30,6 +30,7 @@ import { transcribeAsset, withTranscript } from "../document/transcribe";import type { AxcutDocument } from "../schema";import {type AssetTranscriptionView,+ assetCanCarrySpeech,classifyTranscriptionError,deriveAssetStatus,findAssetTranscript,@@ -130,6 +131,10 @@ export const useTranscriptionStore = create<TranscriptionState>((set, get) => ({if (jobs[asset.id]) continue;if (findAssetTranscript(document, asset.id)) continue;if (asset.transcriptionFailure) continue;+ // Music is not speech, and finding that out costs a whole inference pass —+ // 35s at editor open for a four-minute bed. The manual regenerate in the+ // media stage stays available for anything this refuses.+ if (!assetCanCarrySpeech(document, asset.id)) continue;patch()[asset.id] = { status: "queued", language: "auto", manual: false };}}diff --git a/src/lib/ai-edition/transcription/status.test.ts b/src/lib/ai-edition/transcription/status.test.tsindex 9b4ff7c31..d453936bf 100644--- a/src/lib/ai-edition/transcription/status.test.ts+++ b/src/lib/ai-edition/transcription/status.test.ts@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";import type { AxcutDocument, AxcutTranscript } from "../schema";import {type AssetTranscriptionView,+ assetCanCarrySpeech,classifyTranscriptionError,deriveAssetStatus,firstBusyView,@@ -394,3 +395,54 @@ describe("deriveAssetStatus carries the engine's own report", () => {expect(derived.rtf).toBeUndefined();});});++describe("assetCanCarrySpeech", () => {+ /** A document with one video asset and one imported audio asset. */+ const doc = (audioTracks: Array<Record<string, unknown>>) =>+ ({+ assets: [+ { id: "vid", kind: "video" },+ { id: "aud", kind: "audio" },+ ],+ audioTracks,+ }) as unknown as Parameters<typeof assetCanCarrySpeech>[0];++ const track = (kind: "voiceover" | "music", assetId = "aud") => ({+ id: `t_${kind}`,+ assetId,+ kind,+ });++ it("says yes to footage without consulting the timeline", () => {+ // Video is the case that always carried speech; the guard must not regress it.+ expect(assetCanCarrySpeech(doc([]), "vid")).toBe(true);+ });++ it("says yes to an audio asset played on a voiceover lane", () => {+ expect(assetCanCarrySpeech(doc([track("voiceover")]), "aud")).toBe(true);+ });++ it("says no to a music bed", () => {+ // The whole point: 35s of inference at editor open, to transcribe music.+ expect(assetCanCarrySpeech(doc([track("music")]), "aud")).toBe(false);+ });++ it("says yes when the same file is on both lanes", () => {+ // One voiceover placement is enough — the file demonstrably carries speech,+ // whatever else it is also used for.+ expect(assetCanCarrySpeech(doc([track("music"), track("voiceover")]), "aud")).toBe(true);+ });++ it("says no to an audio asset no region plays", () => {+ // Nothing is asking for it, so nothing should pay for it.+ expect(assetCanCarrySpeech(doc([]), "aud")).toBe(false);+ });++ it("ignores regions playing a different file", () => {+ expect(assetCanCarrySpeech(doc([track("voiceover", "other")]), "aud")).toBe(false);+ });++ it("says no to an asset that is not in the document", () => {+ expect(assetCanCarrySpeech(doc([]), "ghost")).toBe(false);+ });+});diff --git a/src/lib/ai-edition/transcription/status.ts b/src/lib/ai-edition/transcription/status.tsindex 8bc98b489..941f8a132 100644--- a/src/lib/ai-edition/transcription/status.ts+++ b/src/lib/ai-edition/transcription/status.ts@@ -314,6 +314,38 @@ export function resolveTranscriptGate(views: AssetTranscriptionView[]): Transcri* make it look ready when the clip on screen has no transcript. Falls back to* the whole bin while the timeline is still empty.*/+/**+ * Can this asset plausibly carry speech?+ *+ * The background pass transcribes every asset in the document, which was harmless+ * while every asset was footage. Imported audio broke that: a music bed is speech to+ * nobody, and whisper spends real time discovering it. Measured on a four-minute bed:+ * 35s of GPU inference at editor open, for 164 segments of transcribed music.+ *+ * "Can carry speech" is NOT a property of the asset — `AxcutAsset.kind` only knows+ * `video | audio`. The voiceover/music distinction lives on the TRACK, so the question+ * is answered from the timeline: an audio asset qualifies exactly when some track+ * playing it sits on the voiceover lane.+ *+ * Stable under a lane change, which matters because the track's `kind` is editable:+ *+ * - music -> voiceover queues it, which is right: it is speech now.+ * - voiceover -> music discards nothing. The transcript already exists, and the+ * caller skips an asset that has one, so the round trip is lossless rather than+ * paid for twice.+ *+ * An audio asset no track plays is not transcribed either: nothing is asking for it.+ * See issue #560, where this rule was settled.+ */+export function assetCanCarrySpeech(document: AxcutDocument, assetId: string): boolean {+ const asset = document.assets.find((a) => a.id === assetId);+ if (!asset) return false;+ if (asset.kind !== "audio") return true;+ return document.audioTracks.some(+ (track) => track.assetId === assetId && track.kind === "voiceover",+ );+}+export function transcriptRelevantAssetIds(document: AxcutDocument | null): string[] {if (!document) return [];const onTimeline: string[] = [];