bellows-voice 0.4.1 → 0.5.0
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/README.md +20 -0
- package/THIRD_PARTY_NOTICES.md +1 -0
- package/dist/catalog.gen.d.ts.map +1 -1
- package/dist/chunk-5JCPPIX7.js +6 -0
- package/dist/chunk-5JCPPIX7.js.map +7 -0
- package/dist/chunk-FCBNIGIO.js +3 -0
- package/dist/chunk-FCBNIGIO.js.map +7 -0
- package/dist/chunk-OIBHJK7R.js +6 -0
- package/dist/chunk-OIBHJK7R.js.map +7 -0
- package/dist/dsp/junction-airway.d.ts +5 -0
- package/dist/dsp/junction-airway.d.ts.map +1 -1
- package/dist/engine.js +1 -1
- package/dist/engine.js.map +3 -3
- package/dist/engines/vocal-beats.d.ts +31 -0
- package/dist/engines/vocal-beats.d.ts.map +1 -0
- package/dist/engines/vocal-planner.d.ts +37 -0
- package/dist/engines/vocal-planner.d.ts.map +1 -1
- package/dist/engines/vocal.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/lyrics/accents.d.ts.map +1 -1
- package/dist/lyrics/beat.d.ts +49 -0
- package/dist/lyrics/beat.d.ts.map +1 -0
- package/dist/lyrics/read.d.ts.map +1 -1
- package/dist/lyrics/speech.d.ts.map +1 -1
- package/dist/sing.d.ts.map +1 -1
- package/dist/singer.d.ts +15 -0
- package/dist/singer.d.ts.map +1 -1
- package/dist/text.d.ts +2 -0
- package/dist/text.d.ts.map +1 -1
- package/dist/text.js +1 -1
- package/dist/view/tract.d.ts +4 -0
- package/dist/view/tract.d.ts.map +1 -1
- package/dist/view.js +1 -1
- package/dist/view.js.map +3 -3
- package/dist/voices.d.ts.map +1 -1
- package/dist/worklet-code.gen.d.ts.map +1 -1
- package/dist/worklet.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lyrics/ipa.ts", "../src/lyrics/arpabet.ts", "../src/lyrics/letter-to-sound.ts", "../src/lyrics/syllabify.ts", "../src/lyrics/lexical-sets.ts", "../src/lyrics/english.ts", "../src/lyrics/ipa-front-end.ts", "../src/lyrics/allophones.ts", "../src/lyrics/accents.ts", "../src/lyrics/read.ts", "../src/lyrics/cmudict.ts", "../src/lyrics/sing.ts", "../src/lyrics/durations.ts", "../src/lyrics/pronounce.ts", "../src/lyrics/speech.ts", "../src/lyrics/beat.ts", "../src/voices.ts"],
|
|
4
|
+
"sourcesContent": ["/*\n * IPA text to segments: stress marks, length, syllable dots, word gaps, pauses,\n * affricates and diphthongs, with every diacritic the voice cannot render dropped.\n *\n * Ported from CHIMERA by Jameson Hodge (MIT),\n * https://github.com/jamesondh/chimera-vocal-synth, crates/chimera/src/phonetics/ipa.rs at\n * 1d3ea49 (TypeScript original at cd247a6^:src/engine/phonetics/ipa.ts). Changes from the\n * original: Segment has no sound-mark flags or word ends, so \u02B0 \u02ED \u02B2 \u02B1, nasal and breathy marks\n * are dropped and boundaries go to readIpa's `breaks`; only t\u0283 d\u0292 and the English diphthongs\n * join; an accented letter keeps its base; a syllabic consonant is sung on a \u0259 before it; a\n * Latin or Greek letter outside the inventory is kept, to be reported, where upstream dropped\n * it. See THIRD_PARTY_NOTICES.md.\n *\n * Reading rules, in order of the scan:\n *\n * - \u02C8 (or ') and \u02CC give primary and secondary stress to the next vowel. A consonant does not\n * take it, so /\u02C8tw\u026A\u014B/ stresses the \u026A, as dictionaries write it.\n * - \u02D0 (or :) lengthens the segment before it by 1.7, from CHIMERA's bases of 0.15 s for a\n * vowel and 0.09 s for a consonant when it has no duration yet.\n * - A dot ends a syllable, whitespace ends a word, and a comma, | or \u2016 ends a word and writes a\n * '_' pause of 0.16 s (the vocal engine's silence phoneme).\n * - t\u0283 d\u0292 a\u026A a\u028A \u0254\u026A e\u026A o\u028A are one token each. CHIMERA also joins ts dz pf t\u0255 d\u0291 t\u0282 d\u0290 for German\n * and Mandarin; here they stay two, because English /k\u00E6ts/ is k \u00E6 t s and no bellows engine\n * has those affricates. Tie bars are removed, so t\u0361\u0283 reads as t\u0283 and t\u0361s as t s.\n * - Combining marks are read and dropped, except the syllabic mark (U+0329 below, U+030D\n * above): a syllabic consonant has no vowel to carry a note, so /\u02C8b\u028Ctn\u0329/ sings \u02C8b\u028C.t\u0259n.\n * - A lower-case Latin or Greek letter that is not a known symbol (\u028D \u0253 \u0298 \u01C0 \u03BB) is kept as a\n * consonant. No voice here has a sound for it, but kept, it reaches the facade, which lists it\n * in `unknown` and holds the sound before it for its time; dropped, a lyric lost a sound and\n * nobody was told. Greek \u03B5 and \u03B1, the usual slips for \u025B and \u0251, read as those.\n * - Anything else that is not a known symbol is skipped: digits, capitals, modifier letters\n * such as \u02B0 \u02B7 \u02BC (marks on the sound before them), other scripts.\n *\n * Text is NFC-normalized first and then each letter that is not itself a known symbol is\n * decomposed, so a precomposed U+00E1 keeps its a, as a followed by U+0301 always did. CHIMERA\n * keeps the base of seven nasal and breathy vowels this way and drops every other accented\n * letter whole, which loses a tone-marked vowel and with it a sung syllable. \u00E7 (U+00E7) stays\n * whole, being a letter in its own right, and U+1E09 recomposes to \u00E7 before its acute drops.\n */\n\nimport type { Segment } from './types';\n\n/** First characters of a vowel token (ipa.rs VOWEL_CHARS). */\nconst VOWEL_CHARS = 'iy\u0268\u0289\u026Fu\u026A\u028F\u028Ae\u00F8\u0258\u0275\u0264o\u0259\u025B\u0153\u025C\u025E\u028C\u0254\u00E6\u0250a\u0276\u0251\u0252\u025D\u025A';\n\n/** The single-character consonants of CHIMERA's inventory (inventory.rs base()). */\nconst CONSONANT_CHARS =\n 'pbtd\u0288\u0256c\u025Fkgq\u0262\u0294' + 'm\u0271n\u0273\u0272\u014B\u0274' + '\u0278\u03B2fv\u03B8\u00F0sz\u0283\u0292\u0282\u0290\u00E7\u029Dx\u0263\u03C7\u0281\u0127\u0295h\u0266\u026C\u026E\u0255\u0291' + 'w\u028B\u0279\u027Bj\u0265\u0270l\u026B\u026D\u028E\u027E\u027Dr\u0280\u0299';\n\n/** Tokens longer than one character. The scan takes the one that matches at a position. */\nconst MULTI = ['t\u0283', 'd\u0292', 'a\u026A', 'a\u028A', '\u0254\u026A', 'e\u026A', 'o\u028A'] as const;\n\n/** Spellings of a known symbol by another code point. */\nconst ALIASES: ReadonlyMap<string, string> = new Map([\n ['\u0261', 'g'],\n ['\u02A7', 't\u0283'],\n ['\u02A4', 'd\u0292'],\n ['\u03B5', '\u025B'],\n ['\u03B1', '\u0251'],\n // the reduced vowels of some dictionaries, and the old IPA letters for \u026A and \u028A\n ['\u1D7B', '\u026A'],\n ['\u1D7F', '\u028A'],\n ['\u0269', '\u026A'],\n ['\u0277', '\u028A'],\n // ligature affricates, read as their tie-bar spellings are\n ['\u02A6', 'ts'],\n ['\u02A3', 'dz'],\n ['\u02A8', 't\u0255'],\n ['\u02A5', 'd\u0291'],\n]);\n\n/** A lower-case letter of the scripts IPA is written in, which is a sound even when it is not a known one. */\nconst IPA_LETTER = /^(?=[\\p{Ll}\\p{Lo}])[\\p{Script=Latin}\\p{Script=Greek}]$/u;\n\nconst VOWELS = new Set(Array.from(VOWEL_CHARS));\nconst KNOWN = new Set<string>([...VOWEL_CHARS, ...CONSONANT_CHARS, ...MULTI]);\n\n/** The silence a comma or a bar writes, as the vocal engine's '_' phoneme. */\nexport const PAUSE = '_';\nconst PAUSE_DUR = 0.16;\n/** Bases the length mark scales when a segment has no duration yet (ipa.rs). */\nconst LONG_VOWEL_BASE = 0.15;\nconst LONG_CONSONANT_BASE = 0.09;\nconst LENGTH_FACTOR = 1.7;\n\nconst SYLLABIC_BELOW = '\\u0329';\nconst SYLLABIC_ABOVE = '\\u030D';\nconst TIE_BARS = /[\\u035C\\u0361]/g;\n\n/** What follows a segment in written IPA. */\nexport const BREAK_NONE = 0;\nexport const BREAK_SYLLABLE = 1;\nexport const BREAK_WORD = 2;\n\nexport interface IpaReading {\n /** The segments in order, with a '_' segment for each pause. */\n segments: Segment[];\n /** breaks[i] is BREAK_NONE, BREAK_SYLLABLE or BREAK_WORD: what follows segments[i]. */\n breaks: number[];\n}\n\n/** A vowel or diphthong symbol, by its first character. */\nexport function isVowel(ipa: string): boolean {\n const first = ipa.codePointAt(0);\n return first !== undefined && VOWELS.has(String.fromCodePoint(first));\n}\n\n/** IPA text to its segments, in order. Never throws; unknown characters are skipped. */\nexport function tokenizeIpa(input: string): Segment[] {\n return readIpa(input).segments;\n}\n\n/** IPA text to its segments and the syllable and word boundaries written between them. */\nexport function readIpa(input: string): IpaReading {\n const s = Array.from(prepare(input));\n const segments: Segment[] = [];\n const breaks: number[] = [];\n let stress: 0 | 1 | 2 = 0;\n let i = 0;\n while (i < s.length) {\n const ch = s[i];\n if (ch === '\u02C8' || ch === \"'\") {\n stress = 1;\n i++;\n continue;\n }\n if (ch === '\u02CC') {\n stress = 2;\n i++;\n continue;\n }\n if (ch === '.') {\n markBreak(breaks, BREAK_SYLLABLE);\n i++;\n continue;\n }\n if (ch === ',' || ch === '|' || ch === '\u2016') {\n markBreak(breaks, BREAK_WORD);\n segments.push({ ipa: PAUSE, dur: PAUSE_DUR });\n breaks.push(BREAK_NONE);\n i++;\n continue;\n }\n if (/\\s/.test(ch)) {\n markBreak(breaks, BREAK_WORD);\n i++;\n continue;\n }\n if (ch === '\u02D0' || ch === ':') {\n const last = segments[segments.length - 1];\n if (last) {\n const base = isVowel(last.ipa) ? LONG_VOWEL_BASE : LONG_CONSONANT_BASE;\n last.dur = (last.dur ?? base) * LENGTH_FACTOR;\n }\n i++;\n continue;\n }\n let tok = ch;\n for (const m of MULTI) if (startsAt(s, i, m)) tok = m;\n i += tok === ch ? 1 : Array.from(tok).length;\n let syllabic = false;\n while (i < s.length && isCombining(s[i])) {\n if (s[i] === SYLLABIC_BELOW || s[i] === SYLLABIC_ABOVE) syllabic = true;\n i++;\n }\n if (!KNOWN.has(tok) && !IPA_LETTER.test(tok)) continue;\n if (isVowel(tok)) {\n segments.push({ ipa: tok, stress });\n breaks.push(BREAK_NONE);\n stress = 0;\n continue;\n }\n if (syllabic) {\n segments.push({ ipa: '\u0259', stress });\n breaks.push(BREAK_NONE);\n stress = 0;\n }\n segments.push({ ipa: tok });\n breaks.push(BREAK_NONE);\n }\n return { segments, breaks };\n}\n\nfunction markBreak(breaks: number[], kind: number): void {\n const last = breaks.length - 1;\n if (last >= 0 && breaks[last] < kind) breaks[last] = kind;\n}\n\nfunction startsAt(s: readonly string[], i: number, token: string): boolean {\n let k = i;\n for (const c of token) {\n if (s[k] !== c) return false;\n k++;\n }\n return true;\n}\n\nfunction isCombining(c: string): boolean {\n return c >= '\\u0300' && c <= '\\u036F';\n}\n\n/** NFC, then each unknown letter decomposed so its base survives, then aliases and tie bars. */\nfunction prepare(input: string): string {\n let out = '';\n for (const ch of input.normalize('NFC')) {\n if (KNOWN.has(ch)) {\n out += ch;\n continue;\n }\n const alias = ALIASES.get(ch);\n if (alias !== undefined) {\n out += alias;\n continue;\n }\n const parts = Array.from(ch.normalize('NFD'));\n if (parts.length > 1) {\n /* \u1E09 is \u00E7 plus an acute: keep the letter the first mark makes, when that is a symbol. */\n const head = (parts[0] + parts[1]).normalize('NFC');\n if (KNOWN.has(head)) {\n out += head + parts.slice(2).join('');\n continue;\n }\n }\n out += parts.join('');\n }\n return out.replace(TIE_BARS, '');\n}\n", "/*\n * ARPAbet, the phone set of the CMU Pronouncing Dictionary, to IPA segments.\n *\n * Ported from CHIMERA by Jameson Hodge (MIT),\n * https://github.com/jamesondh/chimera-vocal-synth, crates/chimera/src/phonetics/english.rs at\n * 1d3ea49 (TypeScript original at cd247a6^:src/engine/phonetics/english.ts). Changes from the\n * original: a consonant carries no stress field. See THIRD_PARTY_NOTICES.md.\n *\n * A phone is an upper-case base with an optional stress digit, 0 unstressed, 1 primary,\n * 2 secondary (\"AH0\", \"OW1\"); the dictionary puts digits on vowels only. Unstressed AH is the\n * schwa and unstressed ER the r-coloured schwa, the CMUdict convention. A phone that is not\n * that shape, or names no ARPAbet sound, is skipped.\n */\n\nimport type { Segment } from './types';\nimport { isVowel } from './ipa';\n\nconst ARPA: ReadonlyMap<string, string> = new Map([\n ['AA', '\u0251'], ['AE', '\u00E6'], ['AH', '\u028C'], ['AO', '\u0254'], ['AW', 'a\u028A'], ['AY', 'a\u026A'], ['EH', '\u025B'],\n ['ER', '\u025D'], ['EY', 'e\u026A'], ['IH', '\u026A'], ['IY', 'i'], ['OW', 'o\u028A'], ['OY', '\u0254\u026A'], ['UH', '\u028A'],\n ['UW', 'u'],\n ['B', 'b'], ['CH', 't\u0283'], ['D', 'd'], ['DH', '\u00F0'], ['F', 'f'], ['G', 'g'], ['HH', 'h'],\n ['JH', 'd\u0292'], ['K', 'k'], ['L', 'l'], ['M', 'm'], ['N', 'n'], ['NG', '\u014B'], ['P', 'p'],\n ['R', '\u0279'], ['S', 's'], ['SH', '\u0283'], ['T', 't'], ['TH', '\u03B8'], ['V', 'v'], ['W', 'w'],\n ['Y', 'j'], ['Z', 'z'], ['ZH', '\u0292'],\n]);\n\nconst PHONE = /^([A-Z]+)([012])?$/;\n\n/** \"HH AH0 L OW1\" to h \u0259 l o\u028A, the vowels stressed as the digits say. Never throws. */\nexport function arpabetToSegments(phones: string): Segment[] {\n const out: Segment[] = [];\n for (const ph of phones.trim().split(/\\s+/)) {\n const m = PHONE.exec(ph);\n if (!m) continue;\n const base = m[1];\n const stress = m[2] === '1' ? 1 : m[2] === '2' ? 2 : 0;\n let ipa = ARPA.get(base);\n if (ipa === undefined) continue;\n if (stress === 0 && base === 'AH') ipa = '\u0259';\n if (stress === 0 && base === 'ER') ipa = '\u025A';\n out.push(isVowel(ipa) ? { ipa, stress } : { ipa });\n }\n return out;\n}\n", "/*\n * Letter-to-sound rules: a pronunciation for an English word no dictionary has, or for every\n * word when no dictionary is given. Crude but deterministic; a dictionary or /IPA/ in the lyric\n * is the way to get a word exactly.\n *\n * Ported from CHIMERA by Jameson Hodge (MIT),\n * https://github.com/jamesondh/chimera-vocal-synth, crates/chimera/src/phonetics/english.rs at\n * 1d3ea49 (TypeScript original at cd247a6^:src/engine/phonetics/english.ts). Changes from the\n * original: a doubled consonant sounds once; \"he\", \"the\" say i, \"my\", \"fly\" say a\u026A and \"la\",\n * \"spa\" say \u0251; \"le\" is a syllable only after a consonant. See THIRD_PARTY_NOTICES.md.\n *\n * Each rule is (before, letters, after, phones). At each position the rules are tried in table\n * order and the first whose letters and contexts match wins; a position no rule matches is\n * skipped. Contexts: '#' the word boundary, 'V' a vowel letter (a e i o u y), 'C' any other\n * character, anything else a literal letter. The first vowel takes primary stress.\n *\n * Upstream loads CMUdict at start-up, so these rules rarely run there. Bellows ships no\n * dictionary, so here they are the default, and the changes are the ones that cost a sung line\n * a note or a word. Each was measured against the 117,493 lower-case alphabetic words of the\n * cmudict.dict copy CHIMERA ships (first pronunciation of each word):\n *\n * - Doubled consonants. English doubles a consonant letter to keep the vowel before it short\n * (\"hopping\", not \"hoping\"), so the rules must see both letters but the word has one\n * consonant. Upstream sang two, a coda and an onset, which on a stop is two closures. Equal\n * adjacent consonants are merged as the phones are emitted, which also merges \"c\" + \"qu\" and\n * \"x\" + \"c\" (\"acquire\", \"excel\").\n * - A final e after one or two consonants that open the word is the word's only vowel, so it\n * is not silent: \"he\", \"she\", \"the\", \"me\", \"we\", \"be\". Upstream gave them no vowel, so they\n * had no syllable and vanished from a lyric; that was 6 of 161 common lyric words and 224\n * dictionary words, now 0 and 198. The vowel matches CMUdict on 14 of these 27 dictionary\n * words, up from 1.\n * - A final y after one to three consonants that open the word says a\u026A: \"my\", \"by\", \"fly\",\n * \"try\", \"spry\". Upstream sang them with i, which matched CMUdict on 0 of 28; now 27.\n * - A final a after one or two consonants that open the word says \u0251: \"la\", \"ma\", \"pa\", \"spa\",\n * \"bra\". Upstream sang \u00E6, so `sing('la la la')` sang \"l\u00E6\u00E6\", matching CMUdict on 0 of its 36\n * such words; now 23, the rest being letter names (\"dna\", \"nba\") and \"ca\", \"sta\".\n * - \"le\" at the end is a syllable after a consonant (\"twin-kle\") but not after a vowel, where\n * the e is silent (\"smile\", \"while\", \"pale\"). Same syllable count as CMUdict on 422 of 529\n * vowel + \"le\" words, up from 75, and unchanged on the 1,768 consonant + \"le\" words.\n */\n\nimport type { Segment } from './types';\nimport { isVowel } from './ipa';\n\ntype Rule = readonly [before: string, letters: string, after: string, phones: string];\n\nconst RULES: readonly Rule[] = [\n // English endings and spellings ahead of the general rules, each group scored against the CMU dictionary\n // over 115,507 words and two lists of 827 common and lyric words (no list word lost; MEASURED 2026-11-13)\n // monosyllable -ed/-es keep their vowel (red, bed, yes)\n ['#C', 'ed', '#', '\u025B d'], ['#CC', 'ed', '#', '\u025B d'], ['#CCC', 'ed', '#', '\u025B d'], ['#C', 'es', '#', '\u025B s'],\n ['#CC', 'es', '#', '\u025B s'], ['#y', 'es', '#', '\u025B s'],\n // -ed after t/d is \u026Ad, after voiceless is t\n ['t', 'ed', '#', '\u026A d'], ['d', 'ed', '#', '\u026A d'], ['k', 'ed', '#', 't'], ['p', 'ed', '#', 't'],\n ['s', 'ed', '#', 't'], ['f', 'ed', '#', 't'], ['x', 'ed', '#', 't'], ['h', 'ed', '#', 't'], ['c', 'ed', '#', 't'],\n // -es after sibilants is \u026Az (kisses, roses, changes)\n ['s', 'es', '#', '\u026A z'], ['z', 'es', '#', '\u026A z'], ['x', 'es', '#', '\u026A z'], ['h', 'es', '#', '\u026A z'],\n ['c', 'es', '#', '\u026A z'], ['g', 'es', '#', '\u026A z'],\n // final s after a voiced consonant letter is z\n ['r', 's', '#', 'z'], ['l', 's', '#', 'z'], ['m', 's', '#', 'z'], ['n', 's', '#', 'z'], ['d', 's', '#', 'z'],\n ['g', 's', '#', 'z'], ['b', 's', '#', 'z'], ['v', 's', '#', 'z'], ['w', 's', '#', 'z'],\n // final -us is s (bus, chorus)\n ['u', 's', '#', 's'],\n // ng is \u014B before s/ing/ly/ed, n before k is \u014B\n ['', 'ng', 's#', '\u014B'], ['', 'ng', 'ing', '\u014B'], ['', 'ng', 'ly', '\u014B'], ['', 'ng', 'ed#', '\u014B'], ['', 'n', 'k', '\u014B'],\n // ew is u, j u after f p m h; iew is j u\n ['', 'iew', '', 'j u'], ['f', 'ew', '', 'j u'], ['p', 'ew', '', 'j u'], ['m', 'ew', '', 'j u'],\n ['h', 'ew', '', 'j u'], ['', 'ew', '', 'u'],\n // -ous/-cious/-tious\n ['', 'cious', '', '\u0283 \u0259 s'], ['', 'tious', '', '\u0283 \u0259 s'], ['', 'ous', '#', '\u0259 s'],\n // ow: a\u028A after word-initial h n c w v, o\u028A before s/ing/ly/ed\n ['#h', 'ow', '', 'a\u028A'], ['#n', 'ow', '', 'a\u028A'], ['#c', 'ow', '', 'a\u028A'], ['#w', 'ow', '', 'a\u028A'],\n ['#v', 'ow', '', 'a\u028A'], ['#all', 'ow', '', 'a\u028A'], ['', 'ow', 's#', 'o\u028A'], ['', 'ow', 'ing', 'o\u028A'],\n ['', 'ow', 'ly', 'o\u028A'], ['', 'ow', 'ed#', 'o\u028A'],\n // own is o\u028A n after l h n gr thr and word-initially\n ['#', 'ow', 'n', 'o\u028A'], ['l', 'ow', 'n', 'o\u028A'], ['h', 'ow', 'n', 'o\u028A'], ['n', 'ow', 'n', 'o\u028A'],\n ['gr', 'ow', 'n', 'o\u028A'], ['thr', 'ow', 'n', 'o\u028A'],\n // final o is o\u028A\n ['', 'o', '#', 'o\u028A'],\n // old/olt is o\u028A\n ['', 'o', 'ld', 'o\u028A'], ['', 'o', 'lt', 'o\u028A'],\n // ind/ild is a\u026A\n ['', 'i', 'nd#', 'a\u026A'], ['', 'i', 'nds#', 'a\u026A'], ['', 'i', 'nding', 'a\u026A'], ['', 'i', 'ndly', 'a\u026A'],\n ['', 'i', 'ndness', 'a\u026A'], ['', 'i', 'ld#', 'a\u026A'], ['', 'i', 'ldly', 'a\u026A'],\n // all/alk is \u0254\n ['', 'all', '#', '\u0254 l'], ['', 'all', 's#', '\u0254 l'], ['', 'all', 'ing', '\u0254 l'], ['', 'all', 'ed#', '\u0254 l'],\n ['', 'alk', '', '\u0254 k'],\n // war is w \u0254 \u0279, wa+CC is w \u0251\n ['w', 'ar', '', '\u0254 \u0279'], ['w', 'a', 'CC', '\u0251'], ['w', 'a', 'C#', '\u0251'],\n // ea is \u025B before d#, dy, lth, th#, ther, v+y/en, sant, sure\n ['', 'ea', 'd#', '\u025B'], ['', 'ea', 'dy', '\u025B'], ['', 'ea', 'lth', '\u025B'], ['', 'ea', 'th#', '\u025B'],\n ['', 'ea', 'ther', '\u025B'], ['', 'ea', 'vy', '\u025B'], ['', 'ea', 'ven', '\u025B'], ['', 'ea', 'sant', '\u025B'],\n ['', 'ea', 'sure', '\u025B'], ['', 'ea', 'dow', '\u025B'],\n // oo is \u028A before k, in good wood hood stood foot; door floor\n ['', 'oo', 'k', '\u028A'], ['g', 'oo', 'd', '\u028A'], ['w', 'oo', 'd', '\u028A'], ['h', 'oo', 'd', '\u028A'], ['t', 'oo', 'd', '\u028A'],\n ['f', 'oo', 't', '\u028A'], ['d', 'oo', 'r', '\u0254'], ['fl', 'oo', 'r', '\u0254'],\n // o is \u028C in love, above, cover, some, come, wonder, money, honey, month, other\n ['l', 'o', 've', '\u028C'], ['l', 'o', 'vi', '\u028C'], ['b', 'o', 've#', '\u028C'], ['c', 'o', 'ver', '\u028C'],\n ['s', 'o', 'me', '\u028C'], ['c', 'o', 'me', '\u028C'], ['w', 'o', 'n', '\u028C'], ['', 'o', 'ney', '\u028C'], ['', 'o', 'nth', '\u028C'],\n ['', 'o', 'ther', '\u028C'], ['', 'o', 'thing', '\u028C'],\n // th is \u00F0 before er and in final the\n ['', 'th', 'er', '\u00F0'], ['', 'th', 'e#', '\u00F0'],\n // ear is \u025D before l n ch th; heart\n ['', 'ear', 'l', '\u025D'], ['', 'ear', 'n', '\u025D'], ['', 'ear', 'ch', '\u025D'], ['', 'ear', 'th', '\u025D'],\n ['h', 'ear', 'd#', '\u025D'], ['h', 'ear', 't', '\u0251 \u0279'],\n // are# is \u025B \u0279, a before rr is \u00E6\n ['C', 'are', '#', '\u025B \u0279'], ['', 'a', 'rr', '\u00E6'],\n // ar+V is \u025B \u0279\n ['C', 'a', 'rV', '\u025B'],\n // ire is a\u026A \u0279, one syllable as a sung word keeps one note (fire, tire, inspire); sure\n ['', 'i', 're#', 'a\u026A'], ['V', 'sure', '', '\u0292 \u025A'], ['#', 's', 'ure', '\u0283'], ['', 'ure', '#', '\u028A \u0279'],\n // i is \u026A in -ity, -tive; -ily is \u0259\n ['', 'i', 'ty#', '\u026A'], ['t', 'i', 've#', '\u026A'], ['C', 'i', 'ly#', '\u0259'],\n // i+v+V is \u026A\n ['', 'i', 'ver', '\u026A'], ['', 'i', 'ven', '\u026A'],\n // initial a+CV is \u0259 (but a_e is e\u026A); initial awa is \u0259\n ['#', 'a', 'Ce#', 'e\u026A'], ['#', 'a', 'wa', '\u0259'], ['#', 'a', 'CV', '\u0259'],\n // u+CV is j u after initial, m f p b c h\n ['#', 'u', 'CV', 'j u'], ['m', 'u', 'CV', 'j u'], ['f', 'u', 'CV', 'j u'], ['p', 'u', 'CV', 'j u'],\n ['b', 'u', 'CV', 'j u'], ['c', 'u', 'CV', 'j u'], ['h', 'u', 'CV', 'j u'],\n // ou: soul, touch, young, double, country; ought\n ['', 'ough', 't', '\u0254'], ['', 'ou', 'l', 'o\u028A'], ['', 'ou', 'ng', '\u028C'], ['', 'ou', 'ble', '\u028C'],\n ['', 'ou', 'ntry', '\u028C'],\n // our is \u0254 \u0279 after f p y c s\n ['f', 'our', '', '\u0254 \u0279'], ['p', 'our', '', '\u0254 \u0279'], ['c', 'our', '', '\u0254 \u0279'], ['s', 'our', '', '\u0254 \u0279'],\n // initial gi is g\n ['#', 'g', 'i', 'g'],\n // wor+C is w \u025D\n ['w', 'or', 'n', '\u0254 \u0279'], ['w', 'or', 'C', '\u025D'],\n // er+r is \u025B; -ery/-ory after VC are \u025A\n ['', 'er', 'r', '\u025B'], ['VC', 'er', 'y#', '\u025A'], ['VC', 'or', 'y#', '\u025A'], ['VC', 'or', 'ies#', '\u025A'],\n // ange is e\u026A n d\u0292, angel\n ['', 'a', 'nge#', 'e\u026A'], ['', 'a', 'nges#', 'e\u026A'], ['', 'a', 'nged#', 'e\u026A'], ['', 'a', 'ngel', 'e\u026A'],\n ['', 'n', 'ge#', 'n'], ['', 'n', 'ges#', 'n'], ['', 'n', 'ged#', 'n'], ['', 'n', 'gel', 'n'],\n // final mn is m\n ['m', 'n', '#', ''],\n // initial gu+V is g\n ['#gu', 'y', '#', 'a\u026A'], ['#', 'gu', 'V', 'g'],\n // eau is j u\n ['', 'eau', 't', 'j u'],\n // initial al before so w r m th is \u0254 l\n ['#', 'al', 'so', '\u0254 l'], ['#', 'al', 'w', '\u0254 l'], ['#', 'al', 'r', '\u0254 l'], ['#', 'al', 'mo', '\u0254 l'],\n ['#', 'al', 'th', '\u0254 l'],\n // voiced s in Vse# and easo\n ['Co', 's', 'e#', 'z'], ['Ci', 's', 'e#', 'z'], ['au', 's', 'e#', 'z'], ['ai', 's', 'e#', 'z'],\n ['oi', 's', 'e#', 'z'], ['ea', 's', 'on', 'z'],\n // here/where/sphere\n ['#h', 'ere', '#', '\u026A \u0279'], ['h', 'ere', '#', '\u025B \u0279'], ['', 'ere', '#', '\u026A \u0279'],\n // ost after m p h is o\u028A; only\n ['m', 'o', 'st', 'o\u028A'], ['p', 'o', 'st', 'o\u028A'], ['h', 'o', 'st', 'o\u028A'], ['#', 'o', 'nly', 'o\u028A'],\n // silent e before a suffix (lonely, lovely, hopeful)\n ['VC', 'e', 'ly#', ''], ['VC', 'e', 'ful', ''], ['VC', 'e', 'ness', ''], ['VC', 'e', 'ment', ''],\n ['VC', 'e', 'less', ''],\n // water, father\n ['w', 'a', 'ter', '\u0254'], ['f', 'a', 'ther', '\u0251'],\n // short vowel before C+ow (shadow, widow)\n ['', 'a', 'Cow', '\u00E6'], ['', 'i', 'Cow', '\u026A'],\n // ir+V is \u026A \u0279 (spirit, miracle)\n ['', 'i', 'rV', '\u026A'],\n // for- prefix before ev/g is f \u025A\n ['#f', 'or', 'ev', '\u025A'], ['#f', 'or', 'g', '\u025A'],\n // interjections: final h after a vowel is silent, oh is o\u028A, aa is \u0251, ye, hey\n ['#', 'o', 'h#', 'o\u028A'], ['V', 'h', '#', ''], ['', 'aa', '', '\u0251'], ['#y', 'e', '#', 'i'], ['#h', 'ey', '#', 'e\u026A'],\n ['', 'eah', '#', '\u00E6'],\n // the general rules\n ['', 'tion', '', '\u0283 \u0259 n'], ['', 'sion', '', '\u0292 \u0259 n'], ['', 'ture', '', 't\u0283 \u025A'],\n ['', 'ough', '#', 'o\u028A'], ['', 'augh', '', '\u0254'], ['', 'igh', '', 'a\u026A'], ['', 'eigh', '', 'e\u026A'],\n ['', 'tch', '', 't\u0283'], ['', 'dge', '', 'd\u0292'], ['', 'sch', '', 's k'], ['', 'ch', '', 't\u0283'],\n ['', 'sh', '', '\u0283'], ['', 'th', '', '\u03B8'], ['', 'ph', '', 'f'], ['', 'wh', '', 'w'],\n ['', 'ck', '', 'k'], ['', 'ng', '#', '\u014B'], ['', 'ng', '', '\u014B g'], ['', 'qu', '', 'k w'],\n ['#', 'kn', '', 'n'], ['#', 'wr', '', '\u0279'], ['', 'gh', '', ''], ['', 'ee', '', 'i'],\n ['', 'ea', '', 'i'], ['', 'oo', '', 'u'], ['', 'ou', '', 'a\u028A'], ['', 'ow', '#', 'o\u028A'],\n ['', 'ow', '', 'a\u028A'], ['', 'oi', '', '\u0254\u026A'], ['', 'oy', '', '\u0254\u026A'], ['', 'ai', '', 'e\u026A'],\n ['', 'ay', '', 'e\u026A'], ['', 'au', '', '\u0254'], ['', 'aw', '', '\u0254'], ['', 'ie', '#', 'a\u026A'],\n ['', 'ie', '', 'i'], ['', 'ei', '', 'e\u026A'], ['', 'ey', '#', 'i'], ['', 'oa', '', 'o\u028A'],\n ['', 'ue', '#', 'u'], ['', 'er', '#', '\u025A'], ['', 'er', 'C', '\u025D'], ['', 'ir', '', '\u025D'],\n ['', 'ur', '', '\u025D'], ['', 'or', '', '\u0254 \u0279'], ['', 'ar', '', '\u0251 \u0279'], ['C', 'le', '#', '\u0259 \u026B'],\n ['', 'ed', '#', 'd'], ['', 'es', '#', 'z'], ['C', 's', '#', 's'], ['V', 's', '#', 'z'],\n ['#C', 'y', '#', 'a\u026A'], ['#CC', 'y', '#', 'a\u026A'], ['#CCC', 'y', '#', 'a\u026A'], ['', 'y', '#', 'i'],\n ['#', 'y', '', 'j'], ['C', 'y', '', 'a\u026A'], ['#C', 'e', '#', 'i'], ['#CC', 'e', '#', 'i'],\n ['', 'e', '#', ''], ['#C', 'a', '#', '\u0251'], ['#CC', 'a', '#', '\u0251'], ['', 'a', 'CV', 'e\u026A'],\n ['', 'a', '', '\u00E6'], ['', 'e', '', '\u025B'],\n ['', 'i', 'CV', 'a\u026A'], ['', 'i', '', '\u026A'], ['', 'o', 'CV', 'o\u028A'], ['', 'o', '', '\u0251'],\n ['', 'u', 'CV', 'u'], ['', 'u', '', '\u028C'], ['', 'y', '', '\u026A'], ['', 'c', 'e', 's'],\n ['', 'c', 'i', 's'], ['', 'c', 'y', 's'], ['', 'c', '', 'k'], ['', 'g', 'e', 'd\u0292'],\n ['', 'g', 'i', 'd\u0292'], ['', 'g', '', 'g'], ['', 'x', '', 'k s'], ['', 'j', '', 'd\u0292'],\n ['', 'q', '', 'k'], ['', 'b', '', 'b'], ['', 'd', '', 'd'], ['', 'f', '', 'f'],\n ['', 'h', '', 'h'], ['', 'k', '', 'k'], ['', 'l', '', 'l'], ['', 'm', '', 'm'],\n ['', 'n', '', 'n'], ['', 'p', '', 'p'], ['', 'r', '', '\u0279'], ['', 's', '', 's'],\n ['', 't', '', 't'], ['', 'v', '', 'v'], ['', 'w', '', 'w'], ['', 'z', '', 'z'],\n];\n\n/** The phones of each rule, split once. */\nconst PHONES: readonly (readonly string[])[] = RULES.map((r) => (r[3] ? r[3].split(' ') : []));\n\n/** A lower-case word to segments by rule. Never throws; characters no rule reads are skipped. */\nexport function letterToSound(word: string): Segment[] {\n const phones: string[] = [];\n let i = 0;\n while (i < word.length) {\n let matched = false;\n for (let r = 0; r < RULES.length; r++) {\n const [before, letters, after] = RULES[r];\n if (!word.startsWith(letters, i)) continue;\n if (!contextMatches(word, i - 1, before, -1)) continue;\n if (!contextMatches(word, i + letters.length, after, 1)) continue;\n for (const p of PHONES[r]) {\n if (!isVowel(p) && p === phones[phones.length - 1]) continue;\n phones.push(p);\n }\n i += letters.length;\n matched = true;\n break;\n }\n if (!matched) i++;\n }\n const out: Segment[] = [];\n // primary stress on the first full vowel: a reduced first vowel (about, forget) is unstressed\n // (MEASURED against the CMU dictionary: the stressed syllable right in 83 percent of polysyllables, from 78)\n let at = phones.findIndex((p) => isVowel(p) && p !== '\u0259' && p !== '\u025A');\n if (at < 0) at = phones.findIndex((p) => isVowel(p));\n for (let k = 0; k < phones.length; k++) {\n const ipa = phones[k];\n if (!isVowel(ipa)) out.push({ ipa });\n else out.push({ ipa, stress: k === at ? 1 : 0 });\n }\n return out;\n}\n\nfunction isVowelLetter(c: string | undefined): boolean {\n return c === 'a' || c === 'e' || c === 'i' || c === 'o' || c === 'u' || c === 'y';\n}\n\n/**\n * Whether the context string matches the word read from `at` in direction `dir` (1 forward\n * from the letters' end, -1 backward from their start). The word is indexed in UTF-16 code\n * units, as upstream's was.\n */\nfunction contextMatches(word: string, at: number, context: string, dir: 1 | -1): boolean {\n let pos = at;\n for (let k = 0; k < context.length; k++) {\n const c = dir === 1 ? context[k] : context[context.length - 1 - k];\n const ch = pos >= 0 && pos < word.length ? word[pos] : undefined;\n if (c === '#') {\n if (ch !== undefined) return false;\n } else if (c === 'V') {\n if (!isVowelLetter(ch)) return false;\n } else if (c === 'C') {\n if (ch === undefined || isVowelLetter(ch)) return false;\n } else if (ch !== c) {\n return false;\n }\n pos += dir;\n }\n return true;\n}\n", "/*\n * The syllables of one word: its segments split into onset, nucleus and coda by the\n * maximal-onset principle with English onset clusters, and its spelling split to match, so\n * each note can show its part of the word (\"twin\", \"kle\").\n *\n * Ported from CHIMERA by Jameson Hodge (MIT),\n * https://github.com/jamesondh/chimera-vocal-synth, crates/chimera/src/phonetics/syllables.rs at\n * 1d3ea49 (TypeScript original at cd247a6^:src/engine/phonetics/syllables.ts). Changes from the\n * original: any one consonant but \u014B may open a syllable, and r and \u026B match the \u0279 and l clusters,\n * so written IPA splits as English does; the spelling is read per character with accents folded,\n * and a diaeresis starts a vowel group (\"na-\u00EFve\"). See THIRD_PARTY_NOTICES.md.\n */\n\nimport type { Segment, Syllable } from './types';\nimport { PAUSE, isVowel } from './ipa';\n\n/** A syllable before it has its text and its place in the lyric. */\nexport type SyllableParts = Pick<Syllable, 'onset' | 'nucleus' | 'coda'>;\n\n/*\n * English onsets as joined IPA (syllables.rs:20-27), kept whole so a [t, \u0283] pair still matches\n * \"t\u0283\" as it does upstream. The single consonants in it are a subset of what legalOnset allows\n * on its own. Upstream allowed only these 23, which is every English consonant but \u014B, so\n * dictionary and letter-to-sound words split exactly as they do there; the wider rule matters\n * for IPA, where /\u02C8w\u0254\u027E\u025A/ should sing w\u0254.\u027E\u025A and not w\u0254\u027E.\u025A.\n */\nconst ONSETS = new Set([\n 'p', 'b', 't', 'd', 'k', 'g', 'f', 'v', '\u03B8', '\u00F0', 's', 'z', '\u0283', '\u0292', 'h', 'm', 'n', 'l', '\u0279',\n 'w', 'j', 't\u0283', 'd\u0292',\n 'pl', 'bl', 'kl', 'gl', 'fl', 'sl', 'p\u0279', 'b\u0279', 't\u0279', 'd\u0279', 'k\u0279', 'g\u0279', 'f\u0279', '\u03B8\u0279', '\u0283\u0279',\n 'sp', 'st', 'sk', 'sm', 'sn', 'sw', 'sf', 'tw', 'kw', 'dw', 'gw', '\u03B8w',\n 'pj', 'bj', 'kj', 'gj', 'mj', 'nj', 'fj', 'vj', 'hj', 'lj',\n 'spl', 'sp\u0279', 'st\u0279', 'sk\u0279', 'skw', 'skj', 'spj',\n]);\n\n/** Written variants of the symbols the cluster list uses: IPA input often writes r for \u0279. */\nconst CLUSTER_SPELLING: ReadonlyMap<string, string> = new Map([\n ['r', '\u0279'],\n ['\u026B', 'l'],\n]);\n\nconst SONORANTS = new Set(Array.from('m\u0271n\u0273\u0272\u014B\u0274l\u026B\u026D\u028E\u0279\u027Br\u0280\u0299\u027E\u027Djw\u028B\u0265\u0270'));\nconst FRICATIVES = new Set(Array.from('\u0278\u03B2fv\u03B8\u00F0sz\u0283\u0292\u0282\u0290\u00E7\u029Dx\u0263\u03C7\u0281\u0127\u0295h\u0266\u026C\u026E\u0255\u0291'));\n\n/** Nasals and approximants over fricatives over the rest, for a word that has no vowel. */\nfunction sonority(ipa: string): number {\n return SONORANTS.has(ipa) ? 2 : FRICATIVES.has(ipa) ? 1 : 0;\n}\n\n/**\n * A word with no vowel as one syllable, carried by its most sonorous sound: \"hmm\" hums on its m,\n * \"shh\" and /pst/ hiss, so the word keeps its note rather than vanishing and moving every later\n * syllable one note early. Undefined for a word with no sounds at all.\n */\nexport function vowelless(segs: readonly Segment[]): SyllableParts | undefined {\n if (segs.length === 0) return undefined;\n let n = 0;\n for (let i = 1; i < segs.length; i++) if (sonority(segs[i].ipa) > sonority(segs[n].ipa)) n = i;\n return { onset: segs.slice(0, n), nucleus: segs[n], coda: segs.slice(n + 1) };\n}\n\n/** The longest onset clusters are three consonants long (\"str\"). */\nconst MAX_ONSET = 3;\n\n/**\n * One word's segments to its syllables, one per vowel. Consonants before the first vowel open\n * the first syllable and consonants after the last close the last; between two vowels the\n * longest legal onset goes to the second and the rest close the first (\"extra\" is \u025Bk.st\u0279\u0259).\n * A word with no vowel has no syllables.\n */\nexport function syllabifySegments(segs: readonly Segment[]): SyllableParts[] {\n const vowels: number[] = [];\n for (let i = 0; i < segs.length; i++) if (isVowel(segs[i].ipa)) vowels.push(i);\n const out: SyllableParts[] = [];\n let start = 0;\n for (let n = 0; n < vowels.length; n++) {\n const v = vowels[n];\n let end = segs.length;\n if (n + 1 < vowels.length) {\n const next = vowels[n + 1];\n const between = next - (v + 1);\n let k = 0;\n for (let len = Math.min(MAX_ONSET, between); len >= 1; len--) {\n if (legalOnset(segs, next - len, next)) {\n k = len;\n break;\n }\n }\n end = next - k;\n }\n out.push({ onset: segs.slice(start, v), nucleus: segs[v], coda: segs.slice(v + 1, end) });\n start = end;\n }\n return out;\n}\n\nfunction legalOnset(segs: readonly Segment[], from: number, to: number): boolean {\n if (to - from === 1) {\n const ipa = segs[from].ipa;\n return ipa !== '\u014B' && ipa !== PAUSE;\n }\n let joined = '';\n for (let i = from; i < to; i++) joined += CLUSTER_SPELLING.get(segs[i].ipa) ?? segs[i].ipa;\n return ONSETS.has(joined);\n}\n\n/** Digraphs that stay together at the start of the next chunk (\"fa-ther\", \"any-where\"). */\nconst DIGRAPHS = new Set(['th', 'sh', 'ch', 'ph', 'wh', 'ck', 'gh']);\n\n/**\n * Split a written word into n chunks at its vowel letters, an approximate hyphenation for\n * display. A final silent e is not a syllable (\"like\"), but consonant plus \"le\" is (\"twin-kle\").\n * Between vowel groups a digraph goes right, one consonant goes right, and a longer run splits\n * in the middle (\"lit-tle\", \"won-der\"). A word with fewer vowel groups than n keeps its spelling\n * on the first chunk and \"~\" on the rest (\"fire\" sung on two notes is \"fire\", \"~\").\n */\nexport function splitSpelling(word: string, n: number): string[] {\n const count = Math.floor(n);\n if (!(count > 1) || !Number.isFinite(count)) return [word];\n const w = Array.from(word);\n const len = w.length;\n const groups: [number, number][] = [];\n for (let i = 0; i < len; ) {\n if (!isVowelLetter(w[i])) {\n i++;\n continue;\n }\n const s = i;\n do i++;\n while (i < len && isVowelLetter(w[i]) && !hasDiaeresis(w[i]));\n groups.push([s, i]);\n }\n /* The e is literal: an accented \u00E9 is never silent (\"ca-f\u00E9\"). */\n const finalE = len >= 2 && (w[len - 1] === 'e' || w[len - 1] === 'E');\n const silentE = finalE && !isVowelLetter(w[len - 2]);\n const consonantLe =\n finalE &&\n len >= 3 &&\n (w[len - 2] === 'l' || w[len - 2] === 'L') &&\n !isVowelLetter(w[len - 3]) &&\n w[len - 3] !== 'l' &&\n w[len - 3] !== 'L';\n if (groups.length > 1 && silentE && !consonantLe && groups[groups.length - 1][0] + 1 === len) {\n groups.pop();\n }\n if (groups.length < count) {\n const out = [word];\n for (let i = 1; i < count; i++) out.push('~');\n return out;\n }\n while (groups.length > count) {\n const last = groups.pop()!;\n groups[groups.length - 1][1] = last[1];\n }\n const cuts = [0];\n for (let i = 0; i < groups.length - 1; i++) {\n const a = groups[i][1];\n const b = groups[i + 1][0];\n const gap = b - a;\n const digraph = gap >= 2 && DIGRAPHS.has((w[b - 2] + w[b - 1]).toLowerCase());\n cuts.push(digraph ? b - 2 : a + (gap <= 1 ? 0 : Math.floor(gap / 2)));\n }\n cuts.push(len);\n const out: string[] = [];\n for (let i = 0; i < cuts.length - 1; i++) out.push(w.slice(cuts[i], cuts[i + 1]).join(''));\n return out;\n}\n\n/** a e i o u y in either case, with any accent. */\nfunction isVowelLetter(c: string): boolean {\n const base = c.length === 1 && c < '\\u0080' ? c : c.normalize('NFD')[0];\n switch (base) {\n case 'a': case 'e': case 'i': case 'o': case 'u': case 'y':\n case 'A': case 'E': case 'I': case 'O': case 'U': case 'Y':\n return true;\n default:\n return false;\n }\n}\n\n/** A diaeresis says its vowel is a syllable of its own: \"na-\u00EFve\", \"Zo-\u00EB\". */\nfunction hasDiaeresis(c: string): boolean {\n return c.length === 1 && c < '\\u00C0' ? false : c.normalize('NFD').includes('\\u0308');\n}\n", "/*\n * Wells's lexical sets (J. C. Wells, Accents of English, 1982): a name for the vowel a word has,\n * independent of how any one accent says it. The letter-to-sound rules and the dictionary speak General\n * American; tagging each vowel with its set is what lets an accent say it its own way (accents.ts):\n * British \"bath\" with PALM's vowel, Australian \"goose\" fronted, Irish \"face\" a long monophthong.\n *\n * A set comes from the General American vowel, the r after it, its stress and, where General American has\n * merged what other accents keep apart, the spelling: LOT (\"cot\", spelled o) against PALM (\"calm\",\n * spelled a), THOUGHT (\"caught\": au, aw, al, ough) against CLOTH (\"cloth\", \"dog\", \"long\"), and TRAP\n * against BATH, the set Southern British says with PALM's vowel. BATH is partly lexical, so it is the\n * phonetic rule (\"staff\", \"path\", \"glass\", \"ask\": a before f, th or s that ends the syllable) plus a word\n * list for the n clusters (\"dance\", \"plant\", \"can't\", but not \"ant\").\n */\n\nimport type { Segment } from './types';\nimport { isVowel } from './ipa';\n\n/** Wells's 24 lexical sets and the three weak ones (happY, lettER, commA). */\nexport type LexicalSet =\n | 'KIT'\n | 'DRESS'\n | 'TRAP'\n | 'LOT'\n | 'STRUT'\n | 'FOOT'\n | 'BATH'\n | 'CLOTH'\n | 'NURSE'\n | 'FLEECE'\n | 'FACE'\n | 'PALM'\n | 'THOUGHT'\n | 'GOAT'\n | 'GOOSE'\n | 'PRICE'\n | 'CHOICE'\n | 'MOUTH'\n | 'NEAR'\n | 'SQUARE'\n | 'START'\n | 'NORTH'\n | 'FORCE'\n | 'CURE'\n | 'happY'\n | 'lettER'\n | 'commA';\n\nexport const LEXICAL_SETS: readonly LexicalSet[] = [\n 'KIT', 'DRESS', 'TRAP', 'LOT', 'STRUT', 'FOOT', 'BATH', 'CLOTH', 'NURSE', 'FLEECE', 'FACE', 'PALM',\n 'THOUGHT', 'GOAT', 'GOOSE', 'PRICE', 'CHOICE', 'MOUTH', 'NEAR', 'SQUARE', 'START', 'NORTH', 'FORCE',\n 'CURE', 'happY', 'lettER', 'commA',\n];\n\n/* BATH before an n cluster is lexical: these take it in Southern British, \"ant\", \"cancer\", \"romance\" do not. */\nconst BATH_WORDS = new Set([\n 'dance', 'dancer', 'dancing', 'chance', 'glance', 'lance', 'prance', 'trance', 'france', 'advance', 'enhance',\n 'plant', 'grant', 'slant', 'chant', 'aunt', \"can't\", \"shan't\", 'branch', 'answer', 'example', 'sample', 'demand',\n 'command', 'commander', 'remand', 'rather', 'father', 'half', 'calf', 'laugh', 'laughter', 'banana', 'drama',\n]);\n/* A before f, th or s and then a vowel stays TRAP (\"classic\", \"passage\", \"gaffe\" aside): these are BATH anyway. */\nconst BATH_BEFORE_VOWEL = new Set(['after', 'nasty', 'master', 'disaster', 'plaster', 'pastor', 'rafter', 'castle', 'fasten']);\n\n/* THOUGHT's spellings; \"wa\" too, since General American's \u0254 after it is THOUGHT (\"water\", \"walk\"). */\nconst THOUGHT_SPELLING = /au|aw|al[lkt]|ough|augh|oa|wa/;\n\n/**\n * Tag every vowel of one word's segments (General American, as the reader produced them) with its\n * lexical set, in place. `word` is the spelling, lower-cased.\n */\nexport function tagLexicalSets(word: string, segs: Segment[]): void {\n const w = word.toLowerCase();\n const vowels: number[] = [];\n for (let i = 0; i < segs.length; i++) if (isVowel(segs[i].ipa)) vowels.push(i);\n for (let n = 0; n < vowels.length; n++) {\n const i = vowels[n];\n const seg = segs[i];\n const next = segs[i + 1]?.ipa;\n const after = segs[i + 2]?.ipa;\n const r = next === '\u0279';\n // an r that closes the syllable: the word ends there or a consonant follows (\"car\", \"card\"), not \"carry\"\n const rCoda = r && (after === undefined || !isVowel(after));\n const stressed = seg.stress !== undefined && seg.stress > 0;\n const last = n === vowels.length - 1;\n seg.set = classify(seg.ipa, { w, next, after, rCoda, stressed, last, single: vowels.length === 1 });\n }\n}\n\nfunction classify(\n v: string,\n c: { w: string; next?: string; after?: string; rCoda: boolean; stressed: boolean; last: boolean; single: boolean },\n): LexicalSet | undefined {\n switch (v) {\n case 'i':\n if (c.rCoda) return 'NEAR';\n return !c.stressed && c.last ? 'happY' : 'FLEECE';\n case '\u026A':\n return c.rCoda ? 'NEAR' : 'KIT';\n case '\u025B':\n return c.rCoda ? 'SQUARE' : 'DRESS';\n case 'e\u026A':\n return c.rCoda ? 'SQUARE' : 'FACE';\n case '\u00E6': {\n if (BATH_WORDS.has(c.w) || BATH_BEFORE_VOWEL.has(c.w)) return 'BATH';\n const fric = c.next === 'f' || c.next === '\u03B8' || c.next === 's';\n if (fric && (c.after === undefined || !isVowel(c.after))) return 'BATH';\n return 'TRAP';\n }\n case '\u0251':\n if (c.rCoda) return 'START';\n // \"watch\", \"want\", \"quality\": a after w is LOT's vowel\n if (/(w|qu)a/.test(c.w)) return 'LOT';\n if (c.w.includes('o') && !/a(?!u|w)/.test(c.w)) return 'LOT';\n if (c.w.includes('a') && !c.w.includes('o')) return 'PALM';\n return 'LOT';\n case '\u0254':\n if (c.rCoda) return 'NORTH';\n return THOUGHT_SPELLING.test(c.w) ? 'THOUGHT' : 'CLOTH';\n case 'o\u028A':\n return c.rCoda ? 'FORCE' : 'GOAT';\n case '\u028C':\n return 'STRUT';\n case '\u028A':\n return c.rCoda ? 'CURE' : 'FOOT';\n case 'u':\n return c.rCoda ? 'CURE' : 'GOOSE';\n case '\u025D':\n case '\u025A':\n return c.stressed ? 'NURSE' : 'lettER';\n case '\u0259':\n // commA is a schwa that ends a longer word (\"comma\", \"sofa\"); one before a consonant (\"little\",\n // \"away\") has no set, and nor does a one-vowel word (\"the\", \"a\"), whose schwa is a weak form\n return c.last && c.next === undefined && !c.single ? 'commA' : undefined;\n case 'a\u026A':\n return 'PRICE';\n case 'a\u028A':\n return 'MOUTH';\n case '\u0254\u026A':\n return 'CHOICE';\n default:\n return undefined;\n }\n}\n", "/*\n * English: a written word to its segments, and the front end that sings English lyrics.\n *\n * Ported from CHIMERA by Jameson Hodge (MIT),\n * https://github.com/jamesondh/chimera-vocal-synth, crates/chimera/src/phonetics/english.rs\n * (EnglishG2P::word, the homographs and function words) and syllables.rs (the English front\n * end) at 1d3ea49 (TypeScript originals at cd247a6^:src/engine/phonetics/english.ts and\n * syllables.ts). Changes from the original: accented Latin letters fold to their base, so\n * \"caf\u00E9\" is one word and is looked up as \"cafe\"; the function words carry their own\n * pronunciations, read when no dictionary has the word. See THIRD_PARTY_NOTICES.md.\n *\n * A word is read from, in order: the homograph table, the injected dictionary, the function\n * words below, and the letter-to-sound rules. The dictionary is CMUdict's shape, lower-case\n * word to ARPAbet (parseCmudict reads the files CMU distributes); without one every other word\n * goes to the rules.\n * Upstream reduces monosyllabic function words to weak forms in speech (\"of\" as \u0259v); sung,\n * they keep full vowels, so the front end leaves `reduce` off unless asked.\n */\n\nimport type { FrontEnd, PronouncingDictionary, Segment, Syllable } from './types';\nimport { arpabetToSegments } from './arpabet';\nimport { isVowel } from './ipa';\nimport { letterToSound } from './letter-to-sound';\nimport { splitSpelling, syllabifySegments, vowelless } from './syllabify';\nimport { tagLexicalSets } from './lexical-sets';\n\nexport interface EnglishOptions {\n /** Lower-case word to ARPAbet with stress digits, as parseCmudict returns it. */\n dictionary?: PronouncingDictionary;\n /**\n * Weak forms for monosyllabic function words, as in running speech: every vowel unstressed,\n * and a lone \u028C \u00E6 \u0251 \u025B \u0254 u \u028A reduced to \u0259 (\"of\" sings \u0259v). Off by default: sung, they keep\n * full vowels.\n */\n reduce?: boolean;\n}\n\n/*\n * CMUdict lists the rarer reading of these first (the verb \"wind\", past-tense \"read\"), and the\n * first entry is the one a dictionary map keeps. Telling them apart needs grammar; the common\n * reading wins, with or without a dictionary.\n */\nconst HOMOGRAPHS: ReadonlyMap<string, string> = new Map([\n ['wind', 'W IH1 N D'],\n ['read', 'R IY1 D'],\n ['live', 'L IH1 V'],\n ['lead', 'L IY1 D'],\n ['close', 'K L OW1 Z'],\n ['wound', 'W UW1 N D'],\n]);\n\n/*\n * Upstream's function words, with a pronunciation each. They are the commonest words of any\n * lyric, and spelling predicts them worst: without a dictionary, which bellows does not ship,\n * the rules read 32 of these 66 wrongly, \"the\" as \u03B8i, \"I\" as \u026A, \"you\" as ja\u028A, \"to\" as t\u0251\n * (MEASURED). These are the usual readings, written out by hand, and each one agrees with the\n * first entry of the cmudict.dict copy CHIMERA ships (checked as data, 66 of 66), so a lyric\n * sings the same with or without a dictionary loaded. A loaded dictionary is still read first.\n */\nconst FUNCTION_WORDS: ReadonlyMap<string, string> = new Map([\n ['a', 'AH0'], ['an', 'AE1 N'], ['the', 'DH AH0'], ['of', 'AH1 V'], ['to', 'T UW1'],\n ['in', 'IH0 N'], ['on', 'AA1 N'], ['at', 'AE1 T'], ['by', 'B AY1'], ['for', 'F AO1 R'],\n ['from', 'F R AH1 M'], ['with', 'W IH1 DH'], ['as', 'AE1 Z'], ['and', 'AH0 N D'],\n ['or', 'AO1 R'], ['but', 'B AH1 T'], ['nor', 'N AO1 R'], ['so', 'S OW1'], ['if', 'IH1 F'],\n ['is', 'IH1 Z'], ['am', 'AE1 M'], ['are', 'AA1 R'], ['was', 'W AA1 Z'], ['were', 'W ER1'],\n ['be', 'B IY1'], ['been', 'B IH1 N'], ['do', 'D UW1'], ['does', 'D AH1 Z'], ['did', 'D IH1 D'],\n ['has', 'HH AE1 Z'], ['have', 'HH AE1 V'], ['had', 'HH AE1 D'], ['will', 'W IH1 L'],\n ['would', 'W UH1 D'], ['can', 'K AE1 N'], ['could', 'K UH1 D'], ['should', 'SH UH1 D'],\n ['shall', 'SH AE1 L'], ['may', 'M EY1'], ['might', 'M AY1 T'], ['must', 'M AH1 S T'],\n ['it', 'IH1 T'], ['its', 'IH1 T S'], ['i', 'AY1'], ['you', 'Y UW1'], ['he', 'HH IY1'],\n ['she', 'SH IY1'], ['we', 'W IY1'], ['they', 'DH EY1'], ['me', 'M IY1'], ['him', 'HH IH1 M'],\n ['her', 'HH ER1'], ['us', 'AH1 S'], ['them', 'DH EH1 M'], ['my', 'M AY1'], ['your', 'Y AO1 R'],\n ['his', 'HH IH1 Z'], ['our', 'AW1 ER0'], ['their', 'DH EH1 R'], ['this', 'DH IH1 S'],\n ['that', 'DH AE1 T'], ['than', 'DH AE1 N'], ['then', 'DH EH1 N'], ['there', 'DH EH1 R'],\n ['not', 'N AA1 T'], ['no', 'N OW1'],\n]);\n\n/**\n * Common words the letter-to-sound rules cannot read and contractions, from the CMU dictionary (BSD),\n * never weakened. Where CMU lists a one-syllable form (fire, hour, desire) it is the one taken: a sung\n * word keeps one note. MEASURED against the CMU dictionary, with these and the 2026-11-13 rules: 77.0\n * percent of 469 common and lyric words exact (49.7 before), 74.8 percent of 397 inflected ones (9.6).\n */\nconst IRREGULAR: ReadonlyMap<string, string> = new Map([\n ['one', 'W AH1 N'], ['once', 'W AH1 N S'], ['what', 'W AH1 T'], ['who', 'HH UW1'], ['two', 'T UW1'],\n ['into', 'IH1 N T UW0'], ['through', 'TH R UW1'], ['where', 'W EH1 R'], ['these', 'DH IY1 Z'],\n ['those', 'DH OW1 Z'], ['thee', 'DH IY1'], ['thou', 'DH AW1'], ['thy', 'DH AY1'], ['thine', 'DH AY1 N'],\n ['though', 'DH OW1'], ['people', 'P IY1 P AH0 L'], ['eye', 'AY1'], ['eyes', 'AY1 Z'], ['said', 'S EH1 D'],\n ['any', 'EH1 N IY0'], ['many', 'M EH1 N IY0'], ['anywhere', 'EH1 N IY0 W EH2 R'],\n ['anything', 'EH1 N IY0 TH IH2 NG'], ['anyone', 'EH1 N IY0 W AH2 N'], ['everything', 'EH1 V R IY0 TH IH2 NG'],\n ['everywhere', 'EH1 V R IY0 W EH2 R'], ['everyone', 'EH1 V R IY0 W AH2 N'], ['great', 'G R EY1 T'],\n ['friend', 'F R EH1 N D'], ['hour', 'AW1 R'], ['whole', 'HH OW1 L'], ['woman', 'W UH1 M AH0 N'],\n ['women', 'W IH1 M AH0 N'], ['touch', 'T AH1 CH'], ['ocean', 'OW1 SH AH0 N'], ['together', 'T AH0 G EH1 DH ER0'],\n ['get', 'G EH1 T'], ['forget', 'F ER0 G EH1 T'], ['give', 'G IH1 V'], ['again', 'AH0 G EH1 N'],\n ['against', 'AH0 G EH1 N S T'], ['because', 'B IH0 K AO1 Z'], ['even', 'IY1 V IH0 N'], ['busy', 'B IH1 Z IY0'],\n ['sure', 'SH UH1 R'], ['sugar', 'SH UH1 G ER0'], ['enough', 'IH0 N AH1 F'], ['young', 'Y AH1 NG'],\n ['done', 'D AH1 N'], ['gone', 'G AO1 N'], ['none', 'N AH1 N'], ['bear', 'B EH1 R'], ['wear', 'W EH1 R'],\n ['break', 'B R EY1 K'], ['guy', 'G AY1'], ['buy', 'B AY1'], ['lose', 'L UW1 Z'], ['move', 'M UW1 V'],\n ['goes', 'G OW1 Z'], ['door', 'D AO1 R'], ['fire', 'F AY1 R'], ['desire', 'D IH0 Z AY1 R'], [\"i'm\", 'AY1 M'],\n [\"i'll\", 'AY1 L'], [\"i've\", 'AY1 V'], [\"i'd\", 'AY1 D'], [\"you're\", 'Y UH1 R'], [\"you'll\", 'Y UW1 L'],\n [\"you've\", 'Y UW1 V'], [\"we're\", 'W IY1 R'], [\"we'll\", 'W IY1 L'], [\"they're\", 'DH EH1 R'], [\"don't\", 'D OW1 N T'],\n [\"won't\", 'W OW1 N T'], [\"can't\", 'K AE1 N T'], [\"isn't\", 'IH1 Z AH0 N T'], [\"it's\", 'IH1 T S'],\n [\"that's\", 'DH AE1 T S'], [\"there's\", 'DH EH1 R Z'], [\"let's\", 'L EH1 T S'], [\"ain't\", 'EY1 N T'],\n [\"didn't\", 'D IH1 D AH0 N T'], [\"doesn't\", 'D AH1 Z AH0 N T'], [\"wasn't\", 'W AA1 Z AH0 N T'],\n [\"couldn't\", 'K UH1 D AH0 N T'], [\"wouldn't\", 'W UH1 D AH0 N T'], [\"shouldn't\", 'SH UH1 D AH0 N T'],\n [\"he's\", 'HH IY1 Z'], [\"she's\", 'SH IY1 Z'], [\"what's\", 'W AH1 T S'], [\"o'er\", 'OW1 R'], [\"ne'er\", 'N EH1 R'],\n [\"e'er\", 'EH1 R'],\n]);\n\n/** Vowels a weak form reduces to schwa; i \u026A e\u026A a\u026A o\u028A keep their quality. */\nconst REDUCES = new Set(['\u028C', '\u00E6', '\u0251', '\u025B', '\u0254', 'u', '\u028A']);\n/** Function words whose weak form keeps its vowel (\"you\", \"to\" do not become j\u0259, t\u0259 here). */\nconst KEEPS_VOWEL = new Set(['you', 'do', 'to', 'who', 'not', 'no']);\n\nconst COMBINING = /[\\u0300-\\u036F]/g;\nconst EDGE_APOSTROPHES = /^'+|'+$/g;\n\n/**\n * One English word to segments with lexical stress. Letters are lower-cased and apostrophes\n * at either end dropped (\"'tis\", \"dancin'\"). A hyphenated word the dictionary lacks is read part\n * by part. Never throws; a word with nothing readable gives [].\n */\nexport function pronounceEnglish(word: string, opts: EnglishOptions = {}): Segment[] {\n const clean = word.toLowerCase().replace(EDGE_APOSTROPHES, '');\n const folded = clean.normalize('NFD').replace(COMBINING, '');\n const entry = HOMOGRAPHS.get(folded) ?? lookup(opts.dictionary, clean, folded) ?? FUNCTION_WORDS.get(folded) ?? IRREGULAR.get(folded);\n if (entry) {\n const segs = arpabetToSegments(entry);\n if (opts.reduce && FUNCTION_WORDS.has(folded)) weaken(segs, folded);\n return segs;\n }\n if (clean.includes('-')) {\n const out: Segment[] = [];\n for (const part of clean.split('-')) out.push(...pronounceEnglish(part, opts));\n return out;\n }\n return letterToSound(folded);\n}\n\nfunction lookup(\n dictionary: PronouncingDictionary | undefined,\n clean: string,\n folded: string,\n): string | undefined {\n if (!dictionary) return undefined;\n /* A dictionary may spell a loanword with its accent; CMUdict spells it without. */\n return dictionary.get(clean) || (folded !== clean ? dictionary.get(folded) : undefined);\n}\n\nfunction weaken(segs: Segment[], word: string): void {\n let vowels = 0;\n for (const s of segs) if (isVowel(s.ipa)) vowels++;\n for (const s of segs) {\n if (!isVowel(s.ipa)) continue;\n s.stress = 0;\n if (vowels === 1 && REDUCES.has(s.ipa) && !KEEPS_VOWEL.has(word)) s.ipa = '\u0259';\n }\n}\n\n/**\n * The English front end: claims words of Latin letters and apostrophes, continued by hyphens\n * and combining accents. A hyphen inside a word splits syllables explicitly (\"ti-ger\"), each\n * part showing its whole spelling; otherwise the pronunciation decides the syllables and the\n * spelling is split to match (\"twin\", \"kle\").\n */\nexport function englishFrontEnd(opts: EnglishOptions = {}): FrontEnd {\n return {\n starts: isEnglishLetter,\n continues: (c) => c === '-' || isEnglishLetter(c) || (c >= '\\u0300' && c <= '\\u036F'),\n word: (word) => englishSyllables(word, opts),\n };\n}\n\nfunction englishSyllables(word: string, opts: EnglishOptions): Syllable[] {\n const parts = word.split('-').filter((p) => p !== '');\n const out: Syllable[] = [];\n for (const part of parts) {\n const segs = pronounceEnglish(part, opts);\n // each vowel's lexical set, which an accent re-voices (accents.ts)\n tagLexicalSets(part, segs);\n const syllables = syllabifySegments(segs);\n if (syllables.length === 0) {\n const carried = vowelless(segs);\n if (carried) syllables.push(carried);\n }\n const spelling = parts.length > 1 ? [part] : splitSpelling(part, syllables.length);\n for (let i = 0; i < syllables.length; i++) {\n const { onset, nucleus, coda } = syllables[i];\n out.push({ text: spelling[i] ?? '~', onset, nucleus, coda, wordEnd: false, phraseEnd: false });\n }\n }\n return out;\n}\n\n/** A-Z, a-z, an apostrophe, or a precomposed Latin letter with accents (\"\u00E9\", \"\u00F1\", \"\u0130\"). */\nfunction isEnglishLetter(c: string): boolean {\n if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c === \"'\") return true;\n if (c < '\\u00C0') return false;\n const d = c.normalize('NFD');\n if (d.length < 2) return false;\n const base = d[0];\n if (!((base >= 'a' && base <= 'z') || (base >= 'A' && base <= 'Z'))) return false;\n for (let i = 1; i < d.length; i++) if (d[i] < '\\u0300' || d[i] > '\\u036F') return false;\n return true;\n}\n", "/*\n * Written IPA as a lyric: a word between slashes, /\u02C8tw\u026A\u014B.k\u0259l/, sets its sounds directly, so a\n * lyric needs no dictionary to get a word right. What the tokenizer does with marks and with\n * symbols no voice has is in ipa.ts.\n *\n * Written for bellows: CHIMERA's router (crates/chimera/src/phonetics/syllables.rs) has no IPA\n * reader. It reads with the tokenizer and syllabifier ported from CHIMERA (ipa.ts and\n * syllabify.ts), and has the FrontEnd shape CHIMERA's front ends have.\n *\n * Where a word has syllable dots, the dots decide: /\u02C8s\u026As.t\u025A/ sings s\u026As.t\u025A where maximal onset\n * alone would give s\u026A.st\u025A. A dotted chunk with two vowels is split by maximal onset inside it,\n * and a chunk with no vowel joins the coda before it (or the onset after it, at the start of a\n * word), because a note needs a vowel to carry it. A word without dots is split by maximal\n * onset. Spaces separate words and a comma or bar ends a phrase, so a whole transcribed line can\n * go between one pair of slashes. Each syllable shows its IPA, led by \u02C8 or \u02CC when stressed.\n */\n\nimport type { FrontEnd, Segment, Syllable } from './types';\nimport { BREAK_SYLLABLE, BREAK_WORD, PAUSE, readIpa } from './ipa';\nimport { syllabifySegments, vowelless, type SyllableParts } from './syllabify';\n\nconst SLASH = '/';\n\n/**\n * Claims /\u2026/. The slash is not a character it continues, which tells the router the word is\n * delimited: it closes at the next slash on the same line (see readLyrics).\n */\nexport const ipaFrontEnd: FrontEnd = {\n starts: (c) => c === SLASH,\n continues: (c) => c !== SLASH && c !== '\\n' && c !== '\\r',\n word: (word) => ipaToSyllables(stripSlashes(word)),\n};\n\n/** IPA text, without slashes, to sung syllables. Never throws; unknown characters are skipped. */\nexport function ipaToSyllables(ipa: string): Syllable[] {\n const { segments, breaks } = readIpa(ipa);\n const out: Syllable[] = [];\n let chunks: Segment[][] = [[]];\n for (let i = 0; i < segments.length; i++) {\n const seg = segments[i];\n if (seg.ipa === PAUSE) {\n /* readIpa ends the word before a pause, so the word is already closed. */\n if (out.length > 0) out[out.length - 1].phraseEnd = true;\n continue;\n }\n chunks[chunks.length - 1].push(seg);\n if (breaks[i] === BREAK_WORD || i === segments.length - 1) {\n closeWord(chunks, out);\n chunks = [[]];\n } else if (breaks[i] === BREAK_SYLLABLE) {\n chunks.push([]);\n }\n }\n return out;\n}\n\nfunction closeWord(chunks: Segment[][], out: Syllable[]): void {\n const parts = chunks.length > 1 ? byChunks(chunks) : syllabifySegments(chunks[0]);\n /* a symbol no voice has keeps its note and reaches the facade's unknown list instead of vanishing */\n if (parts.length === 0) {\n const carried = vowelless(chunks.flat());\n if (!carried) return;\n parts.push(carried);\n }\n for (let i = 0; i < parts.length; i++) {\n const { onset, nucleus, coda } = parts[i];\n out.push({\n text: shown(parts[i]),\n onset,\n nucleus,\n coda,\n wordEnd: i === parts.length - 1,\n phraseEnd: false,\n });\n }\n}\n\n/** Syllables as the dots divide them. */\nfunction byChunks(chunks: Segment[][]): SyllableParts[] {\n const out: SyllableParts[] = [];\n let carry: Segment[] = [];\n for (const chunk of chunks) {\n const parts = syllabifySegments(chunk);\n if (parts.length === 0) {\n if (out.length > 0) out[out.length - 1].coda.push(...chunk);\n else carry.push(...chunk);\n continue;\n }\n if (carry.length > 0) {\n parts[0].onset.unshift(...carry);\n carry = [];\n }\n out.push(...parts);\n }\n return out;\n}\n\nfunction shown(s: SyllableParts): string {\n let text = s.nucleus.stress === 1 ? '\u02C8' : s.nucleus.stress === 2 ? '\u02CC' : '';\n for (const seg of s.onset) text += seg.ipa;\n text += s.nucleus.ipa;\n for (const seg of s.coda) text += seg.ipa;\n return text;\n}\n\nfunction stripSlashes(word: string): string {\n const from = word.startsWith(SLASH) ? 1 : 0;\n const to = word.length > from && word.endsWith(SLASH) ? word.length - 1 : word.length;\n return word.slice(from, to);\n}\n", "/*\n * American English allophones, applied across a phrase: /t d/ between a vowel\n * (or \u0279) and an unstressed vowel become the flap \u027E (\"water\", \"little\",\n * \"got it\"), except at the start of a word, and /l/ that ends a syllable\n * becomes velarized \u026B (\"tell\", \"little\", \"milk\"). Those are General American's rules\n * and the default; an accent (accents.ts) picks others: t released, or glottal before a\n * consonant (Southern British, Scottish), or also before a pause and between vowels (London); l clear\n * everywhere (Irish), dark everywhere (Scottish), or vocalized after a vowel (London).\n *\n * Ported from CHIMERA by Jameson Hodge (MIT),\n * https://github.com/jamesondh/chimera-vocal-synth, crates/chimera/src/phonetics/english.rs\n * (apply_allophones, lines 268-292) at 1d3ea49. Changes from the original: it runs over sung\n * syllables instead of a flat segment list, a phrase at a time, and only over syllables the\n * English front end read, so IPA written between slashes is sung exactly as written. See\n * THIRD_PARTY_NOTICES.md.\n *\n * Both rules need the next sound, which can be in the next word (\"got it\" flaps across the\n * space), so they cannot live inside a front end that reads one word at a time; that is why the\n * first port of the English front end lost them, and why this pass runs after the router.\n */\n\nimport type { Segment, Syllable } from './types';\nimport type { LRule, TRule } from './accents';\nimport { isVowel } from './ipa';\n\n/** Which t and l rules to apply; General American's when left out. */\nexport interface AllophoneRules {\n t?: TRule;\n l?: LRule;\n}\n\ninterface Slot {\n seg: Segment;\n /** Last segment of its word. */\n wordEnd: boolean;\n}\n\n/**\n * Rewrite the segments of `syllables` in place where the rules apply. `english` says which\n * syllables the English front end produced; runs of them are processed phrase by phrase, and\n * anything else (IPA, a melisma) ends a run.\n */\nexport function applyAllophones(\n syllables: readonly Syllable[],\n english: (s: Syllable) => boolean,\n rules: AllophoneRules = {},\n): void {\n const t = rules.t ?? 'flap';\n const l = rules.l ?? 'dark-coda';\n let run: Slot[] = [];\n const flush = () => {\n if (run.length > 0) rewrite(run, t, l);\n run = [];\n };\n for (const syl of syllables) {\n if (!english(syl) || syl.melisma) {\n flush();\n continue;\n }\n const segs = [...syl.onset, syl.nucleus, ...syl.coda];\n segs.forEach((seg, i) => run.push({ seg, wordEnd: syl.wordEnd && i === segs.length - 1 }));\n if (syl.phraseEnd) flush();\n }\n flush();\n}\n\nfunction rewrite(segs: Slot[], t: TRule, l: LRule): void {\n if (t === 'flap') {\n for (let i = 1; i + 1 < segs.length; i++) {\n const prev = segs[i - 1];\n const next = segs[i + 1];\n const s = segs[i].seg;\n if ((s.ipa === 't' || s.ipa === 'd') && (isVowel(prev.seg.ipa) || prev.seg.ipa === '\u0279') && isVowel(next.seg.ipa)) {\n const nextStressed = next.seg.stress !== undefined && next.seg.stress !== 0;\n // not at the start of a word: \"were disputing\" keeps its /d/\n if (!nextStressed && !prev.wordEnd) s.ipa = '\u027E';\n }\n }\n } else if (t === 'glottal' || t === 'glottal-coda') {\n for (let i = 1; i < segs.length; i++) {\n const s = segs[i].seg;\n const before = segs[i - 1].seg.ipa;\n if (s.ipa !== 't' || !(isVowel(before) || before === 'n' || before === 'l')) continue;\n const next = segs[i + 1]?.seg;\n // \"football\", \"that one\": before a consonant other than r, w, j (which keep \"true\", \"twin\" whole); London also before a pause\n const coda =\n next === undefined ? t === 'glottal' : !isVowel(next.ipa) && !CLUSTERS_WITH_T.has(next.ipa);\n // \"water\", \"bottle\" (as w\u0254\u0294\u0259, b\u0252\u0294\u0259l): between a vowel and an unstressed one inside a word\n const between =\n t === 'glottal' &&\n next !== undefined &&\n isVowel(next.ipa) &&\n !(next.stress !== undefined && next.stress !== 0) &&\n !segs[i - 1].wordEnd &&\n isVowel(segs[i - 1].seg.ipa);\n if (coda || between) s.ipa = '\u0294';\n }\n }\n if (l === 'clear') return;\n for (let i = 0; i < segs.length; i++) {\n if (segs[i].seg.ipa !== 'l') continue;\n const nextVowel = i + 1 < segs.length && isVowel(segs[i + 1].seg.ipa);\n const coda = !nextVowel || segs[i].wordEnd;\n if (l === 'dark') segs[i].seg.ipa = '\u026B';\n // coda /l/, before a consonant, a pause or the end of a word, is velarized (or, in London, a w-like glide)\n else if (coda) segs[i].seg.ipa = l === 'vocalized' ? 'w' : '\u026B';\n }\n}\n\n/** Consonants a /t/ joins in an onset (\"true\", \"twin\"), which keep it from glottalling. */\nconst CLUSTERS_WITH_T = new Set(['\u0279', 'w', 'j']);\n", "/*\n * Accents as data. An accent says how each lexical set (lexical-sets.ts) is voiced, whether r after a\n * vowel is said, and how it treats t, l, th, r and h. The English reader speaks General American and\n * tags every vowel with its set; applyAccent re-voices those tags across a phrase, then the allophone\n * pass (allophones.ts) applies the accent's t and l. IPA written between slashes has no sets and is\n * sung as written.\n *\n * Realizations are IPA. One vowel is a monophthong (\"e\" for Irish FACE); two vowels are a diphthong\n * that glides from the first to the second, the first held for `hold` of the vowel's time (\"\u0259\u028A\" for\n * Southern British GOAT); a final r (\"\u028C\u027E\" for Scottish NURSE) is an r the accent says after the vowel,\n * which replaces the r General American had there or adds one where it had none (General American\n * NURSE has its r inside the vowel). A length mark is read and dropped, since a sung note sets the\n * vowel's length. Every vowel named must be one the vocal engine has (vocal-phonemes.ts): the General\n * American set plus \u0252 \u0250 \u025C \u0289 \u0268 \u0258 \u0275 y \u00F8 \u0153 \u026F \u0264, solved from formants (scripts/gen-extra-vowels.mjs).\n *\n * Sources for the tables: J. C. Wells, Accents of English (1982), and the lexical-set tables of the\n * Wikipedia articles on each accent, which cite Cruttenden (Gimson's Pronunciation of English, 2014)\n * for Southern British, Cox and Palethorpe (2007) for Australian, Bauer et al. (2007) for New Zealand,\n * Hickey (2007) for Irish, Stuart-Smith (2004) for Scottish, Wells and Tollfree for London, Thomas\n * (2004) for the American South, Boberg (2008) for Canadian, Labov (2006) for New York, Penhallurick\n * (2004) for Welsh, Watt and Milroy (1999) for Geordie, Beal (2004) for the North of England, Bowerman\n * (2004) for South Africa, Gut (2004) for Nigeria, Devonish and Harry (2004) for Jamaica, Sailaja (2009)\n * for India, Deterding (2007) for Singapore, Upton (2004) for traditional RP, Wells (1982) and Watson\n * (2007) for Liverpool, Thorne (2003) for Birmingham, Wagner (2004) for the West Country, Labov,\n * Ash and Boberg (2006) for Boston and the Northern Cities Shift, Tayao (2004) for the Philippines,\n * Huber (2004) for Ghana, Schmied (2004) for East Africa, Youssef and James (2004) for Trinidad\n * and, for Russian speakers of English, Swan and Smith's Learner English (2001, the Russian chapter\n * by Monk and Burak), as summarized in those articles and the Handbook of\n * Varieties of English (Kortmann and Schneider, 2004). They are broad transcriptions of each accent's mainstream form, not\n * of any one speaker.\n */\n\nimport type { LexicalSet } from './lexical-sets';\nimport type { Segment, Syllable } from './types';\nimport { isVowel } from './ipa';\n\n/** How /t/ between vowels and before consonants comes out. */\nexport type TRule =\n /** \"water\" with a tap, as in North America and Australia. */\n | 'flap'\n /** Every /t/ released. */\n | 'released'\n /** A glottal stop before a consonant (\"football\", \"that one\"), released elsewhere. */\n | 'glottal-coda'\n /** A glottal stop before a consonant, a pause, or an unstressed vowel (\"water\", \"bottle\", \"that\"). */\n | 'glottal';\n/** How /l/ comes out. */\nexport type LRule =\n /** Dark after a vowel, clear before one: General American, Southern British. */\n | 'dark-coda'\n /** Clear everywhere: Irish, Welsh. */\n | 'clear'\n /** Dark everywhere: Scottish, much of the American South. */\n | 'dark'\n /** Vocalized to a w-like glide after a vowel (\"milk\", \"bottle\"), dark-coda otherwise: London. */\n | 'vocalized';\n/** How the dental fricatives come out. */\nexport type ThRule =\n | 'fricative'\n /** As stops: \"think\" tink, \"this\" dis (Irish, many Caribbean and African accents). */\n | 'stop'\n /** Fronted: \"think\" fink, \"brother\" bruvver; \"this\" keeps a d at the start of a word (London). */\n | 'front'\n /** As sibilants: \"think\" sink, \"this\" zis (Russian, French and German speakers of English). */\n | 'sibilant';\n/** How /r/ comes out where it is said. */\nexport type RRule = 'approximant' | 'tap';\n\n/** How an accent speaks a phrase (lyrics/speech.ts). Singing follows the melody instead. */\nexport interface Prosody {\n /** The phrase's last tone, from its last stressed syllable: a fall, or a rise (Australian and Belfast statements). */\n tune: 'fall' | 'rise';\n /** Height of a pitch accent on a stressed syllable over the baseline, semitones. */\n range: number;\n /** How far the baseline sinks across a phrase, semitones. */\n declination: number;\n /** Speaking rate, 1 for General American's. */\n rate: number;\n /**\n * How much longer a stressed vowel is than an unstressed one: about 2 in stress-timed English\n * (General American, British), nearer 1 in the syllable-timed Englishes of India, Nigeria,\n * Singapore and the Caribbean. Left out, 2.\n */\n stressRatio?: number;\n}\n\nexport interface Accent {\n id: string;\n name: string;\n /** Where it is spoken, for grouping in a UI ('North America', 'England', 'Africa', ...). */\n region?: string;\n /** Says r after a vowel (\"car\", \"card\"). A non-rhotic accent still links it before a vowel (\"far away\"). */\n rhotic: boolean;\n /** Each lexical set's realization, IPA. A set left out keeps General American's vowel. */\n sets: Partial<Record<LexicalSet, string>>;\n /**\n * Share of a diphthong's time held on its first vowel, 0 to 1. Left out, General American's 0.8\n * (lyrics/sing.ts). Accents whose diphthongs move through the whole vowel sit near 0.5.\n */\n hold?: number;\n /** Per-set holds over `hold`. */\n holds?: Partial<Record<LexicalSet, number>>;\n t: TRule;\n l: LRule;\n th: ThRule;\n r: RRule;\n /** Drops h at the start of a word (\"house\" ouse). */\n hDrop?: boolean;\n /**\n * Devoices a voiced stop or fricative that ends a word: \"bed\" as bet, \"his\" as hiss (Russian,\n * German, Polish and Dutch speakers of English carry this over from their first language).\n */\n devoiceFinal?: boolean;\n /** Consonants said as others everywhere: { w: 'v' } for \"west\" as vest. */\n replace?: Readonly<Record<string, string>>;\n /**\n * Realizations used instead of `sets` when the vowel comes before a voiceless consonant in the\n * same word: Canadian raising, \"price\" and \"house\" with a raised start where \"prize\" and \"how\"\n * keep a low one.\n */\n raised?: Partial<Record<LexicalSet, string>>;\n /** Speech melody and rate; General American's when left out. */\n prosody?: Prosody;\n}\n\n/** General American's speech melody: a fall at the end of a statement, accents about four semitones high. */\nexport const DEFAULT_PROSODY: Prosody = { tune: 'fall', range: 4, declination: 2, rate: 1 };\n\nexport const GENERAL_AMERICAN: Accent = {\n id: 'general-american',\n name: 'General American',\n region: 'North America',\n rhotic: true,\n /*\n * Before an r in its own syllable American English keeps no tense and lax pair apart (pre-rhotic\n * neutralization, Wells 1982, Accents of English, vol. 1): \"fair\" is f\u025B\u0279, not fe\u026A\u0279, \"board\"\n * b\u0254\u0279d, \"near\" n\u026A\u0279, \"poor\" p\u028A\u0279. The CMU dictionary writes it so; spelling rules read \"ai\", \"oa\",\n * \"ea\" and \"oo\" as their free vowels, so the sets say it here, for every word.\n */\n sets: { NEAR: '\u026A', SQUARE: '\u025B', FORCE: '\u0254', CURE: '\u028A' },\n t: 'flap',\n l: 'dark-coda',\n th: 'fricative',\n r: 'approximant',\n};\n\nexport const SOUTHERN_BRITISH: Accent = {\n id: 'southern-british',\n name: 'Southern British',\n region: 'England',\n rhotic: false,\n sets: {\n KIT: '\u026A', DRESS: '\u025B', TRAP: 'a', LOT: '\u0252', STRUT: '\u0250', FOOT: '\u028A', BATH: '\u0251\u02D0', CLOTH: '\u0252', NURSE: '\u025C\u02D0',\n FLEECE: 'i\u02D0', FACE: 'e\u026A', PALM: '\u0251\u02D0', THOUGHT: 'o\u02D0', GOAT: '\u0259\u028A', GOOSE: '\u0289\u02D0', PRICE: 'a\u026A', CHOICE: '\u0254\u026A',\n MOUTH: 'a\u028A', NEAR: '\u026A\u0259', SQUARE: '\u025B\u02D0', START: '\u0251\u02D0', NORTH: 'o\u02D0', FORCE: 'o\u02D0', CURE: 'o\u02D0', happY: 'i',\n lettER: '\u0259', commA: '\u0259',\n },\n hold: 0.55,\n t: 'glottal-coda',\n l: 'dark-coda',\n th: 'fricative',\n r: 'approximant',\n prosody: { tune: 'fall', range: 6, declination: 3, rate: 1 },\n};\n\nexport const LONDON: Accent = {\n id: 'london',\n name: 'London',\n region: 'England',\n rhotic: false,\n sets: {\n KIT: '\u026A', DRESS: 'e', TRAP: '\u00E6', LOT: '\u0252', STRUT: '\u0250', FOOT: '\u028A', BATH: '\u0251\u02D0', CLOTH: '\u0252', NURSE: '\u025C\u02D0',\n FLEECE: '\u0259i', FACE: '\u00E6\u026A', PALM: '\u0251\u02D0', THOUGHT: 'o\u02D0', GOAT: '\u028C\u028A', GOOSE: '\u0289\u02D0', PRICE: '\u0251\u026A', CHOICE: 'o\u026A',\n MOUTH: '\u00E6\u028A', NEAR: '\u026A\u0259', SQUARE: 'e\u02D0', START: '\u0251\u02D0', NORTH: 'o\u02D0', FORCE: 'o\u02D0', CURE: 'o\u02D0', happY: 'i',\n lettER: '\u0259', commA: '\u0259',\n },\n hold: 0.5,\n t: 'glottal',\n l: 'vocalized',\n th: 'front',\n r: 'approximant',\n hDrop: true,\n prosody: { tune: 'fall', range: 5, declination: 2, rate: 1.05 },\n};\n\nexport const AUSTRALIAN: Accent = {\n id: 'australian',\n name: 'Australian',\n region: 'Southern hemisphere',\n rhotic: false,\n sets: {\n KIT: '\u026A', DRESS: 'e', TRAP: '\u00E6', LOT: '\u0254', STRUT: '\u0250', FOOT: '\u028A', BATH: '\u0250\u02D0', CLOTH: '\u0254', NURSE: '\u0275\u02D0',\n FLEECE: '\u026Ai', FACE: '\u00E6\u026A', PALM: '\u0250\u02D0', THOUGHT: 'o\u02D0', GOAT: '\u0250\u0289', GOOSE: '\u0289\u02D0', PRICE: '\u0252e', CHOICE: 'o\u026A',\n MOUTH: '\u00E6\u0254', NEAR: '\u026A\u0259', SQUARE: 'e\u02D0', START: '\u0250\u02D0', NORTH: 'o\u02D0', FORCE: 'o\u02D0', CURE: 'o\u02D0', happY: 'i',\n lettER: '\u0259', commA: '\u0259',\n },\n hold: 0.45,\n t: 'flap',\n l: 'dark-coda',\n th: 'fricative',\n r: 'approximant',\n prosody: { tune: 'rise', range: 4, declination: 1.5, rate: 1 },\n};\n\nexport const NEW_ZEALAND: Accent = {\n id: 'new-zealand',\n name: 'New Zealand',\n region: 'Southern hemisphere',\n rhotic: false,\n sets: {\n KIT: '\u0258', DRESS: 'e', TRAP: '\u025B', LOT: '\u0252', STRUT: '\u0250', FOOT: '\u028A', BATH: '\u0250\u02D0', CLOTH: '\u0252', NURSE: '\u00F8\u02D0',\n FLEECE: '\u026Ai', FACE: '\u00E6\u026A', PALM: '\u0250\u02D0', THOUGHT: 'o\u02D0', GOAT: '\u0250\u0289', GOOSE: '\u0289\u02D0', PRICE: '\u0252e', CHOICE: 'oe',\n MOUTH: '\u00E6\u028A', NEAR: 'i\u0259', SQUARE: 'i\u0259', START: '\u0250\u02D0', NORTH: 'o\u02D0', FORCE: 'o\u02D0', CURE: '\u0289\u0259', happY: 'i',\n lettER: '\u0258', commA: '\u0258',\n },\n hold: 0.45,\n t: 'flap',\n l: 'dark',\n th: 'fricative',\n r: 'approximant',\n prosody: { tune: 'rise', range: 3.5, declination: 1.5, rate: 1.05 },\n};\n\nexport const IRISH: Accent = {\n id: 'irish',\n name: 'Irish',\n region: 'Scotland, Wales and Ireland',\n rhotic: true,\n sets: {\n KIT: '\u026A', DRESS: '\u025B', TRAP: 'a', LOT: '\u0251', STRUT: '\u0250', FOOT: '\u028A', BATH: 'a\u02D0', CLOTH: '\u0252', FLEECE: 'i\u02D0',\n FACE: 'e\u02D0', PALM: 'a\u02D0', THOUGHT: '\u0252\u02D0', GOAT: 'o\u02D0', GOOSE: 'u\u02D0', PRICE: '\u0251\u026A', CHOICE: '\u0252\u026A', MOUTH: '\u0250\u028A',\n NEAR: 'i', SQUARE: 'e', START: 'a', NORTH: '\u0252', FORCE: 'o', CURE: 'u', happY: 'i',\n },\n hold: 0.6,\n t: 'released',\n l: 'clear',\n th: 'stop',\n r: 'approximant',\n prosody: { tune: 'fall', range: 5, declination: 2, rate: 1.05 },\n};\n\nexport const SCOTTISH: Accent = {\n id: 'scottish',\n name: 'Scottish',\n region: 'Scotland, Wales and Ireland',\n rhotic: true,\n sets: {\n KIT: '\u0258', DRESS: '\u025B', TRAP: 'a', LOT: '\u0254', STRUT: '\u028C', FOOT: '\u0289', BATH: 'a', CLOTH: '\u0254', NURSE: '\u028C\u027E',\n FLEECE: 'i', FACE: 'e', PALM: 'a', THOUGHT: '\u0254', GOAT: 'o', GOOSE: '\u0289', PRICE: '\u028C\u026A', CHOICE: '\u0254\u026A',\n MOUTH: '\u028C\u0289', NEAR: 'i\u027E', SQUARE: 'e\u027E', START: 'a\u027E', NORTH: '\u0254\u027E', FORCE: 'o\u027E', CURE: '\u0289\u027E', happY: 'e',\n lettER: '\u0259\u027E', commA: '\u028C',\n },\n hold: 0.5,\n t: 'glottal-coda',\n l: 'dark',\n th: 'fricative',\n r: 'tap',\n prosody: { tune: 'fall', range: 4, declination: 2, rate: 1 },\n};\n\nexport const SOUTHERN_US: Accent = {\n id: 'southern-us',\n name: 'Southern US',\n region: 'North America',\n rhotic: true,\n sets: {\n DRESS: '\u025B', TRAP: '\u00E6', BATH: '\u00E6', FACE: '\u025B\u026A', THOUGHT: '\u0252\u0254', CLOTH: '\u0252\u0254', GOAT: '\u025C\u0289', GOOSE: '\u0289',\n PRICE: 'a\u02D0', MOUTH: '\u00E6\u028A', CHOICE: 'o\u026A',\n },\n hold: 0.5,\n t: 'flap',\n l: 'dark',\n th: 'fricative',\n r: 'approximant',\n prosody: { tune: 'fall', range: 5, declination: 2, rate: 0.85 },\n};\n\n/* ---- North America ---- */\n\nexport const CANADIAN: Accent = {\n id: 'canadian',\n name: 'Canadian',\n region: 'North America',\n rhotic: true,\n sets: {\n TRAP: 'a', BATH: 'a', LOT: '\u0252', CLOTH: '\u0252', THOUGHT: '\u0252', PALM: '\u0252', FACE: 'e\u026A', GOAT: 'o\u028A',\n },\n // Canadian raising: \"price\" and \"house\" start higher than \"prize\" and \"how\"\n raised: { PRICE: '\u028C\u026A', MOUTH: '\u028C\u028A' },\n hold: 0.6,\n t: 'flap',\n l: 'dark-coda',\n th: 'fricative',\n r: 'approximant',\n prosody: { tune: 'fall', range: 4, declination: 2, rate: 1 },\n};\n\nexport const CALIFORNIAN: Accent = {\n id: 'californian',\n name: 'Californian',\n region: 'North America',\n rhotic: true,\n sets: {\n KIT: '\u026A', DRESS: '\u025B', TRAP: 'a', BATH: 'a', LOT: '\u0251', CLOTH: '\u0251', THOUGHT: '\u0251', FOOT: '\u0275', GOOSE: '\u0289',\n GOAT: '\u0275\u028A', FACE: 'e\u026A',\n },\n hold: 0.55,\n t: 'flap',\n l: 'dark-coda',\n th: 'fricative',\n r: 'approximant',\n prosody: { tune: 'fall', range: 4.5, declination: 2, rate: 1.05 },\n};\n\nexport const NEW_YORK: Accent = {\n id: 'new-york',\n name: 'New York',\n region: 'North America',\n rhotic: false,\n sets: {\n TRAP: '\u00E6', BATH: 'e\u0259', LOT: '\u0251', PALM: '\u0251', CLOTH: 'o\u0259', THOUGHT: 'o\u0259', NORTH: 'o\u0259', FORCE: 'o\u0259', START: '\u0251',\n NURSE: '\u025C', PRICE: '\u0251\u026A', MOUTH: '\u00E6\u028A', GOAT: 'o\u028A', NEAR: '\u026A\u0259', SQUARE: 'e\u0259', CURE: '\u028A\u0259', lettER: '\u0259',\n },\n hold: 0.55,\n t: 'flap',\n l: 'dark-coda',\n th: 'fricative',\n r: 'approximant',\n prosody: { tune: 'fall', range: 5, declination: 2, rate: 1.1 },\n};\n\n/* ---- Britain and Ireland ---- */\n\nexport const NORTHERN_ENGLISH: Accent = {\n id: 'northern-english',\n name: 'Northern English',\n region: 'England',\n rhotic: false,\n sets: {\n KIT: '\u026A', DRESS: '\u025B', TRAP: 'a', BATH: 'a', LOT: '\u0252', CLOTH: '\u0252', STRUT: '\u028A', FOOT: '\u028A', NURSE: '\u025C',\n FLEECE: 'i', FACE: 'e', PALM: '\u0251', THOUGHT: 'o', GOAT: 'o', GOOSE: 'u', PRICE: 'a\u026A', CHOICE: '\u0254\u026A',\n MOUTH: 'a\u028A', NEAR: '\u026A\u0259', SQUARE: '\u025B', START: 'a', NORTH: 'o', FORCE: 'o', CURE: '\u028A\u0259', happY: '\u026A',\n lettER: '\u0259', commA: '\u0259',\n },\n hold: 0.6,\n t: 'glottal-coda',\n l: 'dark-coda',\n th: 'fricative',\n r: 'approximant',\n hDrop: true,\n prosody: { tune: 'fall', range: 4, declination: 2, rate: 1 },\n};\n\nexport const GEORDIE: Accent = {\n id: 'geordie',\n name: 'Geordie (Tyneside)',\n region: 'England',\n rhotic: false,\n sets: {\n KIT: '\u026A', DRESS: '\u025B', TRAP: 'a', BATH: 'a', LOT: '\u0252', CLOTH: '\u0252', STRUT: '\u028A', FOOT: '\u028A', NURSE: '\u00F8',\n FLEECE: 'i', FACE: 'e\u0259', PALM: '\u0251', THOUGHT: '\u0252', GOAT: '\u0275', GOOSE: '\u0289', PRICE: '\u025B\u026A', CHOICE: '\u0254\u026A',\n MOUTH: 'u', NEAR: 'i\u0259', SQUARE: '\u025B', START: '\u0251', NORTH: '\u0252', FORCE: '\u0252', CURE: '\u0289\u0259', happY: 'i',\n lettER: '\u0250', commA: '\u0250',\n },\n hold: 0.55,\n t: 'glottal-coda',\n l: 'clear',\n th: 'fricative',\n r: 'approximant',\n prosody: { tune: 'rise', range: 5, declination: 1.5, rate: 1.05 },\n};\n\nexport const WELSH: Accent = {\n id: 'welsh',\n name: 'Welsh',\n region: 'Scotland, Wales and Ireland',\n rhotic: false,\n sets: {\n KIT: '\u026A', DRESS: '\u025B', TRAP: 'a', BATH: 'a', LOT: '\u0252', CLOTH: '\u0252', STRUT: '\u0259', FOOT: '\u028A', NURSE: '\u00F8',\n FLEECE: 'i', FACE: 'e', PALM: 'a', THOUGHT: 'o', GOAT: 'o', GOOSE: '\u0289', PRICE: '\u0259\u026A', CHOICE: '\u0254\u026A',\n MOUTH: '\u0259\u028A', NEAR: '\u026A\u0259', SQUARE: '\u025B', START: 'a', NORTH: 'o', FORCE: 'o', CURE: '\u028A\u0259', happY: 'i',\n lettER: '\u0259', commA: 'a',\n },\n hold: 0.55,\n t: 'released',\n l: 'clear',\n th: 'fricative',\n r: 'tap',\n // the Welsh lilt: a rise and wide range on statements, and less difference between syllables\n prosody: { tune: 'rise', range: 6, declination: 1, rate: 1, stressRatio: 1.5 },\n};\n\nexport const NORTHERN_IRISH: Accent = {\n id: 'northern-irish',\n name: 'Northern Irish (Belfast)',\n region: 'Scotland, Wales and Ireland',\n rhotic: true,\n sets: {\n KIT: '\u0258', DRESS: '\u025B', TRAP: '\u0251', BATH: '\u0251', LOT: '\u0254', CLOTH: '\u0254', STRUT: '\u0250', FOOT: '\u0289', FLEECE: 'i',\n FACE: 'e\u0259', PALM: '\u0251', THOUGHT: '\u0254', GOAT: 'o', GOOSE: '\u0289', PRICE: '\u025B\u026A', CHOICE: '\u0254\u026A', MOUTH: '\u0258\u0289',\n NEAR: 'i', SQUARE: 'e', START: '\u0251', NORTH: '\u0254', FORCE: 'o', CURE: '\u0289', happY: 'e',\n },\n hold: 0.5,\n t: 'flap',\n l: 'clear',\n th: 'fricative',\n r: 'approximant',\n // statements rise in Belfast (Grabe and Post)\n prosody: { tune: 'rise', range: 5, declination: 1.5, rate: 1.05 },\n};\n\n/* ---- Africa, Asia and the Caribbean ---- */\n\nexport const SOUTH_AFRICAN: Accent = {\n id: 'south-african',\n name: 'South African',\n region: 'Southern hemisphere',\n rhotic: false,\n sets: {\n KIT: '\u026A', DRESS: 'e', TRAP: '\u025B', BATH: '\u0251', LOT: '\u0252', CLOTH: '\u0252', STRUT: '\u0250', FOOT: '\u028A', NURSE: '\u00F8',\n FLEECE: 'i', FACE: 'e\u026A', PALM: '\u0251', THOUGHT: 'o', GOAT: '\u0153\u028A', GOOSE: '\u0289', PRICE: '\u0251\u026A', CHOICE: '\u0254\u026A',\n MOUTH: '\u00E6\u028A', NEAR: '\u026A\u0259', SQUARE: 'e', START: '\u0251', NORTH: 'o', FORCE: 'o', CURE: '\u028A\u0259', happY: 'i',\n lettER: '\u0259', commA: '\u0259',\n },\n hold: 0.55,\n t: 'released',\n l: 'clear',\n th: 'fricative',\n r: 'approximant',\n prosody: { tune: 'fall', range: 4, declination: 2, rate: 1 },\n};\n\nexport const NIGERIAN: Accent = {\n id: 'nigerian',\n name: 'Nigerian',\n region: 'Africa',\n rhotic: false,\n // no central vowels: STRUT and NURSE take full vowels, schwa is a\n sets: {\n KIT: 'i', DRESS: '\u025B', TRAP: 'a', BATH: 'a', LOT: '\u0254', CLOTH: '\u0254', STRUT: '\u0254', FOOT: 'u', NURSE: '\u025B',\n FLEECE: 'i', FACE: 'e', PALM: 'a', THOUGHT: '\u0254', GOAT: 'o', GOOSE: 'u', PRICE: 'a\u026A', CHOICE: '\u0254\u026A',\n MOUTH: 'a\u028A', NEAR: 'ia', SQUARE: '\u025B', START: 'a', NORTH: '\u0254', FORCE: '\u0254', CURE: 'ua', happY: 'i',\n lettER: 'a', commA: 'a',\n },\n hold: 0.5,\n t: 'released',\n l: 'clear',\n th: 'stop',\n r: 'tap',\n prosody: { tune: 'fall', range: 4, declination: 1.5, rate: 1, stressRatio: 1.1 },\n};\n\nexport const JAMAICAN: Accent = {\n id: 'jamaican',\n name: 'Jamaican',\n region: 'Caribbean',\n rhotic: false,\n sets: {\n KIT: '\u026A', DRESS: '\u025B', TRAP: 'a', BATH: 'a', LOT: 'a', CLOTH: 'a', STRUT: '\u0254', FOOT: '\u028A', NURSE: '\u0254',\n FLEECE: 'i', FACE: 'ie', PALM: 'a', THOUGHT: 'a', GOAT: 'uo', GOOSE: 'u', PRICE: 'a\u026A', CHOICE: 'a\u026A',\n MOUTH: '\u0254\u028A', NEAR: 'i\u025B', SQUARE: 'i\u025B', START: 'a', NORTH: 'a', FORCE: 'uo', CURE: 'uo', happY: 'i',\n lettER: 'a', commA: 'a',\n },\n hold: 0.45,\n t: 'released',\n l: 'clear',\n th: 'stop',\n r: 'approximant',\n hDrop: true,\n prosody: { tune: 'fall', range: 6, declination: 1.5, rate: 1.05, stressRatio: 1.3 },\n};\n\nexport const INDIAN: Accent = {\n id: 'indian',\n name: 'Indian',\n region: 'Asia',\n rhotic: true,\n sets: {\n KIT: '\u026A', DRESS: '\u025B', TRAP: '\u00E6', BATH: '\u0251', LOT: '\u0252', CLOTH: '\u0252', STRUT: '\u0259', FOOT: '\u028A', NURSE: '\u0259\u027E',\n FLEECE: 'i', FACE: 'e', PALM: '\u0251', THOUGHT: '\u0254', GOAT: 'o', GOOSE: 'u', PRICE: 'a\u026A', CHOICE: '\u0254\u026A',\n MOUTH: 'a\u028A', NEAR: 'i\u0259', SQUARE: 'e', START: '\u0251', NORTH: '\u0254', FORCE: 'o', CURE: 'u\u0259', happY: 'i',\n lettER: '\u0259\u027E', commA: '\u0259',\n },\n hold: 0.5,\n t: 'released',\n l: 'clear',\n th: 'stop',\n r: 'tap',\n prosody: { tune: 'fall', range: 5, declination: 1.5, rate: 1.05, stressRatio: 1.25 },\n};\n\nexport const SINGAPOREAN: Accent = {\n id: 'singaporean',\n name: 'Singaporean',\n region: 'Asia',\n rhotic: false,\n // long and short pairs merge: KIT with FLEECE, FOOT with GOOSE, DRESS with TRAP\n sets: {\n KIT: 'i', DRESS: '\u025B', TRAP: '\u025B', BATH: '\u0251', LOT: '\u0254', CLOTH: '\u0254', STRUT: '\u0250', FOOT: 'u', NURSE: '\u0259',\n FLEECE: 'i', FACE: 'e', PALM: '\u0251', THOUGHT: '\u0254', GOAT: 'o', GOOSE: 'u', PRICE: 'a\u026A', CHOICE: '\u0254\u026A',\n MOUTH: 'a\u028A', NEAR: '\u026A\u0259', SQUARE: '\u025B', START: '\u0251', NORTH: '\u0254', FORCE: '\u0254', CURE: '\u028A\u0259', happY: 'i',\n lettER: '\u0259', commA: '\u0259',\n },\n hold: 0.5,\n t: 'glottal-coda',\n l: 'clear',\n th: 'stop',\n r: 'approximant',\n // syllable-timed\n prosody: { tune: 'fall', range: 3, declination: 1, rate: 1.1, stressRatio: 1 },\n};\n\n/* ---- more of Britain ---- */\n\nexport const RECEIVED_PRONUNCIATION: Accent = {\n id: 'received-pronunciation',\n name: 'Received Pronunciation (traditional)',\n region: 'England',\n rhotic: false,\n // the older standard, before the changes Southern British shows: TRAP \u00E6, STRUT \u028C, SQUARE and CURE centring\n sets: {\n KIT: '\u026A', DRESS: 'e', TRAP: '\u00E6', LOT: '\u0252', STRUT: '\u028C', FOOT: '\u028A', BATH: '\u0251\u02D0', CLOTH: '\u0252', NURSE: '\u025C\u02D0',\n FLEECE: 'i\u02D0', FACE: 'e\u026A', PALM: '\u0251\u02D0', THOUGHT: '\u0254\u02D0', GOAT: '\u0259\u028A', GOOSE: 'u\u02D0', PRICE: 'a\u026A', CHOICE: '\u0254\u026A',\n MOUTH: 'a\u028A', NEAR: '\u026A\u0259', SQUARE: '\u025B\u0259', START: '\u0251\u02D0', NORTH: '\u0254\u02D0', FORCE: '\u0254\u02D0', CURE: '\u028A\u0259', happY: '\u026A',\n lettER: '\u0259', commA: '\u0259',\n },\n hold: 0.6,\n t: 'released',\n l: 'dark-coda',\n th: 'fricative',\n r: 'approximant',\n prosody: { tune: 'fall', range: 7, declination: 3, rate: 0.95 },\n};\n\nexport const SCOUSE: Accent = {\n id: 'scouse',\n name: 'Scouse (Liverpool)',\n region: 'England',\n rhotic: false,\n // NURSE and SQUARE merge (\"fair\" and \"fur\"); FOOT and STRUT merge\n sets: {\n KIT: '\u026A', DRESS: '\u025B', TRAP: 'a', BATH: 'a', LOT: '\u0252', CLOTH: '\u0252', STRUT: '\u028A', FOOT: '\u028A', NURSE: '\u025B\u02D0',\n FLEECE: 'i\u02D0', FACE: '\u025B\u026A', PALM: '\u0251', THOUGHT: '\u0254', GOAT: '\u0259\u0289', GOOSE: '\u0289', PRICE: 'a\u026A', CHOICE: '\u0254\u026A',\n MOUTH: 'a\u028A', NEAR: 'i\u0259', SQUARE: '\u025B\u02D0', START: '\u0251', NORTH: '\u0254', FORCE: '\u0254', CURE: '\u0289\u0259', happY: 'i',\n lettER: '\u0259', commA: '\u0259',\n },\n hold: 0.5,\n t: 'released',\n l: 'clear',\n th: 'fricative',\n r: 'tap',\n prosody: { tune: 'rise', range: 5, declination: 1.5, rate: 1.1 },\n};\n\nexport const BRUMMIE: Accent = {\n id: 'brummie',\n name: 'Brummie (Birmingham)',\n region: 'England',\n rhotic: false,\n // PRICE starts back and rounded, FACE and GOAT start low and central; a famously level tune\n sets: {\n KIT: '\u026A', DRESS: '\u025B', TRAP: 'a', BATH: 'a', LOT: '\u0252', CLOTH: '\u0252', STRUT: '\u028A', FOOT: '\u028A', NURSE: '\u025C',\n FLEECE: '\u0259i', FACE: '\u028C\u026A', PALM: '\u0251', THOUGHT: '\u0254', GOAT: '\u028C\u028A', GOOSE: '\u0259\u0289', PRICE: '\u0254\u026A', CHOICE: 'o\u026A',\n MOUTH: '\u00E6\u028A', NEAR: 'i\u0259', SQUARE: '\u025B', START: '\u0251', NORTH: '\u0254', FORCE: '\u0254', CURE: '\u0289\u0259', happY: 'i',\n lettER: '\u0259', commA: '\u0259',\n },\n hold: 0.5,\n t: 'glottal-coda',\n l: 'dark-coda',\n th: 'fricative',\n r: 'approximant',\n hDrop: true,\n prosody: { tune: 'fall', range: 2.5, declination: 1, rate: 1 },\n};\n\nexport const WEST_COUNTRY: Accent = {\n id: 'west-country',\n name: 'West Country',\n region: 'England',\n // one of the few English accents of England that keeps r after a vowel\n rhotic: true,\n sets: {\n KIT: '\u026A', DRESS: '\u025B', TRAP: 'a', BATH: 'a', LOT: '\u0252', CLOTH: '\u0252', STRUT: '\u0250', FOOT: '\u028A', FLEECE: 'i',\n FACE: 'e', PALM: 'a', THOUGHT: '\u0252', GOAT: 'o', GOOSE: '\u0289', PRICE: '\u0250\u026A', CHOICE: '\u0254\u026A', MOUTH: '\u0250\u028A',\n NEAR: 'i', SQUARE: '\u025B', START: 'a', NORTH: '\u0252', FORCE: 'o', CURE: '\u0289', happY: 'i',\n },\n hold: 0.55,\n t: 'glottal-coda',\n l: 'dark',\n th: 'fricative',\n r: 'approximant',\n prosody: { tune: 'fall', range: 4.5, declination: 2, rate: 0.95 },\n};\n\n/* ---- more of North America ---- */\n\nexport const BOSTON: Accent = {\n id: 'boston',\n name: 'Boston',\n region: 'North America',\n rhotic: false,\n // START and BATH fronted (\"pahk the cah\"); LOT and THOUGHT merged; PRICE raised before voiceless\n sets: {\n TRAP: '\u00E6', BATH: 'a', LOT: '\u0252', CLOTH: '\u0252', THOUGHT: '\u0252', PALM: 'a', START: 'a', NURSE: '\u025C',\n NEAR: '\u026A\u0259', SQUARE: '\u025B\u0259', NORTH: '\u0254\u0259', FORCE: '\u0254\u0259', CURE: '\u028A\u0259', lettER: '\u0259', MOUTH: 'a\u028A',\n },\n raised: { PRICE: '\u028C\u026A' },\n hold: 0.6,\n t: 'flap',\n l: 'dark-coda',\n th: 'fricative',\n r: 'approximant',\n prosody: { tune: 'fall', range: 4.5, declination: 2, rate: 1.1 },\n};\n\nexport const INLAND_NORTH: Accent = {\n id: 'inland-north',\n name: 'Inland North (Chicago, Detroit)',\n region: 'North America',\n rhotic: true,\n // the Northern Cities Shift: TRAP raised to e\u0259, LOT fronted to a, THOUGHT lowered, DRESS and STRUT backed\n sets: {\n TRAP: 'e\u0259', BATH: 'e\u0259', LOT: 'a', PALM: 'a', THOUGHT: '\u0251', CLOTH: '\u0251', DRESS: '\u025C', STRUT: '\u0254', KIT: '\u0258',\n },\n hold: 0.65,\n t: 'flap',\n l: 'dark-coda',\n th: 'fricative',\n r: 'approximant',\n prosody: { tune: 'fall', range: 4, declination: 2, rate: 1.05 },\n};\n\n/* ---- more of Africa, Asia and the Caribbean ---- */\n\nexport const FILIPINO: Accent = {\n id: 'filipino',\n name: 'Filipino',\n region: 'Asia',\n rhotic: true,\n // a five-vowel system, rhotic with a tap, syllable-timed\n sets: {\n KIT: 'i', DRESS: '\u025B', TRAP: 'a', BATH: 'a', LOT: '\u0254', CLOTH: '\u0254', STRUT: 'a', FOOT: 'u', NURSE: '\u025B\u027E',\n FLEECE: 'i', FACE: 'e', PALM: 'a', THOUGHT: '\u0254', GOAT: 'o', GOOSE: 'u', PRICE: 'a\u026A', CHOICE: '\u0254\u026A',\n MOUTH: 'a\u028A', NEAR: 'i\u027E', SQUARE: '\u025B\u027E', START: 'a\u027E', NORTH: '\u0254\u027E', FORCE: 'o\u027E', CURE: 'u\u027E', happY: 'i',\n lettER: '\u025B\u027E', commA: 'a',\n },\n hold: 0.5,\n t: 'released',\n l: 'clear',\n th: 'stop',\n r: 'tap',\n prosody: { tune: 'fall', range: 4.5, declination: 1.5, rate: 1.05, stressRatio: 1.15 },\n};\n\nexport const GHANAIAN: Accent = {\n id: 'ghanaian',\n name: 'Ghanaian',\n region: 'Africa',\n rhotic: false,\n sets: {\n KIT: 'i', DRESS: '\u025B', TRAP: 'a', BATH: 'a', LOT: '\u0254', CLOTH: '\u0254', STRUT: 'a', FOOT: 'u', NURSE: '\u025B',\n FLEECE: 'i', FACE: 'e', PALM: 'a', THOUGHT: '\u0254', GOAT: 'o', GOOSE: 'u', PRICE: 'a\u026A', CHOICE: '\u0254\u026A',\n MOUTH: 'a\u028A', NEAR: 'ia', SQUARE: '\u025B', START: 'a', NORTH: '\u0254', FORCE: '\u0254', CURE: 'ua', happY: 'i',\n lettER: 'a', commA: 'a',\n },\n hold: 0.5,\n t: 'released',\n l: 'clear',\n th: 'stop',\n r: 'approximant',\n prosody: { tune: 'fall', range: 5, declination: 1.5, rate: 1, stressRatio: 1.1 },\n};\n\nexport const KENYAN: Accent = {\n id: 'kenyan',\n name: 'Kenyan',\n region: 'Africa',\n rhotic: false,\n // five vowels, as in Swahili; th kept as a fricative\n sets: {\n KIT: 'i', DRESS: 'e', TRAP: 'a', BATH: 'a', LOT: '\u0254', CLOTH: '\u0254', STRUT: 'a', FOOT: 'u', NURSE: 'e',\n FLEECE: 'i', FACE: 'e', PALM: 'a', THOUGHT: '\u0254', GOAT: 'o', GOOSE: 'u', PRICE: 'a\u026A', CHOICE: '\u0254\u026A',\n MOUTH: 'a\u028A', NEAR: 'ia', SQUARE: 'ea', START: 'a', NORTH: '\u0254', FORCE: '\u0254', CURE: 'ua', happY: 'i',\n lettER: 'a', commA: 'a',\n },\n hold: 0.5,\n t: 'released',\n l: 'clear',\n th: 'fricative',\n r: 'tap',\n prosody: { tune: 'fall', range: 4, declination: 1.5, rate: 1, stressRatio: 1.15 },\n};\n\nexport const TRINIDADIAN: Accent = {\n id: 'trinidadian',\n name: 'Trinidadian',\n region: 'Caribbean',\n rhotic: false,\n sets: {\n KIT: '\u026A', DRESS: '\u025B', TRAP: 'a', BATH: 'a', LOT: '\u0252', CLOTH: '\u0252', STRUT: '\u0254', FOOT: '\u028A', NURSE: '\u025C',\n FLEECE: 'i', FACE: 'e', PALM: 'a', THOUGHT: '\u0252', GOAT: 'o', GOOSE: 'u', PRICE: 'a\u026A', CHOICE: '\u0252\u026A',\n MOUTH: '\u0254\u028A', NEAR: 'i\u025B', SQUARE: '\u025B', START: 'a', NORTH: '\u0252', FORCE: 'o', CURE: '\u028A\u0259', happY: 'i',\n lettER: 'a', commA: 'a',\n },\n hold: 0.5,\n t: 'released',\n l: 'clear',\n th: 'stop',\n r: 'approximant',\n // a lively, wide melody\n prosody: { tune: 'rise', range: 7, declination: 1.5, rate: 1.1, stressRatio: 1.3 },\n};\n\n/* ---- Europe: English as a second language ---- */\n\nexport const RUSSIAN: Accent = {\n id: 'russian',\n name: 'Russian',\n region: 'Europe',\n rhotic: true,\n // Russian's five vowels and \u0268: KIT and FLEECE merge, TRAP is \u025B, STRUT a, and unstressed vowels keep\n // more of their quality than English reduction leaves them\n sets: {\n KIT: 'i', DRESS: '\u025B', TRAP: '\u025B', BATH: 'a', LOT: '\u0254', CLOTH: '\u0254', STRUT: 'a', FOOT: 'u', NURSE: '\u0275\u027E',\n FLEECE: 'i', FACE: 'ei', PALM: 'a', THOUGHT: '\u0254', GOAT: 'o', GOOSE: 'u', PRICE: 'a\u026A', CHOICE: '\u0254\u026A',\n MOUTH: 'a\u028A', NEAR: 'i', SQUARE: '\u025B', START: 'a', NORTH: '\u0254', FORCE: '\u0254', CURE: 'u', happY: 'i',\n lettER: '\u025B\u027E', commA: 'a',\n },\n hold: 0.5,\n t: 'released',\n // Russian's hard l is velarized everywhere\n l: 'dark',\n th: 'sibilant',\n r: 'tap',\n // no w in Russian: \"west\" as vest\n replace: { w: 'v' },\n devoiceFinal: true,\n prosody: { tune: 'fall', range: 6, declination: 2.5, rate: 0.95, stressRatio: 1.7 },\n};\n\n/** The regions the built-in accents are grouped in, in display order. */\nexport const ACCENT_REGIONS: readonly string[] = ['North America', 'England', 'Scotland, Wales and Ireland', 'Southern hemisphere', 'Africa', 'Caribbean', 'Asia', 'Europe'];\n\n/** The built-in accents, by id. */\nexport const ACCENTS: Readonly<Record<string, Accent>> = Object.freeze(\n Object.fromEntries(\n [\n GENERAL_AMERICAN, CANADIAN, CALIFORNIAN, NEW_YORK, BOSTON, INLAND_NORTH, SOUTHERN_US,\n RECEIVED_PRONUNCIATION, SOUTHERN_BRITISH, LONDON, WEST_COUNTRY, BRUMMIE, SCOUSE, NORTHERN_ENGLISH,\n GEORDIE, SCOTTISH, WELSH, IRISH, NORTHERN_IRISH,\n AUSTRALIAN, NEW_ZEALAND, SOUTH_AFRICAN,\n NIGERIAN, GHANAIAN, KENYAN, JAMAICAN, TRINIDADIAN, INDIAN, SINGAPOREAN, FILIPINO,\n RUSSIAN,\n ].map((a) => [a.id, a]),\n ),\n);\n\n/** An accent by id, or the accent itself; General American when left out. Throws on an unknown id. */\nexport function resolveAccent(accent: Accent | string | undefined): Accent {\n if (accent === undefined) return GENERAL_AMERICAN;\n if (typeof accent !== 'string') return accent;\n const found = ACCENTS[accent];\n if (!found) throw new Error(`unknown accent \"${accent}\"; built in: ${Object.keys(ACCENTS).join(', ')}`);\n return found;\n}\n\n/** A realization read into its vowels and the r after them. */\nexport interface Realization {\n vowels: string[];\n /** The r the accent says after the vowel, or undefined. */\n r?: string;\n}\n\nconst LENGTH = /[\u02D0\u02D1:]/g;\n\n/** \"\u0259\u028A\" to { vowels: ['\u0259', '\u028A'] }, \"\u028C\u027E\" to { vowels: ['\u028C'], r: '\u027E' }. */\nexport function readRealization(ipa: string): Realization {\n const chars = Array.from(ipa.replace(LENGTH, ''));\n let r: string | undefined;\n const last = chars[chars.length - 1];\n if (last === '\u0279' || last === '\u027E' || last === 'r') {\n r = last === 'r' ? '\u0279' : last;\n chars.pop();\n }\n const vowels = chars.filter((c) => isVowel(c));\n if (vowels.length === 0 || vowels.length > 2 || vowels.length !== chars.length) {\n throw new Error(`accent realization \"${ipa}\" is not one or two vowels and an optional r`);\n }\n return { vowels, r };\n}\n\nconst R_SOUNDS = new Set(['\u0279', '\u027E', 'r']);\n\n/**\n * Re-voice the English syllables of a lyric in `accent`, in place: vowels by lexical set, r after a\n * vowel, th, r and h. The t and l rules belong to the allophone pass that follows (allophones.ts),\n * since they need the same neighbours flapping does. `english` says which syllables the English\n * reader produced; the rest are left alone.\n */\nexport function applyAccent(syllables: readonly Syllable[], english: (s: Syllable) => boolean, accent: Accent): void {\n for (let i = 0; i < syllables.length; i++) {\n const syl = syllables[i];\n if (!english(syl) || syl.melisma) continue;\n const next = syllables[i + 1];\n const linked = !syl.phraseEnd && next !== undefined && english(next) && !next.melisma && next.onset.length === 0;\n // the consonant after the vowel in the same word, for raising\n const after = syl.coda[0] ?? (!syl.wordEnd && next !== undefined ? next.onset[0] : undefined);\n const beforeVoiceless = after !== undefined && VOICELESS.has(after.ipa);\n voiceVowel(syl, accent, linked, beforeVoiceless);\n consonants(syl, accent, i === 0 || syllables[i - 1].wordEnd);\n }\n}\n\nconst VOICELESS = new Set(['p', 't', 'k', 'f', '\u03B8', 's', '\u0283', 't\u0283', 'h']);\n\nfunction voiceVowel(syl: Syllable, accent: Accent, linked: boolean, beforeVoiceless: boolean): void {\n const n = syl.nucleus;\n const set = n.set;\n const raised = set !== undefined && beforeVoiceless ? accent.raised?.[set] : undefined;\n const spec = raised ?? (set === undefined ? undefined : accent.sets[set]);\n // an r-colored General American vowel loses its color in an accent that names its set\n const hadR = n.ipa === '\u025D' || n.ipa === '\u025A';\n if (spec !== undefined) {\n const real = readRealization(spec);\n n.ipa = real.vowels.join('');\n if (real.r !== undefined) {\n const r = accent.r === 'tap' ? '\u027E' : real.r;\n if (syl.coda.length > 0 && R_SOUNDS.has(syl.coda[0].ipa)) syl.coda[0].ipa = r;\n else syl.coda.unshift({ ipa: r });\n } else if (hadR && !accent.rhotic && linked) {\n // linking r: \"better off\", \"her own\"\n syl.coda.unshift({ ipa: '\u0279' });\n }\n }\n if (!accent.rhotic) dropCodaR(syl, linked);\n if (Array.from(n.ipa).length === 2 && set !== undefined) {\n const hold = accent.holds?.[set] ?? accent.hold;\n if (hold !== undefined) n.hold = Math.max(0, Math.min(1, hold));\n }\n}\n\n/** A non-rhotic accent says r only before a vowel: \"car\" and \"card\" lose it, \"far away\" keeps it. */\nfunction dropCodaR(syl: Syllable, linked: boolean): void {\n for (let k = syl.coda.length - 1; k >= 0; k--) {\n if (!R_SOUNDS.has(syl.coda[k].ipa)) continue;\n const last = k === syl.coda.length - 1;\n if (last && linked) continue;\n syl.coda.splice(k, 1);\n }\n}\n\nconst DEVOICE: Readonly<Record<string, string>> = { b: 'p', d: 't', g: 'k', v: 'f', z: 's', \u00F0: '\u03B8', \u0292: '\u0283', d\u0292: 't\u0283' };\n\nfunction consonants(syl: Syllable, accent: Accent, wordStart: boolean): void {\n const parts: Segment[][] = [syl.onset, syl.coda];\n for (const segs of parts) {\n for (let k = 0; k < segs.length; k++) {\n const s = segs[k];\n const first = wordStart && segs === syl.onset && k === 0;\n if (accent.th === 'stop') {\n if (s.ipa === '\u03B8') s.ipa = 't';\n else if (s.ipa === '\u00F0') s.ipa = 'd';\n } else if (accent.th === 'front') {\n if (s.ipa === '\u03B8') s.ipa = 'f';\n else if (s.ipa === '\u00F0') s.ipa = first ? 'd' : 'v';\n } else if (accent.th === 'sibilant') {\n if (s.ipa === '\u03B8') s.ipa = 's';\n else if (s.ipa === '\u00F0') s.ipa = 'z';\n }\n if (accent.r === 'tap' && s.ipa === '\u0279') s.ipa = '\u027E';\n const swap = accent.replace?.[s.ipa];\n if (swap !== undefined) s.ipa = swap;\n }\n }\n // word-final devoicing: the last consonants of a word, back to the first that is not voiced\n if (accent.devoiceFinal && syl.wordEnd) {\n for (let k = syl.coda.length - 1; k >= 0; k--) {\n const v = DEVOICE[syl.coda[k].ipa];\n if (v === undefined) break;\n syl.coda[k].ipa = v;\n }\n }\n if (accent.hDrop && wordStart && syl.onset.length > 0 && syl.onset[0].ipa === 'h') syl.onset.shift();\n}\n", "/*\n * Lyrics to sung syllables: the router that walks a lyric, hands each word to the front end\n * that claims it, and keeps the conventions every language shares.\n *\n * Ported from CHIMERA by Jameson Hodge (MIT),\n * https://github.com/jamesondh/chimera-vocal-synth, crates/chimera/src/phonetics/syllables.rs\n * (lyric_tokens, read_lyrics, lyrics_to_syllables) at 1d3ea49 (TypeScript original at\n * cd247a6^:src/engine/phonetics/syllables.ts). Changes from the original: front ends may read\n * delimited words, which /IPA/ uses; the text is NFC-normalized; Korean is not ported.\n * See THIRD_PARTY_NOTICES.md.\n *\n * Conventions, as in vocaloid editors and CHIMERA:\n *\n * - A hyphen inside a word splits it into syllables explicitly: \"ti-ger\" is two notes.\n * - A free-standing \"-\" or \"~\" is a melisma: the previous syllable's vowel carries on to the\n * next note, as a syllable with no consonants, text \"~\" and `melisma` set.\n * - . , ; : ! ? and a line break end a phrase: the syllable before them has `phraseEnd`, a breath.\n * - A curly apostrophe reads as a straight one (\"don\u2019t\").\n * - Characters no front end claims (digits, symbols, scripts with no front end) are skipped.\n *\n * Delimited words are bellows' addition, for the /IPA/ front end. A front end that does not\n * continue the character it starts on reads a word between two of that character, and is\n * handed the word with both. The word opens at the start of the text or after a character that\n * is not a letter, mark or digit, and before one that is not a space; it closes at the same\n * character after one that is not a space, before the front end stops continuing (for IPA,\n * before the line ends). An opening character with no close is skipped like any other\n * unclaimed character, so \"and/or\" and \"3/4\" stay plain text. FrontEnd's character tests are\n * stateless and cannot say where a word ends, which is why the router owns this rule.\n */\n\nimport type { FrontEnd, PronouncingDictionary, Syllable } from './types';\nimport { englishFrontEnd } from './english';\nimport { ipaFrontEnd } from './ipa-front-end';\nimport { applyAllophones } from './allophones';\nimport { applyAccent, resolveAccent, type Accent } from './accents';\n\nconst SPACE = /\\s/;\n/** A word character in any script: a delimited word may not open right after one. */\nconst WORDLIKE = /[\\p{L}\\p{M}\\p{N}]/u;\n\nfunction isPhrasePunct(c: string): boolean {\n return (\n c === '.' || c === ',' || c === ';' || c === ':' || c === '!' || c === '?' || c === '\\n'\n );\n}\n\n/**\n * Lyric text to syllables, each word read by the first front end that claims its first\n * character. Deterministic, and never throws on text: empty, punctuation-only or unreadable\n * input gives [].\n */\nexport function readLyrics(text: string, frontEnds: readonly FrontEnd[]): Syllable[] {\n const s = Array.from(text.normalize('NFC').replace(/\u2019/g, \"'\"));\n const out: Syllable[] = [];\n let i = 0;\n while (i < s.length) {\n const c = s[i];\n const fe = frontEnds.find((f) => f.starts(c));\n if (fe) {\n const end = fe.continues(c) ? openWordEnd(s, i, fe) : delimitedWordEnd(s, i, fe);\n if (end > i) {\n addWord(out, fe.word(s.slice(i, end).join('')));\n i = end;\n continue;\n }\n }\n if (isPhrasePunct(c)) {\n if (out.length > 0) out[out.length - 1].phraseEnd = true;\n } else if (isMelisma(s, i)) {\n const prev = out[out.length - 1];\n if (prev) {\n out.push({\n text: '~',\n onset: [],\n nucleus: { ...prev.nucleus },\n coda: [],\n melisma: true,\n wordEnd: prev.wordEnd,\n phraseEnd: false,\n });\n }\n }\n i++;\n }\n return out;\n}\n\n/**\n * Lyric text to syllables with the built-in front ends: English, through the dictionary when\n * one is given and letter-to-sound rules otherwise, and IPA between slashes. The English words\n * then get American flaps and dark l (allophones.ts) unless `allophones` is false, which is\n * how CHIMERA's own sung syllables come out and how classical diction sings; IPA is sung as\n * written either way. `accent` (an id from ACCENTS or an Accent) re-voices the English words'\n * vowels and r, th and h first (accents.ts), and picks the t and l rules; General American, the\n * default, leaves them as the reader gave them.\n */\nexport function lyricsToSyllables(\n text: string,\n opts: {\n dictionary?: PronouncingDictionary;\n /** The accent's t and l rules on English words, default true; false for classical diction, as CHIMERA sings. */\n allophones?: boolean;\n /** An accent id ('southern-british', 'australian', ...; see ACCENTS) or an Accent. Default General American. */\n accent?: Accent | string;\n /** Weak forms of function words (\"the\" \u00F0\u0259, \"and\" \u0259nd), as speech has them; off for singing. */\n reduce?: boolean;\n } = {},\n): Syllable[] {\n const english = englishFrontEnd({ dictionary: opts.dictionary, reduce: opts.reduce });\n const read = new WeakSet<Syllable>();\n const tagged: FrontEnd = {\n starts: english.starts,\n continues: english.continues,\n word: (w) => {\n const syllables = english.word(w);\n for (const syl of syllables) read.add(syl);\n return syllables;\n },\n };\n const out = readLyrics(text, [tagged, ipaFrontEnd]);\n const accent = resolveAccent(opts.accent);\n const isEnglish = (syl: Syllable) => read.has(syl);\n // General American too: its sets say what the reader cannot (the vowels before r)\n applyAccent(out, isEnglish, accent);\n // flaps and dark l need the next sound, which can be in the next word (allophones.ts)\n if (opts.allophones !== false) applyAllophones(out, isEnglish, { t: accent.t, l: accent.l });\n return out;\n}\n\nfunction addWord(out: Syllable[], syllables: Syllable[]): void {\n if (syllables.length === 0) return;\n syllables[syllables.length - 1].wordEnd = true;\n for (const syl of syllables) out.push(syl);\n}\n\n/** Exclusive end of a word that runs while its front end continues it. */\nfunction openWordEnd(s: readonly string[], i: number, fe: FrontEnd): number {\n let j = i + 1;\n while (j < s.length && fe.continues(s[j])) j++;\n return j;\n}\n\n/** Exclusive end of a delimited word opening at i, past its closing character; i if none. */\nfunction delimitedWordEnd(s: readonly string[], i: number, fe: FrontEnd): number {\n const mark = s[i];\n if (i > 0 && WORDLIKE.test(s[i - 1])) return i;\n if (i + 1 >= s.length || s[i + 1] === mark || SPACE.test(s[i + 1])) return i;\n let j = i + 1;\n while (j < s.length && s[j] !== mark && fe.continues(s[j])) j++;\n if (j >= s.length || s[j] !== mark || SPACE.test(s[j - 1])) return i;\n return j + 1;\n}\n\nfunction isMelisma(s: readonly string[], i: number): boolean {\n const c = s[i];\n if (c !== '-' && c !== '~') return false;\n const before = i === 0 || SPACE.test(s[i - 1]);\n const after = i + 1 === s.length || SPACE.test(s[i + 1]);\n return before && after;\n}\n", "/*\n * The CMU Pronouncing Dictionary's text format, read into the map the English front end looks\n * words up in. Bellows ships no dictionary (CMUdict is 3.3 MB raw and BSD-licensed); a caller\n * that wants one fetches or bundles the text and passes the result of parseCmudict as\n * `dictionary`.\n *\n * Written for bellows. CHIMERA reads its own tab-separated copy instead\n * (crates/chimera/src/phonetics/english.rs, load_dict); this reads the files CMU distributes.\n *\n * Accepted, line by line:\n *\n * - cmudict-0.7b: upper-case \"WORD PHONES\" with two spaces, \";;;\" comment lines.\n * - cmudict.dict (the cmusphinx repository): lower-case \"word PHONES\" with one space, and an\n * optional \"# comment\" after the phones.\n * - Any \"word<TAB>PHONES\" copy, CHIMERA's included.\n *\n * Keys are lower-cased. An alternate pronunciation, \"WORD(2)\", is ignored, and so is any later\n * line for a word already read: the first pronunciation wins, which in CMUdict is the most\n * common one. Entries that name punctuation (\"#HASH-MARK\") are kept; a \"#\" only starts a\n * comment after the word. A line with no phones is skipped.\n */\n\nconst ENTRY = /^(\\S+)\\s+(.+)$/;\nconst ALTERNATE = /\\(\\d+\\)$/;\n\n/** CMUdict text to a map from lower-case word to its ARPAbet phones. Never throws. */\nexport function parseCmudict(text: string): Map<string, string> {\n const out = new Map<string, string>();\n for (const raw of text.split('\\n')) {\n const line = raw.trim();\n if (line === '' || line.startsWith(';;;')) continue;\n const m = ENTRY.exec(line);\n if (!m) continue;\n const word = m[1];\n if (ALTERNATE.test(word)) continue;\n const hash = m[2].indexOf('#');\n const phones = (hash < 0 ? m[2] : m[2].slice(0, hash)).trim().split(/\\s+/).join(' ');\n if (phones === '') continue;\n const key = word.toLowerCase();\n if (!out.has(key)) out.set(key, phones);\n }\n return out;\n}\n", "/*\n * Sung timing: notes and syllables in, one timed phoneme span list per\n * breath out.\n *\n * The sung timing follows CHIMERA by Jameson Hodge\n * (crates/chimera/src/phonetics/sing.rs, `plan_song` and `fit`, at 1d3ea49;\n * TypeScript original at cd247a6^:src/engine/phonetics/sing.ts).\n * Reimplemented here. See THIRD_PARTY_NOTICES.md.\n *\n * The rules are the ones a singer follows:\n *\n * - A note's vowel lands exactly on the note time. Its onset consonants\n * are sung just before it, taking their time from the previous note,\n * and they already carry the new pitch, so the pitch has arrived when\n * the vowel starts.\n * - A coda keeps the old pitch and finishes just before the next note's\n * onset, or at the note's end on the last note of a phrase.\n * - A fast passage squeezes. Between two beats sit a vowel, its coda and\n * the next onset; when the consonants would leave the vowel less than\n * MIN_VOWEL, they shrink in proportion, each down to MIN_CONSONANT, so\n * the next vowel still lands on its beat and a run does not drift.\n * - A diphthong holds its first vowel for 80% of the vowel time and\n * glides to its second at the end of the note.\n * - A melisma carries the vowel onto further notes, moving the pitch at\n * each note time, and the coda waits for the last of them.\n * - A phrase is one breath, ended by a syllable marked phraseEnd or by a\n * rest.\n *\n * What differs from CHIMERA, and why. CHIMERA plays its plan on one\n * simulated airway, which blends whatever overlaps; bellows plays a phrase\n * as a pooled voice driven by sample-accurate Param events, so overlaps\n * would be two singers and drift would be audible against the beat.\n *\n * - Vowels never drift. Where even floored consonants leave less than\n * SHORTEST_VOWEL, CHIMERA keeps the vowel at that length and every\n * later vowel lands late (its tests/sing_fast.rs allows 8 ms a note).\n * Here the floored consonants and that shortest vowel shrink together\n * in proportion to fit the time there is.\n * - Squeezing never lengthens a consonant: one already shorter than the\n * floor keeps its length, where CHIMERA's fit raises it to 12 ms.\n * - Phrases never overlap. A phrase's last note stops no later than the\n * next phrase's first sound, and at a phraseEnd the breath (CHIMERA's\n * 120 ms, or 30% of a shorter note) is kept clear before that sound,\n * taken from the end of the note when the melody leaves no rest for\n * it. CHIMERA reserves the breath at the note's end, and the next\n * phrase's onset may then sound under it.\n * - A phrase ended by a rest holds to its note's end. CHIMERA stops the\n * last one up to 50 ms early for its breath release; here the engine's own\n * release envelope follows the end.\n * - A phrase that opens on a melisma, after a breath, sings its vowel\n * again with no consonants. CHIMERA reaches back across the breath and\n * sings the earlier syllable's coda a second time.\n * - A segment's `dur` is honoured as an override. CHIMERA's sung path\n * replaces it with the inventory default.\n * - Notes arrive in seconds and Hz, already through the caller's tempo\n * map and tuning, instead of beats at one bpm and MIDI numbers.\n *\n * This is a planner and runs off the audio thread; it allocates.\n */\n\nimport { clamp } from 'bellowsjs';\nimport { SUNG_CONSONANT_SCALE, consonantDuration } from './durations';\nimport { isVowel } from './ipa';\nimport type {\n Segment,\n SungNote,\n SungPhrase,\n SungPitch,\n SungPlan,\n SungSpan,\n Syllable,\n} from './types';\n\n/** A sung vowel keeps at least this long (s) when a short note squeezes its consonants. */\nexport const MIN_VOWEL = 0.05;\n/**\n * A squeezed consonant keeps at least this long (s). The shortest sung\n * consonant unsqueezed, the flap \u027E, is 20 ms.\n */\nexport const MIN_CONSONANT = 0.012;\n/**\n * The vowel a note keeps when its consonants are at their floor (s).\n * Shorter than that, consonants and vowel shrink together.\n */\nexport const SHORTEST_VOWEL = 0.02;\n\n/** The breath before a phrase that follows a phraseEnd (s), CHIMERA's reserve. */\nconst BREATH = 0.12;\n/** ...but no more than this share of the note it is taken from. */\nconst BREATH_SHARE = 0.3;\n/** A diphthong holds its first vowel for this share of the vowel time, unless its segment says (an accent's hold). */\nconst DIPHTHONG_HOLD = 0.8;\n/** A gap longer than this (s) between one note's end and the next note is a rest. */\nconst REST = 0.001;\nconst DEFAULT_VEL = 0.8;\n/** Top of the consonantScale range: 0 drops consonants, 4 is four times their spoken length. */\nconst MAX_CONSONANT_SCALE = 4;\n/** Longest note (s), so an open-ended Infinity duration keeps the arithmetic finite. */\nconst LONGEST_NOTE = 86400;\n/** Longest consonant override (s), for the same reason. */\nconst LONGEST_CONSONANT = 10;\n\n/*\n * The two vowel targets of each diphthong, from CHIMERA's planner.rs\n * `expand`. American e\u026A and o\u028A glide toward i and u: CHIMERA found that\n * with \u026A and \u028A as targets they barely moved (e and \u026A share F2, per\n * Hillenbrand et al. 1995) and sounded like the steady e\u02D0 and o\u02D0 of Indian\n * English. The other offglides undershoot toward \u026A and \u028A.\n */\nconst DIPHTHONGS: ReadonlyMap<string, readonly [string, string]> = new Map([\n ['a\u026A', ['a', '\u026A']],\n ['a\u028A', ['a', '\u028A']],\n ['e\u026A', ['e', 'i']],\n ['o\u028A', ['o', 'u']],\n ['\u0254\u026A', ['\u0254', '\u026A']],\n]);\n\n/**\n * The two vowels a diphthong is sung as (\"a\u026A\" to [\"a\", \"\u026A\"]), or undefined for a plain vowel.\n * General American's five use the targets above; any other two-vowel nucleus, which an accent\n * writes (accents.ts: \"\u0259\u028A\", \"\u0250\u0289\"), is sung as its two vowels.\n */\nexport function splitDiphthong(ipa: string): readonly [string, string] | undefined {\n const known = DIPHTHONGS.get(ipa);\n if (known !== undefined || ipa.length !== 2) return known;\n const a = ipa[0];\n const b = ipa[1];\n return isVowel(a) && isVowel(b) ? [a, b] : undefined;\n}\n\n/*\n * Sung when there are no words: CHIMERA's keyboard falls back to this\n * syllable (src/ui/singing.ts, AH), and it is the vocal engine's default\n * phoneme, so a plain note-on and a wordless plan agree.\n */\nconst AH: Syllable = {\n text: 'ah',\n onset: [],\n nucleus: { ipa: '\u0251', stress: 1 },\n coda: [],\n wordEnd: true,\n phraseEnd: false,\n};\n\nexport interface PlanSungOptions {\n /**\n * Scale on each consonant's default duration, 0..4. Default 0.8,\n * CHIMERA's sung k. A segment with its own `dur` is not scaled.\n */\n consonantScale?: number;\n}\n\n/** A note paired with its syllable, its numbers made safe. */\ninterface Placed {\n time: number;\n len: number;\n hz: number;\n vel: number;\n syl: Syllable;\n}\n\n/** A consonant and its duration, which the squeeze may shorten. */\ninterface Timed {\n ipa: string;\n dur: number;\n}\n\n/**\n * Time a sung line: each note's syllable laid out as phoneme spans around\n * the note time, one SungPhrase per breath.\n *\n * Notes are in absolute seconds and Hz, already through the caller's tempo\n * map and tuning. They are sung in time order whatever order they arrive\n * in, and the n-th note in time sings the n-th syllable. A note whose time\n * is not finite, or whose hz is not a finite positive number, cannot be\n * placed or pitched and is skipped. A NaN or negative dur is 0 and a NaN\n * vel is 0, the low end of their ranges.\n *\n * Counts that do not match follow CHIMERA, which pairs a demo song's notes\n * with its lyric as `syl[i % syl.length]` (src/ui/singing.ts and\n * crates/chimera-cli/src/render.rs): with more notes than syllables the\n * lyric starts again from its first syllable, and with more syllables than\n * notes the extra syllables are not sung. With no syllables at all every\n * note sings \"ah\", as CHIMERA's keyboard does when it has no words.\n * Nothing here throws.\n *\n * Every non-melisma note starts a nucleus span exactly at its note time,\n * unless the note leaves its vowel no time at all. Each phrase has one\n * pitch entry per note, in note order, carrying the note's Hz unchanged.\n * Spans in a phrase are contiguous, and a span that would last no time is\n * left out; a phrase with nothing left to sing is left out too.\n */\nexport function planSung(\n notes: readonly SungNote[],\n syllables: readonly Syllable[],\n opts: PlanSungOptions = {},\n): SungPlan {\n const scale = clamp(opts.consonantScale ?? SUNG_CONSONANT_SCALE, 0, MAX_CONSONANT_SCALE);\n const placed = place(notes, syllables);\n const n = placed.length;\n if (n === 0) return { phrases: [], leadIn: 0 };\n\n /* Where each breath ends: at a phraseEnd, at a rest, or at the last note. */\n const phraseEnds = new Array<boolean>(n);\n for (let k = 0; k < n; k++) {\n const p = placed[k];\n phraseEnds[k] = k === n - 1 || p.syl.phraseEnd || placed[k + 1].time - (p.time + p.len) > REST;\n }\n\n /*\n * Each note's consonants. A melisma has no onset, and a note followed by\n * a melisma in its phrase has no coda: the coda of the syllable that\n * began the chain sounds after the chain's last note. The chain stops at\n * the start of the phrase, since a breath ends the vowel it carried.\n */\n const onset: Timed[][] = new Array(n);\n const coda: Timed[][] = new Array(n);\n let first = 0;\n for (let k = 0; k < n; k++) {\n if (k > 0 && phraseEnds[k - 1]) first = k;\n onset[k] = placed[k].syl.melisma === true ? [] : timed(placed[k].syl.onset, scale);\n const held = !phraseEnds[k] && placed[k + 1].syl.melisma === true;\n coda[k] = held ? [] : timed(chainStart(placed, k, first).coda, scale);\n }\n\n /*\n * Squeeze, then find where each note's sound ends. Inside a phrase that\n * is where the next onset starts. At the end of a phrase it is the\n * note's end, pulled back if needed so the next phrase's first sound,\n * and the breath before it after a phraseEnd, come after it.\n */\n const soundEnds = new Array<number>(n);\n for (let k = 0; k < n; k++) {\n const p = placed[k];\n if (!phraseEnds[k]) {\n const next = placed[k + 1].time;\n fit(coda[k].concat(onset[k + 1]), next - p.time);\n soundEnds[k] = Math.max(p.time, next - total(onset[k + 1]));\n } else if (k + 1 < n) {\n const next = placed[k + 1].time;\n const room = next - p.time;\n const len = Math.min(p.len, room);\n const breath = p.syl.phraseEnd ? Math.min(BREATH, BREATH_SHARE * len) : 0;\n fit(coda[k].concat(onset[k + 1]), room - breath);\n fit(coda[k], len);\n soundEnds[k] = Math.max(p.time, Math.min(p.time + len, next - total(onset[k + 1]) - breath));\n } else {\n fit(coda[k], p.len);\n soundEnds[k] = p.time + p.len;\n }\n }\n\n const phrases: SungPhrase[] = [];\n let leadIn = 0;\n for (let i = 0; i < n; ) {\n let j = i;\n while (!phraseEnds[j]) j++;\n const phrase = layPhrase(placed, onset, coda, soundEnds, i, j);\n if (phrase !== undefined) {\n phrases.push(phrase);\n leadIn = Math.max(leadIn, placed[i].time - phrase.start);\n }\n i = j + 1;\n }\n return { phrases, leadIn };\n}\n\n/** Valid notes in time order, each with its syllable. */\nfunction place(notes: readonly SungNote[], syllables: readonly Syllable[]): Placed[] {\n const valid: SungNote[] = [];\n for (const nt of notes) {\n if (Number.isFinite(nt.time) && Number.isFinite(nt.hz) && nt.hz > 0) valid.push(nt);\n }\n /* Array.prototype.sort is stable, so notes at the same time keep their order. */\n valid.sort((a, b) => a.time - b.time);\n const lyric = syllables.length > 0 ? syllables : [AH];\n return valid.map((nt, i) => ({\n time: nt.time,\n len: clamp(nt.dur, 0, LONGEST_NOTE),\n hz: nt.hz,\n vel: clamp(nt.vel ?? DEFAULT_VEL, 0, 1),\n syl: lyric[i % lyric.length],\n }));\n}\n\n/** The syllable that began the melisma chain note k is in, not looking back past `first`. */\nfunction chainStart(placed: readonly Placed[], k: number, first: number): Syllable {\n let b = k;\n while (b > first && placed[b].syl.melisma === true) b--;\n return placed[b].syl;\n}\n\nfunction timed(segs: readonly Segment[], scale: number): Timed[] {\n const out: Timed[] = [];\n for (const s of segs) {\n const d = s.dur;\n const dur =\n typeof d === 'number' && Number.isFinite(d)\n ? clamp(d, 0, LONGEST_CONSONANT)\n : consonantDuration(s.ipa) * scale;\n out.push({ ipa: s.ipa, dur });\n }\n return out;\n}\n\nfunction total(group: readonly Timed[]): number {\n let s = 0;\n for (const c of group) s += c.dur;\n return s;\n}\n\n/*\n * Fit the consonants between a vowel's beat and the next one into `span`.\n * CHIMERA's rule first: if they leave the vowel less than MIN_VOWEL they\n * shrink by one common ratio, each stopping at MIN_CONSONANT. The floors\n * can still leave less than SHORTEST_VOWEL; then everything, that vowel\n * included, shrinks by one more ratio to fit, so the next beat holds. Both\n * steps are continuous in `span`, so a slightly faster run is only slightly\n * tighter.\n */\nfunction fit(group: Timed[], span: number): void {\n const cons = total(group);\n const room = span - MIN_VOWEL;\n if (cons <= room || cons <= 0) return;\n const ratio = Math.max(0, room) / cons;\n let floored = 0;\n for (const c of group) {\n c.dur = Math.max(Math.min(c.dur, MIN_CONSONANT), c.dur * ratio);\n floored += c.dur;\n }\n const need = floored + SHORTEST_VOWEL;\n if (need > span) {\n const share = Math.max(0, span) / need;\n for (const c of group) c.dur *= share;\n }\n}\n\n/** Lay out one phrase, notes i..j, from the squeezed consonants and each note's end. */\nfunction layPhrase(\n placed: readonly Placed[],\n onset: readonly Timed[][],\n coda: readonly Timed[][],\n soundEnds: readonly number[],\n i: number,\n j: number,\n): SungPhrase | undefined {\n const spans: SungSpan[] = [];\n const beat = placed[i].time;\n const start = beat - total(onset[i]);\n const pitches: SungPitch[] = [{ time: start, hz: placed[i].hz }];\n layConsonants(spans, onset[i], start, beat, 'onset');\n for (let k = i; k <= j; k++) {\n const p = placed[k];\n const end = soundEnds[k];\n const vowelEnd = Math.max(p.time, end - total(coda[k]));\n const chainEnds = k === j || placed[k + 1].syl.melisma !== true;\n const continues = k > i && p.syl.melisma === true;\n layNucleus(spans, p.syl.nucleus, p.time, vowelEnd, chainEnds, continues);\n layConsonants(spans, coda[k], vowelEnd, end, 'coda');\n if (k < j) {\n /* the onset moves the pitch at its first consonant; with no onset, on the beat */\n pitches.push({ time: end, hz: placed[k + 1].hz });\n layConsonants(spans, onset[k + 1], end, placed[k + 1].time, 'onset');\n }\n }\n if (spans.length === 0) return undefined;\n return {\n start: spans[0].start,\n end: spans[spans.length - 1].end,\n vel: placed[i].vel,\n spans,\n pitches,\n };\n}\n\n/*\n * Consonants end to end from `from`, the last one ending exactly at `to`,\n * so the next span starts on an exact anchor (a beat, or the start of the\n * next onset) whatever rounding the sums picked up.\n */\nfunction layConsonants(\n spans: SungSpan[],\n group: readonly Timed[],\n from: number,\n to: number,\n kind: 'onset' | 'coda',\n): void {\n let t = from;\n for (let g = 0; g < group.length; g++) {\n const end = g === group.length - 1 ? to : Math.min(to, t + group[g].dur);\n if (end > t) spans.push({ ipa: group[g].ipa, start: t, end, kind });\n t = end;\n }\n}\n\n/*\n * A note's vowel from its beat to `to`. A diphthong glides at the end of\n * the note that ends its chain; earlier notes of a melisma hold its first\n * vowel. A melisma note continues the span before it when that is the same\n * vowel, so a held vowel is one span however many notes it crosses.\n */\nfunction layNucleus(\n spans: SungSpan[],\n nucleus: Segment,\n from: number,\n to: number,\n chainEnds: boolean,\n continues: boolean,\n): void {\n const ipa = nucleus.ipa;\n const parts = splitDiphthong(ipa);\n if (parts !== undefined && chainEnds) {\n const glide = from + (nucleus.hold ?? DIPHTHONG_HOLD) * (to - from);\n layVowel(spans, parts[0], from, glide, continues);\n layVowel(spans, parts[1], glide, to, false);\n } else {\n layVowel(spans, parts === undefined ? ipa : parts[0], from, to, continues);\n }\n}\n\nfunction layVowel(\n spans: SungSpan[],\n ipa: string,\n from: number,\n to: number,\n continues: boolean,\n): void {\n if (!(to > from)) return;\n const prev = spans[spans.length - 1];\n const same = prev !== undefined && prev.kind === 'nucleus' && prev.ipa === ipa;\n if (continues && same && prev.end === from) {\n prev.end = to;\n return;\n }\n spans.push({ ipa, start: from, end: to, kind: 'nucleus' });\n}\n", "/*\n * How long each consonant lasts, in seconds, keyed by IPA, and how much\n * shorter it is when sung.\n *\n * Ported from CHIMERA by Jameson Hodge (MIT),\n * https://github.com/jamesondh/chimera-vocal-synth,\n * crates/chimera/src/phonetics/inventory.rs at 1d3ea49 (TypeScript original\n * at cd247a6^:src/engine/phonetics/inventory.ts). Changes from the original:\n * only each phoneme's default duration (its `dur` field) is kept, as a plain\n * table; the sung scales and the 70 ms fallback come from sing.rs, the\n * alternate spellings from ipa.rs. See THIRD_PARTY_NOTICES.md.\n *\n * Where the numbers come from. CHIMERA times speech with the Klatt (1979)\n * segment duration rules as MITalk sets them out (Allen, Hunnicutt and\n * Klatt 1987, ch. 9): DUR = MIN + (INH - MIN) * PRCNT, an inherent and a\n * minimum duration per phoneme scaled by a product of context factors\n * (crates/chimera/src/phonetics/durations.rs). Singing does not use those\n * rules, because the note decides how long the vowel lasts. CHIMERA's sung\n * planner gives each consonant the default duration its inventory lists\n * for the articulatory model, times a scale k (\"sung consonants are a\n * little shorter than spoken ones\"), and this table is those defaults.\n * They are CHIMERA's own values, not Klatt's: of the 27 consonants both\n * tables list, p, t and k agree with Klatt's inherent durations, 15 are\n * longer here (s 120 ms against 105, t\u0283 150 against 70) and 9 are shorter\n * (\u0279 65 against 80, j 55 against 80).\n */\n\n/** Default duration in seconds of each consonant CHIMERA's inventory knows, by IPA. */\nexport const CONSONANT_DURATIONS: Readonly<Record<string, number>> = Object.freeze({\n /* stops */\n p: 0.085,\n b: 0.07,\n t: 0.075,\n d: 0.06,\n \u0288: 0.075,\n \u0256: 0.065,\n c: 0.08,\n \u025F: 0.07,\n k: 0.08,\n g: 0.07,\n q: 0.085,\n \u0262: 0.075,\n \u0294: 0.06,\n /* nasals */\n m: 0.075,\n \u0271: 0.075,\n n: 0.07,\n \u0273: 0.07,\n \u0272: 0.075,\n \u014B: 0.08,\n \u0274: 0.08,\n /* fricatives */\n \u0278: 0.11,\n \u03B2: 0.09,\n f: 0.11,\n v: 0.08,\n \u03B8: 0.11,\n \u00F0: 0.07,\n s: 0.12,\n z: 0.09,\n \u0283: 0.12,\n \u0292: 0.09,\n \u0282: 0.12,\n \u0290: 0.09,\n \u00E7: 0.12,\n \u029D: 0.09,\n x: 0.12,\n \u0263: 0.09,\n \u03C7: 0.12,\n \u0281: 0.09,\n \u0127: 0.12,\n \u0295: 0.09,\n h: 0.09,\n \u0266: 0.08,\n \u026C: 0.12,\n \u026E: 0.09,\n /* affricates */\n ts: 0.14,\n dz: 0.12,\n t\u0283: 0.15,\n d\u0292: 0.13,\n /* Mandarin: alveolo-palatal fricatives and affricates, retroflex affricates */\n \u0255: 0.12,\n \u0291: 0.09,\n t\u0255: 0.14,\n d\u0291: 0.12,\n t\u0282: 0.14,\n d\u0290: 0.12,\n pf: 0.14,\n /* approximants, laterals, taps, trills */\n w: 0.06,\n \u028B: 0.06,\n \u0279: 0.065,\n \u027B: 0.065,\n j: 0.055,\n \u0265: 0.055,\n \u0270: 0.06,\n l: 0.065,\n \u026B: 0.075,\n \u026D: 0.065,\n \u028E: 0.07,\n \u027E: 0.025,\n \u027D: 0.03,\n r: 0.11,\n \u0280: 0.11,\n \u0299: 0.12,\n});\n\n/** A sound the table does not list: CHIMERA's fallback in sing.rs `cdur`. */\nexport const DEFAULT_CONSONANT_DURATION = 0.07;\n\n/** CHIMERA's k for a planned song (sing.rs `plan_song`). */\nexport const SUNG_CONSONANT_SCALE = 0.8;\n\n/** CHIMERA's k for live playing, a key press at a time (sing.rs `plan_note_on`). */\nexport const LIVE_CONSONANT_SCALE = 0.7;\n\n/* A Map, so a lookup can never land on an Object.prototype member. */\nconst TABLE = new Map<string, number>(Object.entries(CONSONANT_DURATIONS));\n\n/*\n * Other spellings of the same sound: the script g CHIMERA's ipa.rs folds to\n * ASCII g, and the six affricate ligatures U+02A3 to U+02A8.\n */\nconst SPELLINGS = new Map<string, string>([\n ['\u0261', 'g'],\n ['\u02A3', 'dz'],\n ['\u02A4', 'd\u0292'],\n ['\u02A5', 'd\u0291'],\n ['\u02A6', 'ts'],\n ['\u02A7', 't\u0283'],\n ['\u02A8', 't\u0255'],\n]);\n\n/*\n * Spacing modifier letters (aspiration \u02B0, palatalization \u02B2, length \u02D0,\n * stress marks) and combining diacritics (tie bars, the voiceless ring).\n * None of them changes which consonant it is, so a lookup that misses\n * retries on the bare letters.\n */\nconst MARKS = /[\u02B0-\u02FF\u0300-\u036F]/g;\n\nfunction lookup(ipa: string): number | undefined {\n const d = TABLE.get(ipa);\n if (d !== undefined) return d;\n const alias = SPELLINGS.get(ipa);\n return alias === undefined ? undefined : TABLE.get(alias);\n}\n\n/**\n * Default duration in seconds of a consonant, before any sung scale.\n * Unknown sounds get DEFAULT_CONSONANT_DURATION.\n */\nexport function consonantDuration(ipa: string): number {\n return lookup(ipa) ?? lookup(ipa.replace(MARKS, '')) ?? DEFAULT_CONSONANT_DURATION;\n}\n", "/*\n * Text to pronunciation, for reading and checking what the voice will say before it says it. One call\n * runs the same path sing() does (the English reader through a dictionary or letter-to-sound rules,\n * IPA between slashes, lexical sets, the accent, the allophones) and returns it word by word, with an\n * IPA spelling. Read back between slashes it gives the same sounds, though an accent's diphthong\n * (\"\u0259\u028A\") reads back as two vowels, two notes, where the accent sang one.\n */\n\nimport type { LexicalSet } from './lexical-sets';\nimport type { PronouncingDictionary, Syllable } from './types';\nimport type { Accent } from './accents';\nimport { lyricsToSyllables } from './read';\n\nexport interface PronounceOptions {\n dictionary?: PronouncingDictionary;\n /** An accent id ('southern-british', 'australian', ...; see ACCENTS) or an Accent. Default General American. */\n accent?: Accent | string;\n /** The accent's t and l rules, default true. */\n allophones?: boolean;\n}\n\nexport interface PronouncedWord {\n /** The word's spelling as the lyric split it (\"twin-kle\"). */\n text: string;\n /** IPA with stress marks and syllable dots (\"\u02C8tw\u026A\u014B.k\u0259\u026B\"). */\n ipa: string;\n syllables: Syllable[];\n /** Each syllable's vowel's lexical set, undefined for IPA written between slashes. */\n sets: (LexicalSet | undefined)[];\n}\n\nexport interface Pronunciation {\n words: PronouncedWord[];\n /** The whole text in IPA: words split by spaces, phrases by \" | \". */\n ipa: string;\n /** Every syllable, in order, as sing() would take them. */\n syllables: Syllable[];\n}\n\n/**\n * How `text` is pronounced. The same syllables sing() sings, so `pronounce(text).syllables` can be\n * edited and handed to sing() in place of the text.\n */\nexport function pronounce(text: string, opts: PronounceOptions = {}): Pronunciation {\n const syllables = lyricsToSyllables(text, opts);\n const words: PronouncedWord[] = [];\n let current: Syllable[] = [];\n const parts: string[] = [];\n for (const syl of syllables) {\n current.push(syl);\n if (!syl.wordEnd) continue;\n const word = wordOf(current);\n words.push(word);\n parts.push(word.ipa, syl.phraseEnd ? ' | ' : ' ');\n current = [];\n }\n if (current.length > 0) {\n const word = wordOf(current);\n words.push(word);\n parts.push(word.ipa);\n }\n return { words, ipa: parts.join('').replace(/ \\| $/, '').trim(), syllables };\n}\n\n/** `text` in IPA, as pronounce() spells it. */\nexport function toIPA(text: string, opts: PronounceOptions = {}): string {\n return pronounce(text, opts).ipa;\n}\n\nfunction wordOf(syllables: Syllable[]): PronouncedWord {\n const several = syllables.filter((s) => !s.melisma).length > 1;\n const ipa = syllables\n .filter((s) => !s.melisma)\n .map((s) => {\n const mark = several && s.nucleus.stress === 1 ? '\u02C8' : several && s.nucleus.stress === 2 ? '\u02CC' : '';\n const body = [...s.onset, s.nucleus, ...s.coda].map((seg) => seg.ipa).join('');\n return mark + body;\n })\n .join('.');\n return {\n text: syllables.map((s) => s.text).join('-'),\n ipa,\n syllables,\n sets: syllables.map((s) => s.nucleus.set),\n };\n}\n", "/*\n * Speech as notes: the syllables of a spoken phrase timed and pitched the way an accent speaks, so the\n * sung planner (sing.ts) can say them. English is stress-timed: a stressed syllable takes about twice\n * an unstressed one's vowel time, and the last syllable of a phrase lengthens (phrase-final\n * lengthening, Klatt 1976). Pitch follows a simple autosegmental reading of English intonation\n * (Pierrehumbert 1980, in the shape ToBI writes): a baseline that sinks across the phrase\n * (declination), a pitch accent on each stressed syllable, and on the phrase's last stressed syllable\n * the nuclear tone that ends it, a fall to below the baseline or a rise above it.\n *\n * The figures are this module's, chosen to sound like ordinary read speech at a given rate, not\n * fitted to a corpus: vowels of 0.18 s stressed and 0.09 s unstressed (the accent's stress ratio, 2\n * here, moves them toward each other for syllable-timed Englishes), final lengthening of 1.5, and\n * each consonant's spoken duration (durations.ts) added to the note it closes or opens.\n */\n\nimport type { Syllable, SungNote } from './types';\nimport type { Prosody } from './accents';\nimport { DEFAULT_PROSODY } from './accents';\nimport { consonantDuration } from './durations';\n\nconst STRESSED_VOWEL = 0.18;\nconst UNSTRESSED_VOWEL = 0.09;\n/* the two together, which another stress ratio splits differently */\nconst VOWEL_PAIR = STRESSED_VOWEL + UNSTRESSED_VOWEL;\nconst STRESS_RATIO = 2;\nconst FINAL_LENGTHENING = 1.5;\n/** The pause after a phrase, s. */\nconst PHRASE_PAUSE = 0.28;\n\nexport interface SpeechOptions {\n /** The speaker's baseline pitch, Hz. Default 110. */\n hz?: number;\n /** Rate over the accent's own, 1 normal, 2 twice as fast. */\n rate?: number;\n /** The melody; the accent's, or General American's. */\n prosody?: Prosody;\n /** End the last phrase rising, as a yes-no question does. Default: the text ends with \"?\". */\n question?: boolean;\n}\n\n/** A spoken note: a syllable's, or a rest (`hz` 0) for the pause after a phrase. Times from 0, s. */\nexport interface SpokenNote extends SungNote {\n rest?: boolean;\n}\n\n/** Speech ready for the sung planner: the syllables (with a held copy where a tone moves inside one) and a note each. */\nexport interface SpeechPlan {\n syllables: Syllable[];\n /** One per syllable, plus the rests between phrases. */\n notes: SpokenNote[];\n}\n\n/**\n * Time and pitch each syllable as speech. `questions` marks, per phrase, the ones that end rising (a\n * yes-no question), whatever the accent's tune. A nuclear tone on a phrase's last syllable moves\n * within it, so that syllable is sung as two notes, its vowel carried onto the second as a melisma.\n */\nexport function speechPlan(\n syllables: readonly Syllable[],\n opts: SpeechOptions = {},\n questions: readonly boolean[] = [],\n): SpeechPlan {\n const pro = opts.prosody ?? DEFAULT_PROSODY;\n const hz = opts.hz !== undefined && opts.hz > 0 ? opts.hz : 110;\n const rate = Math.max(0.1, (opts.rate ?? 1) * pro.rate);\n const ratio = Math.max(0.5, pro.stressRatio ?? STRESS_RATIO);\n // the default ratio keeps the exact constants, so speech in a stress-timed accent is unchanged\n const unstressedVowel = ratio === STRESS_RATIO ? UNSTRESSED_VOWEL : VOWEL_PAIR / (1 + ratio);\n const stressedVowel = ratio === STRESS_RATIO ? STRESSED_VOWEL : (VOWEL_PAIR * ratio) / (1 + ratio);\n const out: SpokenNote[] = [];\n const sylOut: Syllable[] = [];\n let t = 0;\n let phrase = 0;\n for (let start = 0; start < syllables.length; ) {\n let end = start;\n while (end < syllables.length - 1 && !syllables[end].phraseEnd) end++;\n const span = syllables.slice(start, end + 1);\n const rising = questions[phrase] ?? pro.tune === 'rise';\n const { pitches, endTone } = phrasePitches(span, pro, rising);\n for (let k = 0; k < span.length; k++) {\n const syl = span[k];\n const last = k === span.length - 1;\n const stressed = syl.nucleus.stress !== undefined && syl.nucleus.stress > 0;\n let vowel = syl.nucleus.dur ?? (stressed ? stressedVowel : unstressedVowel);\n if (last) vowel *= FINAL_LENGTHENING;\n let consonants = 0;\n for (const c of syl.coda) consonants += c.dur ?? consonantDuration(c.ipa);\n // the next syllable's opening consonants come out of this note\n if (!last) for (const c of span[k + 1].onset) consonants += c.dur ?? consonantDuration(c.ipa);\n if (last && endTone !== undefined) {\n // the tone moves inside the syllable: its first half at the accent, the rest carried to the end tone\n const first = (0.45 * vowel) / rate;\n const second = (0.55 * vowel + consonants) / rate;\n // the coda stays on the syllable that starts the chain, as a sung melisma's does (read.ts):\n // planSung sounds it after the chain's last note, and reads a melisma's own coda never\n sylOut.push({ ...syl, phraseEnd: false, wordEnd: false });\n sylOut.push({ text: '~', onset: [], nucleus: { ...syl.nucleus }, coda: [], melisma: true, wordEnd: syl.wordEnd, phraseEnd: syl.phraseEnd });\n out.push({ time: t, dur: first, hz: hz * 2 ** (pitches[k] / 12) });\n out.push({ time: t + first, dur: second, hz: hz * 2 ** (endTone / 12) });\n t += first + second;\n continue;\n }\n const dur = (vowel + consonants) / rate;\n sylOut.push(syl);\n out.push({ time: t, dur, hz: hz * 2 ** (pitches[k] / 12) });\n t += dur;\n }\n if (end < syllables.length - 1) {\n // the pause, and room for the next phrase's opening consonants\n let lead = 0;\n for (const c of syllables[end + 1].onset) lead += c.dur ?? consonantDuration(c.ipa);\n const dur = PHRASE_PAUSE / rate + lead;\n out.push({ time: t, dur, hz: 0, rest: true });\n t += dur;\n }\n phrase++;\n start = end + 1;\n }\n return { syllables: sylOut, notes: out };\n}\n\n/**\n * Each syllable's pitch in semitones from the baseline, and, when the nuclear syllable is the last,\n * the tone its vowel moves to.\n */\nfunction phrasePitches(span: readonly Syllable[], pro: Prosody, rising: boolean): { pitches: number[]; endTone?: number } {\n const n = span.length;\n let nuclear = -1;\n for (let k = n - 1; k >= 0; k--) {\n const s = span[k].nucleus.stress;\n if (s !== undefined && s > 0) {\n nuclear = k;\n break;\n }\n }\n if (nuclear < 0) nuclear = n - 1;\n const out: number[] = [];\n for (let k = 0; k < n; k++) {\n const base = n > 1 ? -pro.declination * (k / (n - 1)) : 0;\n const stress = span[k].nucleus.stress ?? 0;\n let st = base;\n if (k < nuclear) {\n // prenuclear accents, the first highest, secondary stress lower\n if (stress === 1) st += pro.range * (k === firstStressed(span) ? 1 : 0.7);\n else if (stress === 2) st += pro.range * 0.35;\n } else if (k === nuclear) {\n st += rising ? -0.25 * pro.range : pro.range;\n } else {\n // the tail falls to below the baseline or climbs, spread across what is left\n const along = (k - nuclear) / (n - 1 - nuclear);\n st += rising ? pro.range * (0.4 + 0.8 * along) : -0.6 * pro.range * along - 0.2 * pro.range;\n }\n out.push(st);\n }\n if (nuclear < n - 1) return { pitches: out };\n // a nuclear tone on the last syllable moves within it\n return { pitches: out, endTone: rising ? -pro.declination + pro.range : -pro.declination - 0.4 * pro.range };\n}\n\nfunction firstStressed(span: readonly Syllable[]): number {\n for (let k = 0; k < span.length; k++) if (span[k].nucleus.stress === 1) return k;\n return -1;\n}\n", "/*\n * Beatbox patterns as text, and their timing: what a beatbox line sings, before any audio.\n *\n * A pattern is written as CHIMERA writes one (Jameson Hodge, MIT,\n * crates/chimera/src/phonetics/beatbox.rs, parse_beat and BEAT_PRESETS): tokens separated by spaces\n * or \"|\" (bar lines, ignored), one sixteenth each; \".\" or \"-\" is a rest; a hum may carry a MIDI note\n * (\"m:43\"); a trailing \">\" accents. The sounds are engines/vocal-beats.ts's. Swing delays every\n * off-beat sixteenth by swing times half a step, as CHIMERA's beat player does.\n *\n * A pattern becomes syllables and notes for the sung planner: each step a syllable whose nucleus is\n * a beat token (\"beat:Pf\", \"beat:B>\") on a note one step long, rests a silent ready posture, so the\n * whole pattern is one breath group, one throat, monophonic as a beatboxer is.\n */\n\nimport { BEAT_PREFIX, VOCAL_BEATS, vocalBeatNumber } from '../engines/vocal-beats';\nimport type { Syllable } from './types';\n\nexport interface BeatStep {\n /** A sound's id from VOCAL_BEATS ('B', 'Pf', 'tss', ...). */\n id: string;\n /** A hum's pitch as a MIDI note number, through the caller's tuning. */\n note?: number;\n accent?: boolean;\n}\n\n/** A pattern: one entry a sixteenth, null for a rest. */\nexport type BeatPattern = (BeatStep | null)[];\n\n/** The longest pattern read: sixteen bars of sixteenths. */\nexport const MAX_BEAT_STEPS = 256;\n\n/** A beat written as text to its steps. An unknown token is a rest, so a typo keeps the time. */\nexport function parseBeat(text: string): BeatPattern {\n const out: BeatPattern = [];\n for (const raw of text.split(/[\\s|]+/)) {\n if (raw === '') continue;\n if (out.length === MAX_BEAT_STEPS) break;\n if (raw === '.' || raw === '-') {\n out.push(null);\n continue;\n }\n let tok = raw;\n let accent = false;\n if (tok.length > 1 && tok.endsWith('>')) {\n accent = true;\n tok = tok.slice(0, -1);\n }\n let note: number | undefined;\n const m = /^(.+?):(\\d+)$/.exec(tok);\n if (m) {\n tok = m[1];\n note = Number(m[2]);\n }\n const n = vocalBeatNumber(tok);\n if (n <= 0) {\n // '.' is beat 0, the rest\n out.push(null);\n continue;\n }\n const step: BeatStep = { id: VOCAL_BEATS[n].id };\n if (note !== undefined) step.note = note;\n if (accent) step.accent = true;\n out.push(step);\n }\n return out;\n}\n\n/** A pattern back to text: four steps a group, groups split by \" | \". */\nexport function formatBeat(steps: BeatPattern): string {\n const toks = steps.map((s) => (s === null ? '.' : `${s.id}${s.note !== undefined ? `:${s.note}` : ''}${s.accent ? '>' : ''}`));\n const groups: string[] = [];\n for (let i = 0; i < toks.length; i += 4) groups.push(toks.slice(i, i + 4).join(' '));\n return groups.join(' | ');\n}\n\nexport interface BeatPreset {\n id: string;\n name: string;\n bpm: number;\n /** 0 to 0.6. */\n swing: number;\n text: string;\n}\n\n/** Ready-made patterns: CHIMERA's seven, then bellows' own. */\nexport const BEAT_PRESETS: readonly BeatPreset[] = [\n { id: 'boots-and-cats', name: 'Boots and cats', bpm: 96, swing: 0, text: 'B . t . | Pf . t . | B . t . | Pf . t .' },\n { id: 'four-on-the-floor', name: 'Four on the floor', bpm: 122, swing: 0, text: 'B . t . | B . tss . | B . t . | B . tss .' },\n { id: 'breakbeat', name: 'Breakbeat', bpm: 94, swing: 0.18, text: 'B . t . | Pf . t B | . B t . | Pf . t t' },\n { id: 'rimshot-shuffle', name: 'Rimshot shuffle', bpm: 88, swing: 0.4, text: 'B . t K | . t B . | t . K t | . B K t' },\n { id: 'inward-snare', name: 'Inward snare', bpm: 100, swing: 0, text: 'B . t . | ^K . t . | B B t . | ^K . t .' },\n { id: 'clicks-and-pops', name: 'Clicks and pops', bpm: 90, swing: 0.25, text: 'B . ! . | P! . ! . | B ! . ! | P! . ! !' },\n { id: 'hum-bass', name: 'Hum bass', bpm: 92, swing: 0.1, text: 'B m . m:43 | Pf . m:45 . | B m:40 . m | Pf . t kch' },\n { id: 'psh-groove', name: 'Psh groove', bpm: 98, swing: 0.12, text: 'B . ch . | Psh . ch B | . B ch . | Psh . ch tss' },\n];\n\nexport interface BeatTiming {\n /** Quarter notes a minute; a step is a sixteenth. Default 96. */\n bpm?: number;\n /** 0 to 0.6, default 0. */\n swing?: number;\n /** Times through the pattern, default 1. */\n repeat?: number;\n}\n\n/** The silent ready posture before a pattern's first step, s: room for its first sound's preparation. */\nexport const BEAT_LEAD_IN = 0.15;\n\n/** A step's length in seconds at `bpm`. */\nexport function beatStepSeconds(bpm: number): number {\n return 60 / Math.max(20, Math.min(400, bpm)) / 4;\n}\n\nexport interface BeatLine {\n /** One syllable a step, the lead-in first. */\n syllables: Syllable[];\n /** Each step's length in seconds, the lead-in first, swing applied. */\n durs: number[];\n /** Each step, the lead-in (null) first: what its note is. */\n steps: BeatPattern;\n}\n\n/** A pattern as a sung line: the lead-in and each step as a syllable with its length. */\nexport function beatLine(pattern: BeatPattern | string, opts: BeatTiming = {}): BeatLine {\n const steps0 = typeof pattern === 'string' ? parseBeat(pattern) : pattern;\n const repeat = Math.max(1, Math.min(64, Math.floor(opts.repeat ?? 1)));\n const step = beatStepSeconds(opts.bpm ?? 96);\n const swing = Math.max(0, Math.min(0.6, opts.swing ?? 0)) * 0.5 * step;\n const steps: BeatPattern = [null];\n const durs: number[] = [BEAT_LEAD_IN];\n for (let r = 0; r < repeat; r++) {\n for (let i = 0; i < steps0.length; i++) {\n steps.push(steps0[i]);\n // an off-beat sixteenth starts `swing` late: the step before it is that much longer\n durs.push(step + (i % 2 === 0 ? swing : -swing));\n }\n }\n const syllables: Syllable[] = steps.map((s) => ({\n text: s === null ? '.' : s.id,\n onset: [],\n nucleus: { ipa: `${BEAT_PREFIX}${s === null ? '.' : s.id}${s?.accent ? '>' : ''}` },\n coda: [],\n wordEnd: true,\n phraseEnd: false,\n }));\n return { syllables, durs, steps };\n}\n", "/*\n * Starter voices: who is singing, as data. A voice is the vocal engine's params plus the two facts a\n * line needs that the engine cannot know: where the speaking voice sits (speak()'s default pitch)\n * and the range it sings in. Each value comes from published norms or from this voice's own\n * measurements (docs/VOICE-NORMS.md), and each preset says which.\n *\n * Speaking pitch. Mean conversational F0 is 115 Hz (SD 21) for men and 199 Hz (SD 28) for women\n * (Leung et al. 2022, the Sydney Voice Lab's reference sheet); typical ranges are 85 to 155 Hz for\n * men, 165 to 255 Hz for women and 208 to 259 Hz for a child of ten (Baken 1987). A child's 240 here\n * is inside Baken's range.\n *\n * Singing ranges are the classical voice types' (bass E2 to E4, baritone A2 to A4, tenor C3 to C5,\n * contralto F3 to F5, mezzo-soprano A3 to A5, soprano C4 to C6), as the standard references give\n * them; a child treble sings about A3 to A5.\n *\n * Vibrato. Classical vibrato runs at 4 to 7 Hz with an extent near a semitone either side\n * (reviewed in PMC9510150); pop singers use little or none. The engine's vibratoDepth is the extent\n * in semitones.\n *\n * Source. Measured on this voice (docs/VOICE-NORMS.md): roughness 0.02 on the pulse folds gives\n * healthy jitter and shimmer for every body; older voices show more shimmer and a less steady pitch\n * (the age studies in that document), which the elder preset raises roughness and drift for. Women's\n * voices are on average breathier than men's (a longer open phase and more aspiration noise, Klatt\n * and Klatt 1990, Hanson 1997), which the female presets carry as a little more breath.\n */\n\n/** Which body a voice is: the size of the tract and folds. */\nexport type VoiceGroup = 'male' | 'female' | 'child';\n\nexport interface VoicePreset {\n id: string;\n name: string;\n group: VoiceGroup;\n /** One line on what it is for. */\n description: string;\n /** The vocal engine's params; anything left out keeps the engine's default. */\n params: Record<string, number>;\n /** speak()'s default baseline pitch, Hz. */\n speechHz: number;\n /** The comfortable singing range, MIDI note numbers, low and high. */\n range: [number, number];\n}\n\n/** The conversational F0 norms by body: men, women, children (see the header). */\nexport const SPEECH_HZ_BY_BODY: readonly [number, number, number] = [115, 199, 240];\n\n/** speak()'s default pitch for a body, 0 male to 1 female to 2 child, interpolated. */\nexport function speechHzForBody(body: number): number {\n const b = Math.max(0, Math.min(2, Number.isFinite(body) ? body : 0));\n const i = Math.min(1, Math.floor(b));\n const t = b - i;\n return SPEECH_HZ_BY_BODY[i] + t * (SPEECH_HZ_BY_BODY[i + 1] - SPEECH_HZ_BY_BODY[i]);\n}\n\nexport const VOICE_PRESETS: readonly VoicePreset[] = [\n {\n id: 'narrator-male',\n name: 'Narrator (male)',\n group: 'male',\n description: 'a steady, clear speaking voice at the male conversational mean',\n params: { body: 0, vibratoDepth: 0, drift: 4, roughness: 0.02, breath: 0.12, tension: 0.5 },\n speechHz: 115,\n range: [43, 64],\n },\n {\n id: 'narrator-female',\n name: 'Narrator (female)',\n group: 'female',\n description: 'a steady, clear speaking voice at the female conversational mean',\n params: { body: 1, vibratoDepth: 0, drift: 4, roughness: 0.02, breath: 0.2, tension: 0.5 },\n speechHz: 199,\n range: [55, 76],\n },\n {\n id: 'child',\n name: 'Child',\n group: 'child',\n description: 'a child of about ten: the smallest tract, a high light voice',\n params: { body: 2, vibratoDepth: 0.1, drift: 6, roughness: 0.02, breath: 0.2, tension: 0.5 },\n speechHz: 240,\n range: [57, 81],\n },\n {\n id: 'bass',\n name: 'Bass',\n group: 'male',\n description: 'the lowest classical voice, E2 to E4, dark and slow to move',\n params: { body: 0, tension: 0.6, breath: 0.1, vibratoRate: 5.2, vibratoDepth: 0.5, glide: 0.2, ring: 0.5 },\n speechHz: 98,\n range: [40, 64],\n },\n {\n id: 'baritone',\n name: 'Baritone',\n group: 'male',\n description: 'the middle male voice, A2 to A4',\n params: { body: 0, tension: 0.58, breath: 0.12, vibratoRate: 5.5, vibratoDepth: 0.45, ring: 0.4 },\n speechHz: 110,\n range: [45, 69],\n },\n {\n id: 'tenor',\n name: 'Tenor',\n group: 'male',\n description: 'the high male voice, C3 to C5: a slightly shorter tract, brighter and pressed',\n params: { body: 0.15, tension: 0.65, breath: 0.1, vibratoRate: 5.8, vibratoDepth: 0.45, ring: 0.6, tuning: 0.4 },\n speechHz: 130,\n range: [48, 72],\n },\n {\n id: 'contralto',\n name: 'Contralto',\n group: 'female',\n description: 'the lowest female voice, F3 to F5, warm and dark',\n params: { body: 0.85, tension: 0.55, breath: 0.15, vibratoRate: 5.4, vibratoDepth: 0.45, ring: 0.4 },\n speechHz: 180,\n range: [53, 77],\n },\n {\n id: 'mezzo',\n name: 'Mezzo-soprano',\n group: 'female',\n description: 'the middle female voice, A3 to A5',\n params: { body: 0.95, tension: 0.58, breath: 0.15, vibratoRate: 5.6, vibratoDepth: 0.5, ring: 0.5, tuning: 0.5 },\n speechHz: 195,\n range: [57, 81],\n },\n {\n id: 'soprano',\n name: 'Soprano',\n group: 'female',\n description: 'the highest classical voice, C4 to C6, with the jaw opening on high notes as trained sopranos do',\n params: { body: 1, tension: 0.62, breath: 0.12, vibratoRate: 5.8, vibratoDepth: 0.55, ring: 0.6, tuning: 1, overshoot: 0.12 },\n speechHz: 215,\n range: [60, 84],\n },\n {\n id: 'pop-female',\n name: 'Pop (female)',\n group: 'female',\n description: 'light, breathy and close, little vibrato and that only on long notes',\n params: { body: 1, tension: 0.45, breath: 0.32, vibratoRate: 6, vibratoDepth: 0.15, vibratoDelay: 0.45, overshoot: 0.06, glide: 0.12 },\n speechHz: 205,\n range: [55, 76],\n },\n {\n id: 'pop-male',\n name: 'Pop (male)',\n group: 'male',\n description: 'a light male pop voice, breathier than the classical ones, little vibrato',\n params: { body: 0.1, tension: 0.5, breath: 0.25, vibratoRate: 6, vibratoDepth: 0.12, vibratoDelay: 0.45, overshoot: 0.06, glide: 0.12 },\n speechHz: 120,\n range: [48, 69],\n },\n {\n id: 'rock',\n name: 'Rock (gravel)',\n group: 'male',\n description: 'pressed and rough, with creak at the bottom of the voice',\n params: { body: 0, tension: 0.8, breath: 0.1, roughness: 0.18, fry: 0.35, vibratoDepth: 0.15, overshoot: 0.1 },\n speechHz: 115,\n range: [45, 69],\n },\n {\n id: 'elder',\n name: 'Elder',\n group: 'male',\n description: 'an older man: more shimmer, a wandering pitch, a slow wide wobble',\n params: { body: 0, tension: 0.4, breath: 0.25, roughness: 0.15, drift: 12, vibratoRate: 4.6, vibratoDepth: 0.5, vibratoDelay: 0.1 },\n speechHz: 125,\n range: [43, 62],\n },\n {\n id: 'beatboxer',\n name: 'Beatboxer',\n group: 'male',\n description: 'a male voice on a close microphone, for beatbox(): the mic hears the air of each kick and snare',\n params: { body: 0, mic: 0.8, level: 0.9 },\n speechHz: 115,\n range: [40, 64],\n },\n];\n\n/** A preset by id; undefined if there is none. */\nexport function voicePreset(id: string): VoicePreset | undefined {\n return VOICE_PRESETS.find((v) => v.id === id);\n}\n"],
|
|
5
|
+
"mappings": ";wDA2CA,IAAMA,GAAc,qJAGdC,GACJ,+QAGIC,GAAQ,CAAC,UAAM,UAAM,UAAM,UAAM,eAAM,UAAM,SAAI,EAGjDC,GAAuC,IAAI,IAAI,CACnD,CAAC,SAAK,GAAG,EACT,CAAC,SAAK,SAAI,EACV,CAAC,SAAK,SAAI,EACV,CAAC,SAAK,QAAG,EACT,CAAC,SAAK,QAAG,EAET,CAAC,SAAK,QAAG,EACT,CAAC,SAAK,QAAG,EACT,CAAC,SAAK,QAAG,EACT,CAAC,SAAK,QAAG,EAET,CAAC,SAAK,IAAI,EACV,CAAC,SAAK,IAAI,EACV,CAAC,SAAK,SAAI,EACV,CAAC,SAAK,SAAI,CACZ,CAAC,EAGKC,GAAa,0DAEbC,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ANT_CHARS", "MULTI", "ALIASES", "IPA_LETTER", "VOWELS", "KNOWN", "PAUSE", "PAUSE_DUR", "LONG_VOWEL_BASE", "LONG_CONSONANT_BASE", "LENGTH_FACTOR", "SYLLABIC_BELOW", "SYLLABIC_ABOVE", "TIE_BARS", "BREAK_NONE", "BREAK_SYLLABLE", "BREAK_WORD", "isVowel", "ipa", "first", "tokenizeIpa", "input", "readIpa", "s", "prepare", "segments", "breaks", "stress", "i", "ch", "markBreak", "last", "base", "tok", "m", "startsAt", "syllabic", "isCombining", "kind", "token", "k", "c", "out", "alias", "parts", "head", "ARPA", "PHONE", "arpabetToSegments", "phones", "out", "ph", "m", "base", "stress", "ipa", "isVowel", "RULES", "PHONES", "r", "letterToSound", "word", "phones", "i", "matched", "before", "letters", "after", "contextMatches", "p", "isVowel", "out", "at", "k", "ipa", "isVowelLetter", "c", "context", "dir", "pos", "ch", "ONSETS", "CLUSTER_SPELLING", "SONORANTS", "FRICATIVES", "sonority", "ipa", "vowelless", "segs", "n", "i", "MAX_ONSET", "syllabifySegments", "vowels", "isVowel", "out", "start", "v", "end", "next", "between", "k", "len", "legalOnset", "from", "to", "PAUSE", "joined", "DIGRAPHS", "splitSpelling", "word", "count", "w", "groups", "isVowelLetter", "s", "hasDiaeresis", "finalE", "silentE", "consonantLe", "last", "cuts", "a", "b", "gap", "digraph", "c", "LEXICAL_SETS", "BATH_WORDS", "BATH_BEFORE_VOWEL", "THOUGHT_SPELLING", "tagLexicalSets", "word", "segs", "w", "vowels", "i", "isVowel", "n", "seg", "next", "after", "rCoda", "stressed", "last", "classify", "v", "c", "HOMOGRAPHS", "FUNCTION_WORDS", "IRREGULAR", "REDUCES", "KEEPS_VOWEL", "COMBINING", "EDGE_APOSTROPHES", "pronounceEnglish", "word", "opts", "clean", "folded", "entry", "lookup", "segs", "arpabetToSegments", "weaken", "out", "part", "letterToSound", "dictionary", "vowels", "s", "isVowel", "englishFrontEnd", "isEnglishLetter", "c", "englishSyllables", "parts", "p", "tagLexicalSets", "syllables", "syllabifySegments", "carried", "vowelless", "spelling", "splitSpelling", "i", "onset", "nucleus", "coda", "d", "base", "SLASH", "ipaFrontEnd", "c", "word", "ipaToSyllables", "stripSlashes", "ipa", "segments", "breaks", "readIpa", "out", "chunks", "i", "seg", "PAUSE", "BREAK_WORD", "closeWord", "BREAK_SYLLABLE", "parts", "byChunks", "syllabifySegments", "carried", "vowelless", "onset", "nucleus", "coda", "shown", "carry", "chunk", "s", "text", "from", "to", "applyAllophones", "syllables", "english", "rules", "t", "l", "run", "flush", "rewrite", "syl", "segs", "seg", "i", "prev", "next", "s", "isVowel", "before", "coda", "CLUSTERS_WITH_T", "between", "DEFAULT_PROSODY", "GENERAL_AMERICAN", "SOUTHERN_BRITISH", "LONDON", "AUSTRALIAN", "NEW_ZEALAND", "IRISH", "SCOTTISH", "SOUTHERN_US", "CANADIAN", "CALIFORNIAN", "NEW_YORK", "NORTHERN_ENGLISH", "GEORDIE", "WELSH", "NORTHERN_IRISH", "SOUTH_AFRICAN", "NIGERIAN", "JAMAICAN", "INDIAN", "SINGAPOREAN", "RECEIVED_PRONUNCIATION", "SCOUSE", "BRUMMIE", "WEST_COUNTRY", "BOSTON", "INLAND_NORTH", "FILIPINO", "GHANAIAN", "KENYAN", "TRINIDADIAN", "RUSSIAN", "ACCENT_REGIONS", "ACCENTS", "a", "resolveAccent", "accent", "found", "LENGTH", "readRealization", "ipa", "chars", "last", "vowels", "c", "isVowel", "R_SOUNDS", "applyAccent", "syllables", "english", "i", "syl", "next", "linked", "after", "beforeVoiceless", "VOICELESS", "voiceVowel", "consonants", "n", "set", "spec", "hadR", "real", "r", "dropCodaR", "hold", "k", "DEVOICE", "wordStart", "parts", "segs", "s", "first", "swap", "v", "SPACE", "WORDLIKE", "isPhrasePunct", "c", "readLyrics", "text", "frontEnds", "s", "out", "i", "fe", "f", "end", "openWordEnd", "delimitedWordEnd", "addWord", "isMelisma", "prev", "lyricsToSyllables", "opts", "english", "englishFrontEnd", "read", "tagged", "w", "syllables", "syl", "ipaFrontEnd", "accent", "resolveAccent", "isEnglish", "applyAccent", "applyAllophones", "j", "mark", "before", "after", "ENTRY", "ALTERNATE", "parseCmudict", "text", "out", "raw", "line", "m", "word", "hash", "phones", "key", "clamp", "CONSONANT_DURATIONS", "DEFAULT_CONSONANT_DURATION", "SUNG_CONSONANT_SCALE", "TABLE", "CONSONANT_DURATIONS", "SPELLINGS", "MARKS", "lookup", "ipa", "d", "alias", "consonantDuration", "DEFAULT_CONSONANT_DURATION", "MIN_VOWEL", "MIN_CONSONANT", "SHORTEST_VOWEL", "BREATH", "BREATH_SHARE", "DIPHTHONG_HOLD", "REST", "DEFAULT_VEL", "MAX_CONSONANT_SCALE", "LONGEST_NOTE", "LONGEST_CONSONANT", "DIPHTHONGS", "splitDiphthong", "ipa", "known", "a", "b", "isVowel", "AH", "planSung", "notes", "syllables", "opts", "scale", "clamp", "SUNG_CONSONANT_SCALE", "placed", "place", "n", "phraseEnds", "k", "p", "onset", "coda", "first", "timed", "held", "chainStart", "soundEnds", "next", "room", "len", "breath", "fit", "total", "phrases", "leadIn", "i", "j", "phrase", "layPhrase", "valid", "nt", "lyric", "segs", "out", "s", "d", "dur", "consonantDuration", "group", "c", "span", "cons", "ratio", "floored", "need", "share", "spans", "beat", "start", "pitches", "layConsonants", "end", "vowelEnd", "chainEnds", "continues", "layNucleus", "from", "to", "kind", "t", "g", "nucleus", "parts", "glide", "layVowel", "prev", "same", "pronounce", "text", "opts", "syllables", "lyricsToSyllables", "words", "current", "parts", "syl", "word", "wordOf", "toIPA", "several", "s", "ipa", "mark", "body", "seg", "STRESSED_VOWEL", "UNSTRESSED_VOWEL", "VOWEL_PAIR", "STRESS_RATIO", "FINAL_LENGTHENING", "PHRASE_PAUSE", "speechPlan", "syllables", "opts", "questions", "pro", "DEFAULT_PROSODY", "hz", "rate", "ratio", "unstressedVowel", "stressedVowel", "out", "sylOut", "t", "phrase", "start", "end", "span", "rising", "pitches", "endTone", "phrasePitches", "k", "syl", "last", "stressed", "vowel", "consonants", "c", "consonantDuration", "first", "second", "dur", "lead", "nuclear", "base", "stress", "st", "firstStressed", "along", "MAX_BEAT_STEPS", "parseBeat", "text", "out", "raw", "tok", "accent", "note", "m", "n", "vocalBeatNumber", "step", "VOCAL_BEATS", "formatBeat", "steps", "toks", "s", "groups", "i", "BEAT_PRESETS", "BEAT_LEAD_IN", "beatStepSeconds", "bpm", "beatLine", "pattern", "opts", "steps0", "repeat", "swing", "durs", "r", "BEAT_PREFIX", "SPEECH_HZ_BY_BODY", "speechHzForBody", "body", "b", "i", "t", "VOICE_PRESETS", "voicePreset", "id", "v"]
|
|
7
|
+
}
|