@skaile/forge-voice 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/LICENSE +21 -0
- package/README.md +329 -2
- package/dist/browser/index.d.mts +2102 -0
- package/dist/browser/index.mjs +5808 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/h3/index.d.mts +26 -0
- package/dist/h3/index.mjs +234 -0
- package/dist/h3/index.mjs.map +1 -0
- package/dist/index.d.mts +138 -0
- package/dist/index.mjs +1 -0
- package/dist/relay.d.mts +345 -0
- package/dist/relay.mjs +1194 -0
- package/dist/relay.mjs.map +1 -0
- package/dist/server/index.d.mts +57 -0
- package/dist/server/index.mjs +1 -0
- package/dist/speech-terms.d.mts +237 -0
- package/dist/wire.mjs +792 -0
- package/dist/wire.mjs.map +1 -0
- package/package.json +90 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.mjs","names":[],"sources":["../src/shared/audio-tags.ts","../src/shared/voice-languages.ts","../src/shared/speech-terms.ts","../src/shared/spoken-language-default.ts","../src/shared/spoken-sentences.ts","../src/shared/stop-phrases.ts","../src/shared/utterance-end.ts","../src/shared/wire.ts"],"sourcesContent":["/**\n * Audio tags in a spoken reply: `[[whispers]]`, `[[laughs]]`. The reply-format contract between an\n * agent that writes tags and the speech model that performs them. The stored text keeps them; what a\n * chat shows of a voice reply, what Talk counts as heard (`heardChars`) and what a server reuses of one\n * (history, search, recaps) is the text without them. Only voice replies have tags: anywhere else\n * `[[...]]` is code or a wiki link. Browser and server import the same functions, so both count\n * offsets the same way; keep this file free of runtime-specific imports.\n */\n\n/** `[[` + letters, spaces, commas, hyphens or apostrophes (at most 40) + `]]`. */\nconst TAG_SOURCE = \"\\\\[\\\\[[\\\\p{L} ,'-]{1,40}\\\\]\\\\]\"\nconst anyDoubleBracket = /\\[\\[[^\\]\\n]*\\]\\]/gu\n// A tag still streaming in: `[[`, up to 40 tag characters and at most the first `]`.\nconst pendingTail = /\\[\\[[\\p{L} ,'-]{0,40}\\]?$/u\n\n/** The text without its audio tags. */\nexport function stripAudioTags(text: string): string {\n return text.replace(new RegExp(TAG_SOURCE, 'gu'), '')\n}\n\n/**\n * Where `rawOffset` in the stored text lands in the stripped text. An offset inside a tag lands\n * where the tag was.\n */\nexport function strippedOffset(raw: string, rawOffset: number): number {\n const end = Math.max(0, Math.min(rawOffset, raw.length))\n let removed = 0\n for (const match of raw.matchAll(new RegExp(TAG_SOURCE, 'gu'))) {\n const start = match.index ?? 0\n if (start >= end) {\n break\n }\n removed += Math.min(match[0].length, end - start)\n }\n return end - removed\n}\n\n/**\n * The text without any double-bracket tag, malformed ones too (`[[laughs!]]`): what Talk speaks\n * on the fallback model or shows as a caption, never a `[[`. Not for offsets: `stripAudioTags`.\n */\nexport function stripAnyAudioTags(text: string): string {\n return text.replace(anyDoubleBracket, '')\n}\n\n/**\n * Where a trailing, not yet closed tag starts (`[[laug`, `[[laughs]`, or a lone final `[`), so\n * Talk holds it back until it closes instead of speaking or cutting half of it; -1 otherwise.\n */\nexport function pendingTagStart(text: string): number {\n const match = pendingTail.exec(text)\n if (match) {\n return match.index\n }\n return text.endsWith('[') ? text.length - 1 : -1\n}\n\n/**\n * The ElevenLabs v4 form: `[[x]]` becomes `[x]`; a malformed double-bracket tag is dropped.\n */\nexport function toElevenLabsTags(text: string): string {\n const valid = new RegExp(`^${TAG_SOURCE}$`, 'u')\n return text.replace(anyDoubleBracket, tag => (valid.test(tag) ? tag.slice(1, -1) : ''))\n}\n\n// Fenced code (to its closing fence or the end) and inline code spans: `[[x]]` there is code, not a tag.\nconst codeSpan = /```[\\s\\S]*?(?:```|$)|`[^`\\n]+`/g\n\n/** The [start, end) ranges of fenced code blocks and inline code spans in `text`. */\nfunction codeRanges(text: string): [number, number][] {\n return [...text.matchAll(codeSpan)].map(m => [m.index, m.index + m[0].length])\n}\n\nfunction inCode(ranges: readonly [number, number][], at: number): boolean {\n return ranges.some(([start, end]) => at >= start && at < end)\n}\n\n/**\n * What Chat shows of a voice reply: its valid tags removed, except inside code (a fenced block or\n * an inline span), where `[[x]]` is the code's own (bash `[[ -d x ]]`, a wiki link).\n */\nexport function stripAudioTagsForDisplay(text: string): string {\n if (!text.includes('[[')) {\n return text\n }\n const ranges = codeRanges(text)\n return text.replace(new RegExp(TAG_SOURCE, 'gu'), (tag: string, at: number) => (inCode(ranges, at) ? tag : ''))\n}\n\n/** The [start, end) ranges of the audio tags in `raw`. */\nexport function audioTagRanges(raw: string): [number, number][] {\n return [...raw.matchAll(new RegExp(TAG_SOURCE, 'gu'))].map(m => [m.index ?? 0, (m.index ?? 0) + m[0].length])\n}\n\n/**\n * A voice reply's text for reuse as plain text (history, search, recaps, read-aloud): every\n * `[[...]]` removed, malformed ones too since Flash reads them aloud, but none inside code. Text\n * without one comes back unchanged; a removed tag takes one adjacent space, nothing else is touched.\n * Callers outside `/voice/speak` apply it to voice replies only. `inCodeToo`: code as well, for\n * `/voice/speak`, where the fast model would read a tag aloud wherever it is.\n * Not for offsets: `stripAudioTags`.\n */\nexport function stripAudioTagsForText(text: string, { inCodeToo = false }: { inCodeToo?: boolean } = {}): string {\n if (!text.includes('[[')) {\n return text\n }\n const ranges = inCodeToo ? [] : codeRanges(text)\n let out = ''\n let pos = 0\n for (const match of text.matchAll(anyDoubleBracket)) {\n if (inCode(ranges, match.index)) {\n continue\n }\n out += text.slice(pos, match.index)\n let end = match.index + match[0].length\n const next = text[end]\n if (next === ' ' && (out === '' || /\\s$/.test(out))) {\n end += 1\n } else if ((next === undefined || !/[\\p{L}\\p{N}]/u.test(next)) && out.endsWith(' ')) {\n out = out.slice(0, -1)\n }\n pos = end\n }\n return out + text.slice(pos)\n}\n","/**\n * Spoken languages a session may pin for speech-to-text, as Deepgram nova-3 codes.\n * `multi` is nova-3's multilingual mode, which a relay default language of `auto` maps to.\n * A closed list: the value is interpolated into the upstream URL.\n */\nexport const STT_LANGUAGES = [\n 'multi',\n 'en',\n 'en-US',\n 'en-GB',\n 'de',\n 'de-CH',\n 'fr',\n 'es',\n 'it',\n 'nl',\n 'pt',\n 'pt-BR',\n 'pl',\n 'sv',\n 'da',\n 'no',\n 'fi',\n 'tr',\n 'ru',\n 'uk',\n 'ja',\n 'ko',\n 'hi',\n] as const\n\nexport type SttLanguage = (typeof STT_LANGUAGES)[number]\n\nconst STT_LANGUAGE_SET: ReadonlySet<string> = new Set(STT_LANGUAGES)\n\n/** The requested language when it is on the list, else null (the caller falls back to the deployment default). */\nexport function parseSttLanguage(value: unknown): SttLanguage | null {\n return typeof value === 'string' && STT_LANGUAGE_SET.has(value) ? (value as SttLanguage) : null\n}\n\n/**\n * The ElevenLabs `language_code` for a pinned STT language: the bare ISO 639-1 part,\n * or null for `multi` / anything malformed.\n */\nexport function ttsLanguageCode(value: unknown): string | null {\n const lang = parseSttLanguage(typeof value === 'string' ? value.trim() : value)\n if (!lang || lang === 'multi') {\n return null\n }\n return lang.slice(0, 2)\n}\n\n/**\n * ElevenLabs refuses `language_code` on models that do not enforce a language; today\n * that is everything except the v2.5 Flash and Turbo models and the v3 / v4 family\n * (which Talk's text-to-dialogue stream uses).\n */\nexport function modelAcceptsLanguageCode(modelId: string): boolean {\n return /^eleven_(flash|turbo)_v2_5$/.test(modelId) || /^eleven_v[34](_|$)/.test(modelId)\n}\n","/**\n * Speech terms: words Talk should hear and say right. Each entry is for one spoken language; its\n * `term` is boosted in Deepgram's recognition (keyterm prompting), and an optional\n * `pronunciation` is the spelling the speech model reads instead (a text alias). Plain types and\n * functions only: a host that validates stored terms builds its schema from the constants here\n * (`SPEECH_TERM_LANGUAGES`, `SPEECH_TERM_PATTERN`, the length limits, `sameSpeechTerm`).\n */\nimport { STT_LANGUAGES, type SttLanguage } from './voice-languages'\n\n/** Base language codes a term can be for (`multi` and regional variants fold into these). */\nexport const SPEECH_TERM_LANGUAGES = [\n ...new Set(STT_LANGUAGES.filter(lang => lang !== 'multi').map(lang => lang.slice(0, 2))),\n] as [string, ...string[]]\n\nexport const MAX_SPEECH_TERMS = 60\nexport const MAX_SPEECH_TERM_CHARS = 50\nexport const MAX_PRONUNCIATION_CHARS = 80\n\n/**\n * Letters, digits, spaces and the punctuation names use; nothing that could act as markup. A stored\n * term or pronunciation also has no double or trailing spaces (`tidySpeechTermText` folds them).\n */\nexport const SPEECH_TERM_PATTERN = /^[\\p{L}\\p{N}][\\p{L}\\p{N} .'’&+-]*$/u\n\n/** Folds whitespace the way stored terms are written, before they are validated. */\nexport function tidySpeechTermText(value: string): string {\n return value.normalize('NFC').replace(/\\s+/g, ' ').trim()\n}\n\nexport interface SpeechTerm {\n /** The base language the term is for, one of `SPEECH_TERM_LANGUAGES` (`de`, `en`, …). */\n language: string\n /** The word or name as it is written (at most `MAX_SPEECH_TERM_CHARS`). */\n term: string\n /** How to say it, spelled the way a speaker of that language would read it (at most `MAX_PRONUNCIATION_CHARS`). */\n pronunciation?: string\n}\n\n/** Whether two entries name the same term: same language, same term ignoring case. */\nexport function sameSpeechTerm(\n a: Pick<SpeechTerm, 'language' | 'term'>,\n b: Pick<SpeechTerm, 'language' | 'term'>,\n): boolean {\n return a.language === b.language && a.term.toLowerCase() === b.term.toLowerCase()\n}\n\n/** The list with `entry` added, or replacing the same term in the same language. */\nexport function withSpeechTerm(list: readonly SpeechTerm[], entry: SpeechTerm): SpeechTerm[] {\n return [...list.filter(other => !sameSpeechTerm(other, entry)), entry]\n}\n\n/** The list without that term in that language. */\nexport function withoutSpeechTerm(\n list: readonly SpeechTerm[],\n entry: Pick<SpeechTerm, 'language' | 'term'>,\n): SpeechTerm[] {\n return list.filter(other => !sameSpeechTerm(other, entry))\n}\n\n/** A term's base language matches the stream's; `multi` or no language means every term. */\nexport function speechTermLanguageMatches(termLanguage: string, streamLanguage: SttLanguage | string | null): boolean {\n return !streamLanguage || streamLanguage === 'multi' || streamLanguage.slice(0, 2) === termLanguage\n}\n\n/**\n * Dev words Talk hears in every conversation about work, per base language. German speech uses\n * the English words with German endings (\"mergen\", \"gemergt\"), which Deepgram heard as \"Merchant\".\n */\nexport const BUILT_IN_KEYTERMS: Record<string, readonly string[]> = {\n de: ['mergen', 'gemergt', 'Merge', 'Pull Request', 'Issue', 'Deploy', 'deployen', 'Branch', 'Commit', 'Review'],\n en: ['merge', 'pull request', 'issue', 'deploy', 'branch', 'commit'],\n}\n\n/**\n * Spellings German speech reads English dev words with. ElevenLabs reads \"mergen\" with a German\n * g; respelled, the German voice says it the English way. Matched as whole words, case-insensitively.\n */\nexport const BUILT_IN_PRONUNCIATIONS: Record<string, readonly { term: string; pronunciation: string }[]> = {\n de: [\n { term: 'mergen', pronunciation: 'mördschen' },\n { term: 'gemergt', pronunciation: 'gemördscht' },\n { term: 'gemerged', pronunciation: 'gemördscht' },\n { term: 'merge', pronunciation: 'mördsch' },\n { term: 'merges', pronunciation: 'mördsches' },\n { term: 'mergt', pronunciation: 'mördscht' },\n { term: 'Pull Request', pronunciation: 'Pull Riquest' },\n { term: 'Pull Requests', pronunciation: 'Pull Riquests' },\n { term: 'Issue', pronunciation: 'Ischu' },\n { term: 'Issues', pronunciation: 'Ischus' },\n { term: 'deployen', pronunciation: 'diploien' },\n { term: 'deployt', pronunciation: 'diploit' },\n { term: 'Deploy', pronunciation: 'Diploi' },\n ],\n}\n\n// ── Keyterms for one Deepgram request ───────────────────────────────────────\n\n/**\n * Deepgram refuses a request whose keyterms exceed 500 tokens in total, and its tokenizer is not\n * public. A term is counted at its UTF-8 bytes (spaces included) plus one per word, which no subword tokenizer\n * exceeds (umlauts count twice), and the budget stays well below 500. Deepgram advises 20-50 terms.\n */\nexport const KEYTERM_TOKEN_BUDGET = 400\nexport const MAX_KEYTERMS = 50\n/** The user's own terms may fill at most this share, so the assistant name and dev words always fit. */\nexport const USER_KEYTERM_TOKEN_BUDGET = 240\nexport const MAX_USER_KEYTERMS = 30\nconst MAX_KEYTERM_WORDS = 5\nconst utf8 = new TextEncoder()\n\nexport function estimateKeytermTokens(term: string): number {\n return utf8.encode(term).length + term.split(' ').filter(Boolean).length\n}\n\n/** A name fit to prompt with: short, made of words, no markup. Null when it is not. */\nexport function cleanKeyterm(raw: string): string | null {\n const term = raw\n .normalize('NFC')\n .replace(/[\\p{Cc}\\p{Cf}]/gu, '')\n .replace(/\\s+/g, ' ')\n .trim()\n if (!term || term.length > MAX_SPEECH_TERM_CHARS || !/\\p{L}/u.test(term)) {\n return null\n }\n if (term.split(' ').length > MAX_KEYTERM_WORDS) {\n return null\n }\n return term\n}\n\nexport type KeytermSources = {\n /** The stream's language; null or `multi` takes every language's terms. */\n language: SttLanguage | string | null\n userTerms: readonly SpeechTerm[]\n assistantName?: string | null\n /** Names of opted-in orgs, their projects and agents, most recently active first. */\n names: readonly string[]\n /** Names of the user's own sessions in opted-in orgs, most recently active first. */\n sessionNames?: readonly string[]\n}\n\n/**\n * The keyterms for one request in a fixed priority: the user's own terms (newest first, within\n * their own share), the assistant's name, the built-in dev words, org/project/agent names, then\n * own session names. Deduplicated\n * case-insensitively, within {@link MAX_KEYTERMS} and {@link KEYTERM_TOKEN_BUDGET}; a term over the\n * remaining budget is skipped and a shorter later one may still fit, so the result is deterministic.\n */\nexport function buildKeyterms({\n language,\n userTerms,\n assistantName,\n names,\n sessionNames = [],\n}: KeytermSources): string[] {\n const builtIn = Object.entries(BUILT_IN_KEYTERMS)\n .filter(([lang]) => speechTermLanguageMatches(lang, language))\n .flatMap(([, terms]) => terms)\n const own = userTerms\n .filter(entry => speechTermLanguageMatches(entry.language, language))\n .map(entry => entry.term)\n .reverse()\n const seen = new Set<string>()\n const out: string[] = []\n let tokens = 0\n const take = (raws: readonly string[], maxTokens: number, maxTerms: number) => {\n for (const raw of raws) {\n const term = cleanKeyterm(raw)\n if (!term || seen.has(term.toLowerCase())) {\n continue\n }\n const cost = estimateKeytermTokens(term)\n if (tokens + cost > maxTokens) {\n continue\n }\n seen.add(term.toLowerCase())\n out.push(term)\n tokens += cost\n if (out.length >= maxTerms) {\n return\n }\n }\n }\n take(own, USER_KEYTERM_TOKEN_BUDGET, MAX_USER_KEYTERMS)\n take(\n [...(assistantName ? [assistantName] : []), ...builtIn, ...names, ...sessionNames],\n KEYTERM_TOKEN_BUDGET,\n MAX_KEYTERMS,\n )\n return out\n}\n","import { parseSttLanguage, type SttLanguage } from './voice-languages'\n\n/**\n * The spoken language for a conversation language (a locale such as `de-DE`): the locale\n * itself when the recognizer knows that region, else its bare language, else null (the\n * deployment default).\n */\nexport function sttLanguageForLocale(locale: string | null | undefined): SttLanguage | null {\n if (!locale) {\n return null\n }\n return parseSttLanguage(locale) ?? parseSttLanguage(locale.split('-')[0])\n}\n\n/**\n * What dictation and read-aloud use: the language the person pinned by hand, else the one\n * they converse in here. A pin is never replaced; clearing it returns to following them.\n */\nexport function effectiveSttLanguage(\n pinned: SttLanguage | null | undefined,\n conversationLocale: string | null | undefined,\n): SttLanguage | null {\n return pinned ?? sttLanguageForLocale(conversationLocale)\n}\n","import { stripAudioTags } from './audio-tags'\n\n/**\n * Splits a reply that is still streaming into sentences that can be spoken now.\n * A sentence ends at `.`, `!`, `?` or `…` followed by whitespace, or at a line\n * break. Very short pieces (\"1.\", \"OK.\") wait for the next one, so one request\n * never carries a single syllable.\n */\nexport const MIN_SENTENCE_CHARS = 12\n\nconst BOUNDARY = /[.!?…]+[\"')\\]]*\\s+|\\n+/g\n\nexport type SentenceCut = {\n /** Complete sentences found after `from`, trimmed and non-empty. */\n sentences: string[]\n /** Offset into `text` where the unspoken remainder starts. */\n next: number\n}\n\nexport function takeCompleteSentences(text: string, from: number): SentenceCut {\n const sentences: string[] = []\n let start = from\n BOUNDARY.lastIndex = from\n for (let match = BOUNDARY.exec(text); match; match = BOUNDARY.exec(text)) {\n const end = match.index + match[0].length\n const piece = text.slice(start, end).trim()\n // An audio tag adds no syllable: `[[sighs]] Ja.` is as short as `Ja.`.\n if (stripAudioTags(piece).trim().length >= MIN_SENTENCE_CHARS || (match[0].includes('\\n') && piece.length > 0)) {\n sentences.push(piece)\n start = end\n }\n }\n return { sentences, next: start }\n}\n\n/**\n * Removes the markdown that would be read out as symbols: emphasis, headings,\n * inline code ticks, list bullets, and link targets (the link text stays).\n * Fenced code blocks are dropped entirely.\n */\nexport function toSpeakableText(markdown: string): string {\n return markdown\n .replace(/```[\\s\\S]*?(```|$)/g, ' ')\n .replace(/!?\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1')\n .replace(/^\\s{0,3}#{1,6}\\s+/gm, '')\n .replace(/^\\s*[-*+]\\s+/gm, '')\n .replace(/(\\*\\*|__|\\*|_|`)/g, '')\n .replace(/[ \\t]+/g, ' ')\n .trim()\n}\n","/**\n * Utterances the hands-free loop acts on instead of sending. Matched against the\n * whole utterance, so \"stop the deployment\" still reaches the agent.\n */\n\n/**\n * \"Stop talking\" / \"be quiet and listen\": barge-in has already silenced the reply; the\n * words are not sent and the loop goes on.\n */\nconst HUSH_PHRASES = new Set([\n 'stop',\n 'stopp',\n 'quiet',\n 'ruhe',\n 'pause',\n 'warte',\n 'warte mal',\n 'moment',\n 'einen moment',\n 'kurz',\n 'halt',\n 'wait',\n 'hold on',\n 'one moment',\n])\nconst LONGEST_HUSH_PHRASE = Math.max(...[...HUSH_PHRASES].map(phrase => phrase.split(' ').length))\n\n/** End the loop. */\nconst STOP_PHRASES = new Set([\n 'stop listening',\n 'stop hands free',\n 'end hands free',\n 'hands free off',\n 'hör auf',\n 'hör auf zuzuhören',\n 'freihändig aus',\n 'arrête',\n 'arrête d’écouter',\n])\n\n/** Lowercases and drops punctuation and hyphens, so \"Stop listening.\" matches \"stop listening\". */\nfunction normalize(utterance: string): string {\n return utterance\n .toLowerCase()\n .replace(/['’]/g, '’')\n .replace(/[-–]/g, ' ')\n .replace(/[^\\p{L}\\p{N}’ ]/gu, '')\n .replace(/\\s+/g, ' ')\n .trim()\n}\n\nexport type LoopCommand = 'end' | 'hush'\n\n/** What a hands-free utterance asks of the loop itself; null when it is a message for the agent. */\nexport function loopCommand(utterance: string): LoopCommand | null {\n const phrase = normalize(utterance)\n if (STOP_PHRASES.has(phrase)) {\n return 'end'\n }\n return HUSH_PHRASES.has(phrase) ? 'hush' : null\n}\n\n/**\n * True when the whole utterance is made of hush phrases (greedy longest match), so\n * \"Stopp, warte mal\" hushes but \"Stopp, was meinst du damit?\" is a message.\n */\nexport function isHushOnly(utterance: string): boolean {\n const tokens = normalize(utterance).split(' ').filter(Boolean)\n if (tokens.length === 0) {\n return false\n }\n let i = 0\n while (i < tokens.length) {\n let matched = 0\n for (let len = Math.min(LONGEST_HUSH_PHRASE, tokens.length - i); len > 0 && matched === 0; len--) {\n if (HUSH_PHRASES.has(tokens.slice(i, i + len).join(' '))) {\n matched = len\n }\n }\n if (matched === 0) {\n return false\n }\n i += matched\n }\n return true\n}\n","/**\n * How long the hands-free loop waits after Deepgram reports the end of speech before\n * it sends what was said. Deepgram ends an utterance after 300 ms of silence, which a\n * breath mid-sentence already reaches, so a sentence would leave as several messages.\n * Speech inside the wait joins the same message; a transcript that stops mid-sentence\n * waits longer, but is still sent, so the loop never stalls on a dropped thought.\n */\n\n/** After a finished sentence. */\nexport const UTTERANCE_HOLD_MS = 2_000\n/** After a transcript that stops mid-sentence, and the cap while the user is still talking. */\nexport const UTTERANCE_HOLD_MID_SENTENCE_MS = 5_000\n\nconst TERMINAL_PUNCTUATION = /[.?!。?!][\"'”’)\\]]*$/u\nconst QUESTION_OR_EXCLAMATION = /[?!?!][\"'”’)\\]]*$/u\nconst DANGLING_PUNCTUATION = /(?:[,;:–—-]|\\.\\.\\.|…)[\"'”’)\\]]*$/u\n\n// Words an English or German sentence rarely ends on; words that often end one (\"that\",\n// \"on\", \"so\", \"zu\") are left out. Checked after a full stop too, which smart formatting\n// also puts on fragments like \"The.\"; a \"?\" or \"!\" is taken at its word.\nconst CONTINUATION_WORDS = new Set([\n // English\n 'a',\n 'an',\n 'the',\n 'and',\n 'or',\n 'but',\n 'because',\n 'if',\n 'to',\n 'of',\n 'with',\n 'is',\n 'are',\n 'was',\n 'were',\n 'my',\n 'your',\n 'our',\n 'their',\n // German\n 'der',\n 'die',\n 'das',\n 'den',\n 'dem',\n 'des',\n 'ein',\n 'eine',\n 'einen',\n 'einem',\n 'einer',\n 'und',\n 'oder',\n 'aber',\n 'weil',\n 'dass',\n 'wenn',\n 'für',\n 'von',\n 'ist',\n 'sind',\n])\n\n/** True when the transcript reads as a thought that has not finished yet. */\nexport function endsMidSentence(transcript: string): boolean {\n const text = transcript.trim()\n if (!text || DANGLING_PUNCTUATION.test(text)) {\n return true\n }\n if (QUESTION_OR_EXCLAMATION.test(text)) {\n return false\n }\n const lastWord = text\n .toLowerCase()\n .split(/\\s+/)\n .at(-1)!\n .replace(/[^\\p{L}\\p{N}’']/gu, '')\n if (CONTINUATION_WORDS.has(lastWord)) {\n return true\n }\n return !TERMINAL_PUNCTUATION.test(text)\n}\n\n/** The wait before sending `transcript`, the utterance collected so far. */\nexport function utteranceHoldMs(transcript: string): number {\n return endsMidSentence(transcript) ? UTTERANCE_HOLD_MID_SENTENCE_MS : UTTERANCE_HOLD_MS\n}\n\n// ── Talk ────────────────────────────────────────────────────────────────────\n\n/**\n * Talk answers aloud, so it hands an utterance over sooner than dictation: after a finished\n * sentence and this much silence (on top of Deepgram's 300 ms endpointing). A sentence the user\n * goes on with after a longer pause still reaches the agent as one request: Talk restarts the\n * turn with the whole of it.\n */\nexport const TALK_HOLD_MS = 800\n/** A short answer (\"Ja\", \"Nein, danke\", \"Okay.\"), whatever its punctuation: sent promptly. */\nexport const TALK_HOLD_SHORT_MS = 250\n/** The most Talk waits after a transcript that reads unfinished (\"…, wenn ich\", \"mit meinen\"). */\nexport const TALK_HOLD_UNFINISHED_MS = 1_200\n/** Up to this many words an utterance is a short answer, unless its words end openly. */\nexport const TALK_SHORT_WORDS = 3\n\n// Fillers a spoken thought pauses on before it goes on.\nconst TALK_FILLER_WORDS = new Set(['also', 'so', 'äh', 'ähm', 'öh', 'öhm', 'hm', 'uh', 'uhm', 'um', 'erm'])\n\n// Words a spoken sentence does not end on, on top of `CONTINUATION_WORDS`: prepositions and\n// possessives that need what follows. Separable verb prefixes (\"auf\", \"an\", \"mit\", \"aus\", \"zu\",\n// \"nach\") are left out, since \"hör auf\" or \"kommst du mit\" end a sentence.\nconst TALK_OPEN_WORDS = new Set([\n 'in',\n 'im',\n 'ins',\n 'zum',\n 'zur',\n 'beim',\n 'vom',\n 'über',\n 'unter',\n 'ohne',\n 'gegen',\n 'seit',\n 'mein',\n 'meine',\n 'meinen',\n 'meinem',\n 'meiner',\n 'dein',\n 'deine',\n 'deinen',\n 'deinem',\n 'deiner',\n 'seine',\n 'seinen',\n 'seinem',\n 'seiner',\n 'unser',\n 'unsere',\n 'unseren',\n 'unserem',\n 'for',\n 'from',\n 'into',\n])\n\n// A subordinating word right before a pronoun opens a clause that still needs its verb (\"wenn ich\").\nconst CLAUSE_OPENERS = new Set([\n 'wenn',\n 'dass',\n 'weil',\n 'ob',\n 'als',\n 'obwohl',\n 'damit',\n 'bevor',\n 'nachdem',\n 'falls',\n 'wo',\n 'wie',\n 'was',\n 'warum',\n 'wieso',\n 'if',\n 'when',\n 'because',\n 'whether',\n 'that',\n])\nconst PRONOUNS = new Set([\n 'ich',\n 'du',\n 'er',\n 'sie',\n 'es',\n 'wir',\n 'ihr',\n 'man',\n 'i',\n 'you',\n 'he',\n 'she',\n 'it',\n 'we',\n 'they',\n])\n\n// German modal and future verbs: their clause ends on an infinitive (\"kannst du mir … geben\").\nconst MODAL_VERBS = new Set([\n 'kann',\n 'kannst',\n 'könnte',\n 'könntest',\n 'soll',\n 'sollst',\n 'sollte',\n 'solltest',\n 'muss',\n 'musst',\n 'müsste',\n 'will',\n 'willst',\n 'möchte',\n 'möchtest',\n 'darf',\n 'darfst',\n 'wird',\n 'wirst',\n 'würde',\n 'würdest',\n])\n// Words ending like an infinitive that are not one.\nconst NOT_INFINITIVES = new Set([\n 'den',\n 'einen',\n 'meinen',\n 'deinen',\n 'seinen',\n 'ihren',\n 'unseren',\n 'euren',\n 'keinen',\n 'diesen',\n 'jenen',\n 'welchen',\n 'allen',\n 'vielen',\n 'anderen',\n 'denen',\n 'wen',\n 'zwischen',\n 'oben',\n 'unten',\n 'hinten',\n 'wegen',\n 'gegen',\n 'neben',\n])\n\nfunction wordsOf(transcript: string): string[] {\n return transcript\n .trim()\n .toLowerCase()\n .split(/\\s+/)\n .map(word => word.replace(/[^\\p{L}\\p{N}’']/gu, ''))\n .filter(Boolean)\n}\n\nfunction looksLikeVerbEnd(word: string): boolean {\n if (NOT_INFINITIVES.has(word)) {\n return false\n }\n return (word.length >= 4 && /(?:en|ern|eln)$/u.test(word)) || (word.length >= 5 && /^ge.*(?:t|en)$/u.test(word))\n}\n\n/** The last clause has a modal verb and no infinitive after it yet: \"du sollst auf den Kalender\". */\nfunction modalWithoutInfinitive(transcript: string): boolean {\n const clause = wordsOf(transcript.split(/[,;:]/u).at(-1) ?? '')\n const modal = clause.findIndex(word => MODAL_VERBS.has(word))\n return modal !== -1 && !clause.slice(modal + 1).some(looksLikeVerbEnd)\n}\n\n// Words a modal clause often ends on without an infinitive (\"Ich muss los\", \"Das kann ich\").\nconst MODAL_COMPLETERS = new Set([\n 'los',\n 'weg',\n 'nicht',\n 'schon',\n 'ja',\n 'auch',\n 'mit',\n 'hin',\n 'her',\n 'raus',\n 'rein',\n 'zu',\n 'an',\n 'aus',\n 'gern',\n 'gerne',\n ...PRONOUNS,\n])\n\n// Spoken German ends many a sentence on \"das\" as a pronoun (\"Ja, mach das\").\nconst SENTENCE_FINAL_ARTICLES = new Set(['das'])\n\n/**\n * True when the words themselves leave the thought open, whatever the punctuation: a joining word,\n * a preposition or possessive, a filler, a subordinating word and its pronoun (\"wenn ich\"), or a\n * modal verb still waiting for its infinitive. A question or an exclamation is finished.\n */\nexport function talkOpenEnding(transcript: string): boolean {\n const words = wordsOf(transcript)\n const last = words.at(-1)\n // A question or an exclamation is taken at its word, as in `endsMidSentence`.\n if (!last || QUESTION_OR_EXCLAMATION.test(transcript.trim())) {\n return false\n }\n if ((CONTINUATION_WORDS.has(last) && !SENTENCE_FINAL_ARTICLES.has(last)) || TALK_OPEN_WORDS.has(last)) {\n return true\n }\n const before = words.at(-2)\n if (before && CLAUSE_OPENERS.has(before) && PRONOUNS.has(last)) {\n return true\n }\n // STT puts a full stop on a finished \"I think so.\" or \"Ich muss los.\", never on a trailing \"ähm\".\n if (TERMINAL_PUNCTUATION.test(transcript.trim())) {\n return false\n }\n return TALK_FILLER_WORDS.has(last) || (modalWithoutInfinitive(transcript) && !MODAL_COMPLETERS.has(last))\n}\n\n// A colon, dash or ellipsis announces more at any length; a comma only after more than a short answer.\nconst ANNOUNCING_PUNCTUATION = /(?:[;:–—-]|\\.\\.\\.|…)[\"'”’)\\]]*$/u\n\n/**\n * True when a Talk transcript reads as unfinished: its words end openly, it stops on a colon, dash\n * or ellipsis, or a longer one stops on a comma. A short answer's comma (\"Ja,\") and a missing full\n * stop count for nothing; STT puts both on finished words.\n */\nexport function talkLooksUnfinished(transcript: string): boolean {\n const text = transcript.trim()\n if (!text) {\n return false\n }\n if (talkOpenEnding(text) || ANNOUNCING_PUNCTUATION.test(text)) {\n return true\n }\n return wordsOf(text).length > TALK_SHORT_WORDS && DANGLING_PUNCTUATION.test(text)\n}\n\nexport type TalkHold = { ms: number; reason: 'short' | 'finished' | 'unfinished' }\n\n/** The silence Talk waits for after the end of speech before it sends `transcript`, and why. */\nexport function talkUtteranceHold(transcript: string): TalkHold {\n if (talkLooksUnfinished(transcript)) {\n return { ms: TALK_HOLD_UNFINISHED_MS, reason: 'unfinished' }\n }\n if (wordsOf(transcript).length <= TALK_SHORT_WORDS) {\n return { ms: TALK_HOLD_SHORT_MS, reason: 'short' }\n }\n return { ms: TALK_HOLD_MS, reason: 'finished' }\n}\n","/**\n * Wire protocol v1 between a browser transport and a voice relay: two WebSockets (speech to text,\n * streamed text to speech) and two HTTP routes (re-transcription of one utterance, one spoken clip).\n * Frozen: a change to a frame is a breaking change and a new protocol version. Fields marked optional\n * are additive and old clients ignore them.\n */\n\n/** The version of the frames below. */\nexport const VOICE_WIRE_PROTOCOL_VERSION = 1\n\n/** Where the relay routes live by default; a host may mount them elsewhere. */\nexport const VOICE_RELAY_DEFAULT_PATHS = {\n stt: '/voice/transcribe-stream',\n tts: '/voice/speak-stream',\n retranscribe: '/voice/retranscribe',\n speak: '/voice/speak',\n} as const\n\nexport type VoiceRelayRoute = keyof typeof VOICE_RELAY_DEFAULT_PATHS\n\n/**\n * Query parameters the relay reads itself. Every other query parameter (or, for `speak`, every other\n * body field) is the host's opaque scope (`sessionId`, `organizationId`, `spaceId`, …).\n * `token` carries a bearer, since a browser cannot set headers on `new WebSocket()`.\n */\nexport const RELAY_QUERY_PARAMS = ['token', 'language', 'encoding', 'voiceId', 'languageCode'] as const\n\n// ── Speech to text: WS `stt` ────────────────────────────────────────────────\n\n/**\n * `linear16`: raw 16 kHz mono PCM (Talk), so one capture feeds the socket, a pre-open buffer and the\n * re-transcription ring. Absent: the provider sniffs the container (MediaRecorder webm/opus).\n */\nexport type SttEncoding = 'linear16'\n\n/** Closed list: the value selects upstream URL params. Anything else means the container format. */\nexport function parseSttEncoding(value: unknown): SttEncoding | null {\n return value === 'linear16' ? 'linear16' : null\n}\n\n/** The sample rate of `linear16` audio, on the STT socket and the re-transcription body alike. */\nexport const LINEAR16_SAMPLE_RATE = 16_000\n\n/** Client → relay text frame; every binary frame is audio. Any other text frame is dropped. */\nexport type SttClientFrame = { type: 'stop' }\n\nexport type SttServerFrame =\n /** The provider stream is open; audio sent before this is dropped. */\n | { type: 'ready' }\n /** The provider heard speech start; `timestamp` is its stream time in seconds. */\n | { type: 'speech_started'; timestamp?: number }\n | {\n type: 'transcript'\n transcript: string\n is_final: boolean\n speech_final: boolean\n /** Window start and length in stream seconds. */\n start?: number\n duration?: number\n /** First word's start and last word's end (the window runs on through trailing silence). */\n wordsStart?: number\n wordsEnd?: number\n /** Mean word confidence. */\n confidence?: number\n /** The detected language in `multi` mode, else the stream's language. */\n language?: string\n }\n /** The stream reaches its duration cap in `inMs`; a client that keeps listening opens a new one now. */\n | { type: 'expiring'; inMs: number }\n | { type: 'error'; error: string }\n /** The provider closed its stream. */\n | { type: 'closed' }\n\nexport type SttCloseReason = 'max-duration' | 'idle-timeout' | 'upstream-error'\n\n// ── Text to speech: WS `tts` ────────────────────────────────────────────────\n\n/** Every client frame is a short JSON text frame of at most this many bytes; binary frames are ignored. */\nexport const TTS_MAX_CLIENT_FRAME_BYTES = 64 * 1024\n\n/** The PCM the TTS stream answers with: s16le, mono, this rate. */\nexport const TTS_STREAM_SAMPLE_RATE = 24_000\n\nexport type TtsClientFrame =\n /** Reply text as it is written; `flush` asks the provider to speak what it holds now. */\n | { type: 'text'; text: string; flush?: boolean }\n /** No more text: the stream ends after the last audio. */\n | { type: 'end' }\n\n/**\n * Relay → client. Per audio piece an optional `alignment` (the piece's characters) is followed by\n * exactly ONE binary frame of PCM; a client pairs each binary frame with the alignment before it.\n */\nexport type TtsServerFrame =\n | { type: 'ready'; sampleRate: number }\n | { type: 'alignment'; text: string }\n | { type: 'done' }\n /** Only a status or error code, never provider text. */\n | { type: 'error'; error: string }\n\nexport type TtsCloseReason = 'done' | 'max-duration' | 'idle-timeout' | 'upstream-error' | 'text-limit'\n\n// ── Close codes, both sockets ───────────────────────────────────────────────\n\nexport const RELAY_CLOSE_CODES = {\n /** `done`, `max-duration`, `idle-timeout`. */\n normal: 1000,\n /** `text-limit` (TTS). */\n policy: 1008,\n /** `upstream-error`. */\n upstreamError: 1011,\n} as const\n\n// ── Re-transcription: POST `retranscribe` ───────────────────────────────────\n\n/** The body's content type: raw `linear16` at 16 kHz. */\nexport const RETRANSCRIBE_CONTENT_TYPE = 'audio/l16'\n\n/** 30 s of 16 kHz mono linear16: the client's utterance ring holds no more. Above it: 413. */\nexport const RETRANSCRIBE_MAX_BYTES = 960_000\n\n/** The 200 answer of `POST retranscribe`; errors are 400/401/403/413/415/429/501/502/504 with `{ message }`. */\nexport interface RetranscribeResult {\n transcript: string\n /** The pinned language, else the detected one. */\n language: string | null\n /** How sure the provider is of the detected language; null with a pinned language. */\n languageConfidence: number | null\n /** How sure the provider is of the words, so a client can compare two languages' transcripts. */\n confidence: number | null\n}\n\n// ── One spoken clip: POST `speak` ───────────────────────────────────────────\n\n/** The JSON body of `POST speak` (answer: `audio/mpeg`). Other fields are the host's scope. */\nexport interface SpeakRequestBody {\n text: string\n voiceId?: string | null\n languageCode?: string | null\n /** Speak on the expressive (v4) model so `[[...]]` audio tags are performed; for short clips. */\n expressive?: boolean\n /** Speak on the low-latency model. */\n lowLatency?: boolean\n}\n\n/** The error body of every relay HTTP answer other than 200. */\nexport interface RelayErrorBody {\n message: string\n code?: string\n}\n"],"mappings":";;;;;;;;;;AAUA,MAAM,aAAa;AACnB,MAAM,mBAAmB;AAEzB,MAAM,cAAc;;AAGpB,SAAgB,eAAe,MAAsB;CACnD,OAAO,KAAK,QAAQ,IAAI,OAAO,YAAY,IAAI,GAAG,EAAE;AACtD;;;;;AAMA,SAAgB,eAAe,KAAa,WAA2B;CACrE,MAAM,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,WAAW,IAAI,MAAM,CAAC;CACvD,IAAI,UAAU;CACd,KAAK,MAAM,SAAS,IAAI,SAAS,IAAI,OAAO,YAAY,IAAI,CAAC,GAAG;EAC9D,MAAM,QAAQ,MAAM,SAAS;EAC7B,IAAI,SAAS,KACX;EAEF,WAAW,KAAK,IAAI,MAAM,EAAE,CAAC,QAAQ,MAAM,KAAK;CAClD;CACA,OAAO,MAAM;AACf;;;;;AAMA,SAAgB,kBAAkB,MAAsB;CACtD,OAAO,KAAK,QAAQ,kBAAkB,EAAE;AAC1C;;;;;AAMA,SAAgB,gBAAgB,MAAsB;CACpD,MAAM,QAAQ,YAAY,KAAK,IAAI;CACnC,IAAI,OACF,OAAO,MAAM;CAEf,OAAO,KAAK,SAAS,GAAG,IAAI,KAAK,SAAS,IAAI;AAChD;;;;AAKA,SAAgB,iBAAiB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CAAW;AAAc;;AAW7F,SAAgB,iBAAiB,OAAoC;CACnE,OAAO,UAAU,aAAa,aAAa;AAC7C;;AAGA,MAAa,uBAAuB;;AAqCpC,MAAa,6BAA6B;;AAG1C,MAAa,yBAAyB;AAuBtC,MAAa,oBAAoB;;CAE/B,QAAQ;;CAER,QAAQ;;CAER,eAAe;AACjB;;AAKA,MAAa,4BAA4B;;AAGzC,MAAa,yBAAyB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,92 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skaile/forge-voice",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Headless voice conversation stack: shared speech types and wire protocol, audio tags, keyterm budget, a browser engine (capture, VAD and barge-in, echo filter, streaming speech playback) with a relay transport and a turn-taking Talk session over the host's agent, and a framework-free relay to Deepgram (speech to text) and ElevenLabs (text to speech) with forced provider privacy settings, plus an h3 adapter.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/skaile-ai/forge.git",
|
|
10
|
+
"directory": "packages/voice"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/skaile-ai/forge/tree/main/packages/voice#readme",
|
|
13
|
+
"bugs": "https://github.com/skaile-ai/forge/issues",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"voice",
|
|
16
|
+
"speech-to-text",
|
|
17
|
+
"text-to-speech",
|
|
18
|
+
"deepgram",
|
|
19
|
+
"elevenlabs",
|
|
20
|
+
"websocket",
|
|
21
|
+
"relay",
|
|
22
|
+
"vad",
|
|
23
|
+
"barge-in",
|
|
24
|
+
"webaudio"
|
|
25
|
+
],
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"README.md",
|
|
29
|
+
"CHANGELOG.md",
|
|
30
|
+
"LICENSE"
|
|
31
|
+
],
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=22"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"prebuild": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
41
|
+
"build": "tsdown",
|
|
42
|
+
"test": "bun --bun vitest run",
|
|
43
|
+
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.browser.json",
|
|
44
|
+
"check": "bun ../../scripts/check-package.ts"
|
|
45
|
+
},
|
|
46
|
+
"exports": {
|
|
47
|
+
".": {
|
|
48
|
+
"forge-voice-source": "./src/index.ts",
|
|
49
|
+
"types": "./dist/index.d.mts",
|
|
50
|
+
"import": "./dist/index.mjs",
|
|
51
|
+
"default": "./dist/index.mjs"
|
|
52
|
+
},
|
|
53
|
+
"./browser": {
|
|
54
|
+
"forge-voice-source": "./src/browser/index.ts",
|
|
55
|
+
"types": "./dist/browser/index.d.mts",
|
|
56
|
+
"import": "./dist/browser/index.mjs",
|
|
57
|
+
"default": "./dist/browser/index.mjs"
|
|
58
|
+
},
|
|
59
|
+
"./server": {
|
|
60
|
+
"forge-voice-source": "./src/server/index.ts",
|
|
61
|
+
"types": "./dist/server/index.d.mts",
|
|
62
|
+
"import": "./dist/server/index.mjs",
|
|
63
|
+
"default": "./dist/server/index.mjs"
|
|
64
|
+
},
|
|
65
|
+
"./h3": {
|
|
66
|
+
"forge-voice-source": "./src/h3/index.ts",
|
|
67
|
+
"types": "./dist/h3/index.d.mts",
|
|
68
|
+
"import": "./dist/h3/index.mjs",
|
|
69
|
+
"default": "./dist/h3/index.mjs"
|
|
70
|
+
},
|
|
71
|
+
"./package.json": "./package.json"
|
|
72
|
+
},
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"h3": "^1.15.0",
|
|
75
|
+
"ws": "^8.18.0"
|
|
76
|
+
},
|
|
77
|
+
"peerDependenciesMeta": {
|
|
78
|
+
"h3": {
|
|
79
|
+
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"ws": {
|
|
82
|
+
"optional": true
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"devDependencies": {
|
|
86
|
+
"@types/node": "^22.0.0",
|
|
87
|
+
"@types/ws": "^8.18.2",
|
|
88
|
+
"h3": "^1.15.11",
|
|
89
|
+
"typescript": "^5.9.3",
|
|
90
|
+
"ws": "^8.18.3"
|
|
91
|
+
}
|
|
92
|
+
}
|