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(stt): frame the names and terms as a glossary prompt

EtienneLescotdf33fc1758b8
diff --git a/electron/stt/whisperServer.test.ts b/electron/stt/whisperServer.test.ts
index 1d66e0f06..fd2ac429f 100644
--- a/electron/stt/whisperServer.test.ts
+++ b/electron/stt/whisperServer.test.ts
@@ -310,9 +310,9 @@ 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 the project's names and terms as a glossary prompt", async () => {
+ const sent = await captureFormField("auto", " OpenScreen, whisper.cpp. \n", "prompt");
+ expect(sent).toBe("Glossary: OpenScreen, whisper.cpp.");
});
it("sends no prompt field when the names and terms are blank", async () => {
diff --git a/electron/stt/whisperServer.ts b/electron/stt/whisperServer.ts
index a1065fecd..b572180df 100644
--- a/electron/stt/whisperServer.ts
+++ b/electron/stt/whisperServer.ts
@@ -496,8 +496,13 @@ 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);
+ const prompt = opts.prompt?.trim().replace(/\.+$/, "");
+ // Framed as a glossary, not handed over bare. Whisper reads its prompt as the
+ // text that came just before, so a bare list read as already said: the opening
+ // words that held those terms were dropped ("Welcome to this release
+ // candidate…" lost its first five words) and a list of names turned the whole
+ // transcript into Title Case. Measured in #1023.
+ if (prompt) form.set("prompt", `Glossary: ${prompt}.`);
let res: Response;
try {
res = await fetch(url, {
diff --git a/technical-documentation/architecture/transcription-and-captions.md b/technical-documentation/architecture/transcription-and-captions.md
index b594c122f..ecd8f90ee 100644
--- a/technical-documentation/architecture/transcription-and-captions.md
+++ b/technical-documentation/architecture/transcription-and-captions.md
@@ -609,9 +609,12 @@ 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 optional
ISO 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.
+(`project.vocabulary`, the media stage's "Names and terms" field, issue #1023).
+`whisperServer.ts` sends it framed as `Glossary: <terms>.`, and the helper sets
+that as whisper's `initial_prompt` with `carry_initial_prompt`, so every 30 s
+window of every chunk is conditioned on it. The framing is not cosmetic: whisper
+reads a bare list as text already spoken, and dropped the opening words that
+contained the terms.
Status events fan out on a separate channel
(`SttStatusEvent`, `phase: "model" | "transcribe"`) so the renderer can
drive a "downloading model" / "transcribing" indicator without holding open