Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apps/server/src/textGeneration/TranscriptionPostProcessing.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import { DEFAULT_SPEECH_POST_PROCESSING_PROMPT } from "@t3tools/contracts";
import { describe, expect, it } from "vite-plus/test";

import { buildTranscriptionPostProcessingPrompt } from "./TranscriptionPostProcessing.ts";

describe("buildTranscriptionPostProcessingPrompt", () => {
it.each([
{ mode: "default", instructions: DEFAULT_SPEECH_POST_PROCESSING_PROMPT },
{ mode: "custom", instructions: "Clean up my dictation." },
])("requires the structured transcription reply with $mode instructions", ({ instructions }) => {
const prompt = buildTranscriptionPostProcessingPrompt(instructions, "hello world", {
text: "",
selection: { start: 0, end: 0 },
});
expect(prompt).toContain(
'Return a JSON object with one key, "transcription", holding the cleaned transcript.',
);
});

it("names the correction cue only when the person set one", () => {
const draft = { text: "Make it 42.", selection: { start: 11, end: 11 } };
const plain = buildTranscriptionPostProcessingPrompt("Clean.", "sorry 24", draft);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function buildTranscriptionPostProcessingPrompt(
${transcript}
</transcript>

${placement} Use the composer draft and insertion position to resolve ambiguity and correct likely recognition errors in the transcript. The draft can clarify the topic, references, terminology, and how the new speech fits with nearby text. Prefer an interpretation supported by the draft when the speech plausibly matches it. Do not invent content, change clear speech, or include existing composer text in the result. Return only the cleaned transcript.
${placement} Use the composer draft and insertion position to resolve ambiguity and correct likely recognition errors in the transcript. The draft can clarify the topic, references, terminology, and how the new speech fits with nearby text. Prefer an interpretation supported by the draft when the speech plausibly matches it. Do not invent content, change clear speech, or include existing composer text in the result. Return only the cleaned transcript. Return a JSON object with one key, "transcription", holding the cleaned transcript.
<composer_before>
${draft.text.slice(0, cursor)}
</composer_before>${selectionBlock}
Expand Down
Loading