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
feat(transcription): per-project names and terms for Whisper
EtienneLescot13db77e5b822
diff --git a/electron/stt/index.test.ts b/electron/stt/index.test.tsindex c5af87fe9..02a071a42 100644--- a/electron/stt/index.test.ts+++ b/electron/stt/index.test.ts@@ -331,6 +331,15 @@ describe("SttManager", () => {expect(languages.slice(1).every((l) => l === "en")).toBe(true);});+ it("hands the names and terms to every chunk, not only the first", async () => {+ const mgr = new SttManager();+ await mgr.init({ modelsBaseDir: "/tmp/fake-stt-models" });+ await mgr.transcribe({ samples: new Float32Array(200 * 16000), prompt: "OpenScreen, Vulkan" });+ const prompts = fakeWhisperServer.transcribe.mock.calls.map(([req]) => req.prompt);+ expect(prompts.length).toBeGreaterThan(1);+ expect(prompts.every((p) => p === "OpenScreen, Vulkan")).toBe(true);+ });+it("retries a failed chunk instead of losing the whole transcription", async () => {fakeWhisperServer.transcribe.mockRejectedValueOnce(new Error("helper died")).mockResolvedValue({segments: [{ text: "hello", startSec: 0, endSec: 0.5 }],diff --git a/electron/stt/index.ts b/electron/stt/index.tsindex 11c760f0b..7a536409b 100644--- a/electron/stt/index.ts+++ b/electron/stt/index.ts@@ -291,12 +291,18 @@ export class SttManager {private async transcribeChunk(samples: Float32Array,language: string | undefined,+ prompt: string | undefined,): Promise<Awaited<ReturnType<WhisperServerManager["transcribe"]>>> {let lastError: unknown;for (let attempt = 1; attempt <= CHUNK_ATTEMPTS; attempt++) {if (this.shuttingDown) throw cancelledError();try {- return await this.server.transcribe({ samples, language, alignerFor: this.alignerFor });+ return await this.server.transcribe({+ samples,+ language,+ prompt,+ alignerFor: this.alignerFor,+ });} catch (error) {lastError = error;if (this.shuttingDown) throw cancelledError();@@ -387,6 +393,7 @@ export class SttManager {const result = await this.transcribeChunk(samples.subarray(chunk.startSample, chunk.endSample),language,+ req.prompt,).catch((error) => {if (error instanceof Error && error.name === "AbortError") throw error;// Say where it died. Without this the user gets "Transcriptiondiff --git a/electron/stt/transcriptionContract.ts b/electron/stt/transcriptionContract.tsindex 4a2563a78..d30181487 100644--- a/electron/stt/transcriptionContract.ts+++ b/electron/stt/transcriptionContract.ts@@ -129,6 +129,11 @@ export interface SttTranscribeRequest {* The spec locks language detection on by default; we only honour an explicit value.*/language?: string;+ /**+ * The project's names and terms (issue #1023), handed to Whisper as its+ * initial prompt on every chunk. Omit or leave blank for none.+ */+ prompt?: string;}/**diff --git a/electron/stt/whisperServer.test.ts b/electron/stt/whisperServer.test.tsindex 773235577..1d66e0f06 100644--- a/electron/stt/whisperServer.test.ts+++ b/electron/stt/whisperServer.test.ts@@ -255,7 +255,11 @@ describe("WhisperServerManager", () => {});describe("WhisperServerManager language normalization", () => {- function captureFormField(language: string | undefined): Promise<string | null> {+ function captureFormField(+ language: string | undefined,+ prompt?: string,+ field = "language",+ ): Promise<string | null> {return new Promise((resolve, reject) => {let resolvedText: string | null = null;const fakeJson = {@@ -268,7 +272,7 @@ describe("WhisperServerManager", () => {vi.fn(async (_url: string, init: RequestInit) => {const body = init?.body as FormData | undefined;if (body && typeof (body as FormData).get === "function") {- resolvedText = (body as FormData).get("language") as string | null;+ resolvedText = (body as FormData).get(field) as string | null;}return new Response(JSON.stringify(fakeJson), { status: 200 });}),@@ -281,6 +285,7 @@ describe("WhisperServerManager", () => {await mgr.transcribe({samples: new Float32Array(1600),language,+ prompt,});resolve(resolvedText);} catch (e) {@@ -305,6 +310,16 @@ describe("WhisperServerManager", () => {expect(sent).toBe("fr");});+ it("sends the project's names and terms as the prompt field, trimmed", async () => {+ const sent = await captureFormField("auto", " OpenScreen, whisper.cpp \n", "prompt");+ expect(sent).toBe("OpenScreen, whisper.cpp");+ });++ it("sends no prompt field when the names and terms are blank", async () => {+ expect(await captureFormField("auto", undefined, "prompt")).toBeNull();+ expect(await captureFormField("auto", " ", "prompt")).toBeNull();+ });+afterEach(() => {vi.unstubAllGlobals();});diff --git a/electron/stt/whisperServer.ts b/electron/stt/whisperServer.tsindex 2543a79bb..a1065fecd 100644--- a/electron/stt/whisperServer.ts+++ b/electron/stt/whisperServer.ts@@ -85,6 +85,8 @@ export interface WhisperServerStatus {export interface TranscribeOptions {samples: Float32Array;language?: string;+ /** Names and terms to bias the decode toward (whisper's initial prompt). */+ prompt?: string;/** The aligner model for a language, or null for none (see `transcribe`). */alignerFor?: (language: string) => Promise<string | null>;}@@ -484,6 +486,7 @@ export class WhisperServerManager {private async runMultipartInfer(opts: {wavPath: string;language?: string;+ prompt?: string;}): Promise<WhisperJsonResponse> {await this.ensureReady();const url = `${this.baseUrl()}/inference`;@@ -493,6 +496,8 @@ export class WhisperServerManager {form.set("file", blob, path.basename(opts.wavPath));form.set("response_format", "verbose_json");form.set("language", opts.language && opts.language !== "auto" ? opts.language : "auto");+ const prompt = opts.prompt?.trim();+ if (prompt) form.set("prompt", prompt);let res: Response;try {res = await fetch(url, {@@ -612,7 +617,11 @@ export class WhisperServerManager {}> {const wavPath = await writeSamplesAsWav(opts.samples);try {- const json = await this.runMultipartInfer({ wavPath, language: opts.language });+ const json = await this.runMultipartInfer({+ wavPath,+ language: opts.language,+ prompt: opts.prompt,+ });const raw = json.segments ?? [];const segments: SttPhraseSegment[] = raw.map((seg) => {diff --git a/src/components/ai-edition/v4/MediaStage.test.ts b/src/components/ai-edition/v4/MediaStage.test.tsindex 6fa306e83..51d9c789e 100644--- a/src/components/ai-edition/v4/MediaStage.test.ts+++ b/src/components/ai-edition/v4/MediaStage.test.ts@@ -1,6 +1,15 @@import { describe, expect, it, vi } from "vitest";-import type { AxcutTranscript } from "@/lib/ai-edition/schema";-import { addSelectedAssetToTimeline, detectedLanguageForTranscript } from "./MediaStage";+import {+ type AxcutTranscript,+ createEmptyDocument,+ parseDocumentFile,+} from "@/lib/ai-edition/schema";+import {+ addSelectedAssetToTimeline,+ detectedLanguageForTranscript,+ VOCABULARY_MAX_CHARS,+ withVocabulary,+} from "./MediaStage";function transcript(language: string, text = ""): AxcutTranscript {return {@@ -85,3 +94,30 @@ describe("addSelectedAssetToTimeline", () => {expect(onSuccess).not.toHaveBeenCalled();});});++describe("withVocabulary", () => {+ const empty = createEmptyDocument({ projectId: "p1", title: "Demo" });++ it("stores the trimmed names and terms on the project, and they survive a save", () => {+ const next = withVocabulary(empty, " OpenScreen, whisper.cpp\n");+ expect(next?.project.vocabulary).toBe("OpenScreen, whisper.cpp");+ const reloaded = parseDocumentFile(JSON.parse(JSON.stringify(next)));+ expect(reloaded.project.vocabulary).toBe("OpenScreen, whisper.cpp");+ });++ it("returns null when nothing changed, so a blur does not add an undo step", () => {+ expect(withVocabulary(empty, " ")).toBeNull();+ const set = withVocabulary(empty, "Vulkan");+ expect(set && withVocabulary(set, "Vulkan ")).toBeNull();+ });++ it("clears the field back to no prompt", () => {+ const set = withVocabulary(empty, "Vulkan");+ expect(set && withVocabulary(set, "")?.project.vocabulary).toBeUndefined();+ });++ it("caps what reaches Whisper", () => {+ const next = withVocabulary(empty, "x".repeat(VOCABULARY_MAX_CHARS + 50));+ expect(next?.project.vocabulary).toHaveLength(VOCABULARY_MAX_CHARS);+ });+});diff --git a/src/components/ai-edition/v4/MediaStage.tsx b/src/components/ai-edition/v4/MediaStage.tsxindex 7b0558084..d370b9ee2 100644--- a/src/components/ai-edition/v4/MediaStage.tsx+++ b/src/components/ai-edition/v4/MediaStage.tsx@@ -3,7 +3,12 @@ import { useMemo, useState } from "react";import { toast } from "sonner";import { Tooltip } from "@/components/ui/tooltip";import { useI18n, useScopedT } from "@/contexts/I18nContext";-import type { AxcutAsset, AxcutTranscript, TranscriptLanguageCode } from "@/lib/ai-edition/schema";+import type {+ AxcutAsset,+ AxcutDocument,+ AxcutTranscript,+ TranscriptLanguageCode,+} from "@/lib/ai-edition/schema";import { useProjectStore } from "@/lib/ai-edition/store/projectStore";import {useAssetTranscriptions,@@ -48,6 +53,19 @@ export function detectedLanguageForTranscript(transcript: AxcutTranscript | nullreturn transcript.language;}+/**+ * Whisper reads at most the last 223 tokens of its prompt; 600 characters of+ * names and terms stays under that for Latin scripts (issue #1023).+ */+export const VOCABULARY_MAX_CHARS = 600;++/** The document with its names and terms set, or null when nothing changed. */+export function withVocabulary(document: AxcutDocument, text: string): AxcutDocument | null {+ const vocabulary = text.trim().slice(0, VOCABULARY_MAX_CHARS) || undefined;+ if (vocabulary === document.project.vocabulary) return null;+ return { ...document, project: { ...document.project, vocabulary } };+}+export async function addSelectedAssetToTimeline(selected: Pick<AxcutAsset, "id" | "label" | "originalPath"> | null,onAddToTimeline: (assetId: string) => Promise<void>,@@ -68,6 +86,7 @@ export function MediaStage({const projectId = useProjectStore((s) => s.projectId);const document = useProjectStore((s) => s.document);const addAsset = useProjectStore((s) => s.addAsset);+ const saveDocument = useProjectStore((s) => s.saveDocument);// Transcripts are produced in the background as soon as a media lands here// (see transcriptionStore) — this stage only reports where each one is at,// and lets the user force a re-run in another language.@@ -388,6 +407,46 @@ export function MediaStage({</p>) : null}+ {/* Project-wide: whisper's initial prompt for every run (issue #1023).+ Uncontrolled and keyed on the saved value, so an undo that restores+ an older list shows it; the save happens on blur, one undo step. */}+ <label style={{ display: "block", marginBottom: 12 }}>+ <span+ style={{+ display: "block",+ fontSize: 12.5,+ fontWeight: 600,+ color: "var(--fg-2)",+ marginBottom: 6,+ }}+ >+ {t("mediaStage.namesAndTerms")}+ </span>+ <textarea+ key={`${document?.project.id}:${document?.project.vocabulary ?? ""}`}+ defaultValue={document?.project.vocabulary ?? ""}+ maxLength={VOCABULARY_MAX_CHARS}+ rows={2}+ spellCheck={false}+ onBlur={(e) => {+ const next = document && withVocabulary(document, e.target.value);+ if (next) void saveDocument(next, { history: true });+ }}+ style={{+ width: "100%",+ padding: "8px 10px",+ borderRadius: 9,+ border: "1px solid var(--border)",+ background: "var(--surface-2)",+ color: "var(--fg)",+ fontSize: 12.5,+ lineHeight: 1.5,+ resize: "vertical",+ outline: "none",+ }}+ />+ </label>+<div style={{ marginBottom: 12 }}><divstyle={{diff --git a/src/i18n/locales/ar/editor.json b/src/i18n/locales/ar/editor.jsonindex 0de8bfa88..95d5cc2dc 100644--- a/src/i18n/locales/ar/editor.json+++ b/src/i18n/locales/ar/editor.json@@ -156,6 +156,7 @@"close": "إغلاق","transcriptReady": "النص جاهز","regenerateAs": "إعادة الإنشاء بلغة",+ "namesAndTerms": "الأسماء والمصطلحات","auto": "تلقائي","regenerate": "إعادة الإنشاء","regenerateTip": "إعادة الإنشاء: تفريغ النص مرة أخرى باللغة المختارة",diff --git a/src/i18n/locales/cs/editor.json b/src/i18n/locales/cs/editor.jsonindex 78ed90f4f..0dacc65ed 100644--- a/src/i18n/locales/cs/editor.json+++ b/src/i18n/locales/cs/editor.json@@ -163,6 +163,7 @@"cpuBackendHint": "Běží na CPU: přibližně 2× pomalejší než na GPU","noTranscript": "Žádný přepis","regenerateAs": "Znovu generovat jako",+ "namesAndTerms": "Jména a pojmy","auto": "Automaticky","regenerate": "Znovu generovat","regenerateTip": "Znovu generovat: znovu přepsat ve zvoleném jazyce",diff --git a/src/i18n/locales/de/editor.json b/src/i18n/locales/de/editor.jsonindex c5bc7453f..9515dbbd9 100644--- a/src/i18n/locales/de/editor.json+++ b/src/i18n/locales/de/editor.json@@ -163,6 +163,7 @@"cpuBackendHint": "Läuft auf der CPU: etwa 2× langsamer als auf der GPU","noTranscript": "Kein Transkript","regenerateAs": "Neu erzeugen als",+ "namesAndTerms": "Namen und Begriffe","auto": "Auto","regenerate": "Neu erzeugen","regenerateTip": "Neu erzeugen: in der gewählten Sprache erneut transkribieren",diff --git a/src/i18n/locales/en/editor.json b/src/i18n/locales/en/editor.jsonindex 8a2073355..da6fc8e33 100644--- a/src/i18n/locales/en/editor.json+++ b/src/i18n/locales/en/editor.json@@ -163,6 +163,7 @@"cpuBackendHint": "Running on the CPU: about 2× slower than on the GPU","noTranscript": "No transcript","regenerateAs": "Regenerate as",+ "namesAndTerms": "Names and terms","auto": "Auto","regenerate": "Regenerate","regenerateTip": "Regenerate: transcribe again in the chosen language",diff --git a/src/i18n/locales/es/editor.json b/src/i18n/locales/es/editor.jsonindex 5640049e7..0b21ba537 100644--- a/src/i18n/locales/es/editor.json+++ b/src/i18n/locales/es/editor.json@@ -156,6 +156,7 @@"close": "Cerrar","transcriptReady": "Transcripción lista","regenerateAs": "Regenerar en",+ "namesAndTerms": "Nombres y términos","auto": "Auto","regenerate": "Regenerar","regenerateTip": "Regenerar: transcribir de nuevo en el idioma elegido",diff --git a/src/i18n/locales/fr/editor.json b/src/i18n/locales/fr/editor.jsonindex e7e0c5bf2..ac7d61cec 100644--- a/src/i18n/locales/fr/editor.json+++ b/src/i18n/locales/fr/editor.json@@ -156,6 +156,7 @@"close": "Fermer","transcriptReady": "Transcription prête","regenerateAs": "Régénérer en",+ "namesAndTerms": "Noms et termes","auto": "Auto","regenerate": "Régénérer","regenerateTip": "Régénérer : transcrire à nouveau dans la langue choisie",diff --git a/src/i18n/locales/it/editor.json b/src/i18n/locales/it/editor.jsonindex cc2116ea3..8646297ad 100644--- a/src/i18n/locales/it/editor.json+++ b/src/i18n/locales/it/editor.json@@ -156,6 +156,7 @@"close": "Chiudi","transcriptReady": "Trascrizione pronta","regenerateAs": "Rigenera in",+ "namesAndTerms": "Nomi e termini","auto": "Auto","regenerate": "Rigenera","regenerateTip": "Rigenera: trascrivi di nuovo nella lingua scelta",diff --git a/src/i18n/locales/ja-JP/editor.json b/src/i18n/locales/ja-JP/editor.jsonindex 2313587b6..9cacf994e 100644--- a/src/i18n/locales/ja-JP/editor.json+++ b/src/i18n/locales/ja-JP/editor.json@@ -156,6 +156,7 @@"close": "閉じる","transcriptReady": "文字起こし完了","regenerateAs": "この言語で再生成",+ "namesAndTerms": "固有名詞と用語","auto": "自動","regenerate": "再生成","regenerateTip": "再生成:選んだ言語でもう一度文字起こしします",diff --git a/src/i18n/locales/ko-KR/editor.json b/src/i18n/locales/ko-KR/editor.jsonindex b75059aa3..f8843a8ae 100644--- a/src/i18n/locales/ko-KR/editor.json+++ b/src/i18n/locales/ko-KR/editor.json@@ -156,6 +156,7 @@"close": "닫기","transcriptReady": "대본 준비 완료","regenerateAs": "다음 언어로 재생성",+ "namesAndTerms": "이름 및 용어","auto": "자동","regenerate": "재생성","regenerateTip": "재생성: 선택한 언어로 다시 받아씁니다",diff --git a/src/i18n/locales/pt-BR/editor.json b/src/i18n/locales/pt-BR/editor.jsonindex 003ea563a..07557b726 100644--- a/src/i18n/locales/pt-BR/editor.json+++ b/src/i18n/locales/pt-BR/editor.json@@ -156,6 +156,7 @@"close": "Fechar","transcriptReady": "Transcrição pronta","regenerateAs": "Regenerar em",+ "namesAndTerms": "Nomes e termos","auto": "Automático","regenerate": "Regenerar","regenerateTip": "Regenerar: transcrever de novo no idioma escolhido",diff --git a/src/i18n/locales/ru/editor.json b/src/i18n/locales/ru/editor.jsonindex 096daf5e7..d0d4487ee 100644--- a/src/i18n/locales/ru/editor.json+++ b/src/i18n/locales/ru/editor.json@@ -156,6 +156,7 @@"close": "Закрыть","transcriptReady": "Транскрипт готов","regenerateAs": "Пересоздать на",+ "namesAndTerms": "Имена и термины","auto": "Авто","regenerate": "Пересоздать","regenerateTip": "Пересоздать: расшифровать заново на выбранном языке",diff --git a/src/i18n/locales/tr/editor.json b/src/i18n/locales/tr/editor.jsonindex f4a76714e..d3277609c 100644--- a/src/i18n/locales/tr/editor.json+++ b/src/i18n/locales/tr/editor.json@@ -156,6 +156,7 @@"close": "Kapat","transcriptReady": "Metin dökümü hazır","regenerateAs": "Şu dilde yeniden oluştur",+ "namesAndTerms": "Adlar ve terimler","auto": "Otomatik","regenerate": "Yeniden oluştur","regenerateTip": "Yeniden oluştur: seçilen dilde yeniden metne dök",diff --git a/src/i18n/locales/vi/editor.json b/src/i18n/locales/vi/editor.jsonindex 1ab9da48c..0d31eb588 100644--- a/src/i18n/locales/vi/editor.json+++ b/src/i18n/locales/vi/editor.json@@ -156,6 +156,7 @@"close": "Đóng","transcriptReady": "Bản ghi lời thoại đã sẵn sàng","regenerateAs": "Tạo lại bằng",+ "namesAndTerms": "Tên và thuật ngữ","auto": "Tự động","regenerate": "Tạo lại","regenerateTip": "Tạo lại: phiên âm lại bằng ngôn ngữ đã chọn",diff --git a/src/i18n/locales/zh-CN/editor.json b/src/i18n/locales/zh-CN/editor.jsonindex 98a12b084..021db711c 100644--- a/src/i18n/locales/zh-CN/editor.json+++ b/src/i18n/locales/zh-CN/editor.json@@ -156,6 +156,7 @@"close": "关闭","transcriptReady": "转录已就绪","regenerateAs": "重新生成为",+ "namesAndTerms": "名称和术语","auto": "自动","regenerate": "重新生成","regenerateTip": "重新生成:用所选语言再次转录",diff --git a/src/i18n/locales/zh-TW/editor.json b/src/i18n/locales/zh-TW/editor.jsonindex 8862c279a..522ccc751 100644--- a/src/i18n/locales/zh-TW/editor.json+++ b/src/i18n/locales/zh-TW/editor.json@@ -156,6 +156,7 @@"close": "關閉","transcriptReady": "逐字稿已就緒","regenerateAs": "以此語言重新產生",+ "namesAndTerms": "名稱與術語","auto": "自動","regenerate": "重新產生","regenerateTip": "重新產生:以所選語言再次轉錄",diff --git a/src/lib/ai-edition/document/transcribe.test.ts b/src/lib/ai-edition/document/transcribe.test.tsindex 43a31feea..a7c2d194b 100644--- a/src/lib/ai-edition/document/transcribe.test.ts+++ b/src/lib/ai-edition/document/transcribe.test.ts@@ -215,6 +215,23 @@ describe("transcribeAsset native extraction", () => {expect(transcript.segments.length).toBeGreaterThan(0);});+ it("passes the project's names and terms on both paths", async () => {+ const doc = makeDoc();+ doc.project.vocabulary = "OpenScreen, Kubernetes";+ transcribeMock.mockRejectedValueOnce(+ new Error(`${STT_NATIVE_EXTRACTION_UNAVAILABLE}: no ffmpeg binary`),+ );+ rendererMock.mockResolvedValueOnce({+ segments: [],+ granularity: "word",+ detectedLanguage: "en",+ });+ await transcribeAsset(doc, "asset_1");+ const withPrompt = expect.objectContaining({ prompt: "OpenScreen, Kubernetes" });+ expect(transcribeMock).toHaveBeenCalledWith("/tmp/demo.mp4", withPrompt);+ expect(rendererMock).toHaveBeenCalledWith(expect.anything(), withPrompt);+ });+it("does NOT fall back on any other failure", async () => {// "This file has no audio" is a verdict. Re-deriving it in the renderer would buy// the same answer for the price of the decode this change exists to avoid.diff --git a/src/lib/ai-edition/document/transcribe.ts b/src/lib/ai-edition/document/transcribe.tsindex 697a5a387..cffddf51d 100644--- a/src/lib/ai-edition/document/transcribe.ts+++ b/src/lib/ai-edition/document/transcribe.ts@@ -65,6 +65,8 @@ export async function transcribeAsset(// so the stored transcript reflects reality, not the input option.const forcedLanguage =options.language && options.language !== "auto" ? options.language : undefined;+ // The project's names and terms ride along on every run, background or manual.+ const prompt = document.project.vocabulary;// Forward the main process's per-chunk progress. Without this the status// callback only ever fired the two coarse phases above, so a 30-minute@@ -99,6 +101,7 @@ export async function transcribeAsset(trimRegions: [],signal: options.signal,language: forcedLanguage,+ prompt,onStatus: forwardStatus,}).catch(async (error: unknown) => {const message = error instanceof Error ? error.message : String(error);@@ -111,6 +114,7 @@ export async function transcribeAsset(trimRegions: [],signal: options.signal,language: forcedLanguage,+ prompt,onStatus: forwardStatus,});});diff --git a/src/lib/ai-edition/schema/index.ts b/src/lib/ai-edition/schema/index.tsindex 9c5760f19..4d8caf600 100644--- a/src/lib/ai-edition/schema/index.ts+++ b/src/lib/ai-edition/schema/index.ts@@ -613,6 +613,9 @@ const documentSchemaShape = z.object({createdAt: isoDateSchema,updatedAt: isoDateSchema,primaryAssetId: z.string().optional(),+ // Names and terms passed to Whisper as its initial prompt (issue #1023).+ // Additive, so no schemaVersion bump: an older build drops the key on save.+ vocabulary: z.string().optional(),}),assets: z.array(assetSchema).default([]),transcript: transcriptSchema.nullable().default(null),diff --git a/src/lib/captioning/transcribe.ts b/src/lib/captioning/transcribe.tsindex 82aaad14c..132c1cea1 100644--- a/src/lib/captioning/transcribe.ts+++ b/src/lib/captioning/transcribe.ts@@ -52,7 +52,7 @@ export interface SttRendererStatus {}interface RendererSttApi {- transcribe: (request: { samples: Float32Array; language?: string }) => Promise<{+ transcribe: (request: { samples: Float32Array; language?: string; prompt?: string }) => Promise<{segments: CaptionSegment[];wordSegments: SttWordSegment[];detectedLanguage: string;@@ -103,6 +103,8 @@ export interface TranscribeOptions {onStatus?: (status: SttRendererStatus) => void;signal?: AbortSignal;language?: string;+ /** Names and terms to bias Whisper toward (the project's vocabulary). */+ prompt?: string;}function runTranscription(@@ -135,7 +137,7 @@ function runTranscription(// trimmed leading silence with a peak detector and got false positives on// quiet music intros / room tone. VAD or nothing.return api- .transcribe({ ...payload, language: forcedLanguage })+ .transcribe({ ...payload, language: forcedLanguage, prompt: options?.prompt }).then((result) => {const words = result.wordSegments ?? [];let segments: CaptionSegment[];diff --git a/technical-documentation/architecture/transcription-and-captions.md b/technical-documentation/architecture/transcription-and-captions.mdindex 6aed5347d..b594c122f 100644--- a/technical-documentation/architecture/transcription-and-captions.md+++ b/technical-documentation/architecture/transcription-and-captions.md@@ -608,6 +608,10 @@ which is far too late to explain a wait that is already happening.The request takes a raw `Float32Array` of mono 16 kHz PCM and an optionalISO 639-1 `language` code; `"auto"` or absent leaves detection to Whisper.+An optional `prompt` carries the project's names and terms+(`project.vocabulary`, the media stage's "Names and terms" field, issue #1023):+the helper sets it as whisper's `initial_prompt` with `carry_initial_prompt`, so+every 30 s window of every chunk is conditioned on it.Status events fan out on a separate channel(`SttStatusEvent`, `phase: "model" | "transcribe"`) so the renderer candrive a "downloading model" / "transcribing" indicator without holding open