@broberg/speech-dictionary

中文文档
0.2.0发布于 2026/11/01MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 2580

Fleet STT vocabulary + correction primitive — terms[] for WhisperKit-style prompt-biasing, corrections{} for post-transcription fixup. Seeded from the fleet's real dev-jargon mishear list.

原始使用文档
文档目录5 节
  1. Two datasets, two jobs
  2. Cross-stack: raw JSON, not just a JS API
  3. Unicode-aware correction (why this mattered)
  4. Six mishearings are also real Danish words (0.2.0, F044.2)
  5. Extending with your own vocabulary

@broberg/speech-dictionary

Fleet STT vocabulary + correction primitive — a shared dictionary any Whisper-family transcription feature can pull in, instead of every repo hand-rolling its own term list that drifts.

npm i @broberg/speech-dictionary

Two real consumers today: Trail's on-device WhisperKit ambient-STT (F201.6) and cardmem's interview module (F185) both mishear the same fleet proper nouns and dev-jargon — this package is seeded from the fleet's real, previously-loose ordbog.txt mishear list plus cardmem's authored proper-noun set.

Two datasets, two jobs

import { terms, corrections, toInitialPrompt, applyCorrections } from "@broberg/speech-dictionary";

// PRE-transcription: bias WhisperKit's initialPrompt toward fleet proper nouns
toInitialPrompt({ groups: ["product", "tech"], maxTerms: 20 });
// → "cardmem, buddy, Trail, ..., WhisperKit, Fly.io, ..."

// POST-transcription: fix known dev-jargon mishears in the raw transcript
applyCorrections("jeg lavede en kommitte og fixede en bog i søveren");
// → "jeg lavede en committe og fixede en bog i serveren"
  • terms() / toInitialPrompt() — 40 fleet proper nouns (products, people, brands, tech), grouped so a caller can bias toward just what's relevant (groups: ["product"]) and cap the list to fit a model's prompt budget (maxTerms).
  • corrections() / applyCorrections() — 55 real Danish/English dev-jargon mishears ("kommitte" → "committe", "søver" → "server"), parsed verbatim from the fleet's own ordbog.txt.

Cross-stack: raw JSON, not just a JS API

data/terms.json and data/corrections.json ship as raw files in the npm tarball (not just bundled into dist/), so a non-JS consumer — e.g. a Swift build step bundling WhisperKit resources on-device — can read them directly from node_modules/@broberg/speech-dictionary/data/*.json with no Node/JS runtime involved. The TS/JS wrapper in this README is for JS/TS consumers (cardmem, Trail's Bun engine); Swift consumers read the JSON directly.

Unicode-aware correction (why this mattered)

applyCorrections does not use JavaScript's default \b word-boundary — \b only treats [A-Za-z0-9_] as word characters, so \bsøver\b silently never matches "søver" in real Danish text (æ/ø/å fall outside \b's definition of a word character). This package uses a Unicode-letter-aware boundary instead, so Danish terms correct properly. Longest-wrong-term-first ordering avoids one correction partially clobbering another (e.g. "komitte" and "kommitte" both resolve correctly to "committe").

Six mishearings are also real Danish words (0.2.0, F044.2)

ruter → router is right in «min ruter er nede» and wrong in «API-ruter», which is the plural of rute. Six entries are like that — ruter, mærke, passe, bogen, kloster, dansen — and they carry alsoDanishWord: true: they do not fire inside a hyphenated compound, while a bare occurrence is still corrected. Every other entry behaves exactly as before.

Every entry in data/corrections.json answers the question explicitly (true/false), and a test refuses one that does not — so a new mishearing cannot be added without someone asking «is this also a word?». In your own extend() entries the field is optional and absent means false (the old behaviour). correctionsApplier(list) applies a list of your own on its own.

What the decision rests on, and what it does not. cms measured 628,013 characters of WRITTEN Danish (four sites, 15 collections): API-ruter twice, the other five zero. This package corrects TRANSCRIPT output, so that corpus says which compounds exist in Danish tech writing and nothing about what a transcriber emits — and zero in a software corpus is not zero in Danish (varemærke-, regnskabs-bogen, kirke-kloster would all have fired). The six are flagged because each is both readings at once, not because the corpus found them.

Extending with your own vocabulary

import { extend } from "@broberg/speech-dictionary";

const mine = extend({
  terms: [{ term: "fd-sundhed", group: "product" }],
  corrections: [{ wrong: "fysjo", right: "fysio" }],
});

mine.applyCorrections("fysjo klinik"); // → "fysio klinik"

extend() returns a fresh bound API layered on top of the fleet base — it never mutates shared state, so concurrent callers with different custom vocabularies don't interfere with each other.

版本与发布记录

@broberg/speech-dictionary 共发布 4 个版本,首次发布于 2026/07/03;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.2.0latest2026/11/017 天前
0.1.32026/08/252 个月前
0.1.22026/07/034 个月前
0.1.12026/07/034 个月前

关于 @broberg/speech-dictionary 的常见问题

@broberg/speech-dictionary 是什么?

Fleet STT vocabulary + correction primitive — terms[] for WhisperKit-style prompt-biasing, corrections{} for post-transcription fixup. Seeded from the fleet's real dev-jargon mishear list.

如何安装 @broberg/speech-dictionary?

在项目目录运行 npm install @broberg/speech-dictionary,或使用 pnpm add / yarn add / bun add。

@broberg/speech-dictionary 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@broberg/speech-dictionary 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@broberg/speech-dictionary 可以商用吗?

@broberg/speech-dictionary 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@broberg/speech-dictionary 的下载量有多少?

根据 npm 官方下载统计,@broberg/speech-dictionary 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,580 次,日均约 86 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@broberg/speech-dictionary 还在维护吗?

最新版本 0.2.0 发布于 2026/11/01(7 天前);至今共发布 4 个版本,其中过去 12 个月发布了 4 个;首次发布于 2026/07/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。