Skip to content

Commit 73827d7

Browse files
committed
fix(mcp): caption a transcript only the legacy mirror holds, say transcribe waits for a same-language run
Part of #1180
1 parent 2d0082a commit 73827d7

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎electron/mcp/openscreen-mcp-server.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ const transcribeArgs = z.object({
194194
});
195195

196196
const TRANSCRIBE_DESCRIPTION =
197-
"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.";
197+
"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.";
198198

199199
const TRANSCRIBE_NOTE =
200200
"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.";

‎src/cli/captionProject.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ describe("captionProject", () => {
9696
expect(result.document.annotations).toEqual([]);
9797
});
9898

99+
it("copies a transcript only the legacy mirror holds where the captions read it", async () => {
100+
const legacy = { ...project(), transcript: transcript("one two"), transcripts: [] };
101+
const result = await captionProject(legacy, LINE, vi.fn());
102+
103+
expect(result.document.transcripts).toHaveLength(1);
104+
expect(result.captionCount).toBe(1);
105+
});
106+
99107
it("fails on media with no speech, writing nothing", async () => {
100108
const silent: AxcutTranscript = {
101109
assetId: "asset_1",

‎src/cli/captionProject.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ export async function captionProject(
3333
if (!transcriptHasSpeech(transcript)) {
3434
throw new Error("No speech detected in the project's audio");
3535
}
36-
const transcribed = existing ? document : applyTranscriptionResult(document, transcript).document;
36+
// A transcript only in the legacy `transcript` mirror is copied into `transcripts`, which the
37+
// captions read.
38+
const stored = document.transcripts.some((t) => t.assetId === assetId);
39+
const transcribed = stored ? document : applyTranscriptionResult(document, transcript).document;
3740
// The v1 caption annotations this command used to write: the Captions pane offers to
3841
// clear them, and next to real captions they would show every line twice.
3942
const cleared: AxcutDocument = {

0 commit comments

Comments
 (0)