Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(mcp): caption a transcript only the legacy mirror holds, say transcribe waits for a same-language run

EtienneLescotd0de1b2e3e5a
diff --git a/electron/mcp/openscreen-mcp-server.ts b/electron/mcp/openscreen-mcp-server.ts
index 59adac7f7..169a7482f 100644
--- a/electron/mcp/openscreen-mcp-server.ts
+++ b/electron/mcp/openscreen-mcp-server.ts
@@ -194,7 +194,7 @@ const transcribeArgs = z.object({
});
const TRANSCRIBE_DESCRIPTION =
- "Transcribe one asset's speech with OpenScreen's on-device Whisper, as the editor does when it opens a project, and store the transcript in the project: getTranscript, getTranscriptWords, setWordText, removeWords and the captions all read it. A take from stopRecording has none until this runs. Without `language`, an asset that already has a transcript keeps it, and a transcription the editor is already running is waited for rather than run twice; with `language`, the asset is transcribed again in it, and the word corrections that still match are carried over. The project's vocabulary (setVocabulary) primes Whisper. It runs on this computer and can take minutes on a long recording, more the first time, when the speech model downloads. Media with no audio fails with failure.kind `no-audio`, which the asset then remembers (assets[].transcriptionFailure in getCurrentDocument). The result gives the language and the word count; it needs no checkpoint, and restoreCheckpoint keeps a transcript made after its checkpoint.";
+ "Transcribe one asset's speech with OpenScreen's on-device Whisper, as the editor does when it opens a project, and store the transcript in the project: getTranscript, getTranscriptWords, setWordText, removeWords and the captions all read it. A take from stopRecording has none until this runs. Without `language`, an asset that already has a transcript keeps it, and a transcription the editor is already running is waited for rather than run twice; with `language`, the asset is transcribed again in it (a run of the editor already in that language is waited for instead), and the word corrections that still match are carried over. The project's vocabulary (setVocabulary) primes Whisper. It runs on this computer and can take minutes on a long recording, more the first time, when the speech model downloads. Media with no audio fails with failure.kind `no-audio`, which the asset then remembers (assets[].transcriptionFailure in getCurrentDocument). The result gives the language and the word count; it needs no checkpoint, and restoreCheckpoint keeps a transcript made after its checkpoint.";
const TRANSCRIBE_NOTE =
"Speech: transcribe makes an asset's transcript with OpenScreen's on-device Whisper. Everything that reads speech needs it (getTranscript, getTranscriptWords, removeWords, the captions); a fresh take has none until you call it.";
diff --git a/src/cli/captionProject.test.ts b/src/cli/captionProject.test.ts
index a7f09f032..44bd28038 100644
--- a/src/cli/captionProject.test.ts
+++ b/src/cli/captionProject.test.ts
@@ -96,6 +96,14 @@ describe("captionProject", () => {
expect(result.document.annotations).toEqual([]);
});
+ it("copies a transcript only the legacy mirror holds where the captions read it", async () => {
+ const legacy = { ...project(), transcript: transcript("one two"), transcripts: [] };
+ const result = await captionProject(legacy, LINE, vi.fn());
+
+ expect(result.document.transcripts).toHaveLength(1);
+ expect(result.captionCount).toBe(1);
+ });
+
it("fails on media with no speech, writing nothing", async () => {
const silent: AxcutTranscript = {
assetId: "asset_1",
diff --git a/src/cli/captionProject.ts b/src/cli/captionProject.ts
index 44ac48042..e7daac316 100644
--- a/src/cli/captionProject.ts
+++ b/src/cli/captionProject.ts
@@ -33,7 +33,10 @@ export async function captionProject(
if (!transcriptHasSpeech(transcript)) {
throw new Error("No speech detected in the project's audio");
}
- const transcribed = existing ? document : applyTranscriptionResult(document, transcript).document;
+ // A transcript only in the legacy `transcript` mirror is copied into `transcripts`, which the
+ // captions read.
+ const stored = document.transcripts.some((t) => t.assetId === assetId);
+ const transcribed = stored ? document : applyTranscriptionResult(document, transcript).document;
// The v1 caption annotations this command used to write: the Captions pane offers to
// clear them, and next to real captions they would show every line twice.
const cleared: AxcutDocument = {