bellows-voice 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"speech.d.ts","sourceRoot":"","sources":["../../src/lyrics/speech.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUzC,MAAM,WAAW,aAAa;IAC5B,qDAAqD;IACrD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qGAAqG;AACrG,MAAM,WAAW,UAAW,SAAQ,QAAQ;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,yHAAyH;AACzH,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,wDAAwD;IACxD,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,SAAS,QAAQ,EAAE,EAC9B,IAAI,GAAE,aAAkB,EACxB,SAAS,GAAE,SAAS,OAAO,EAAO,GACjC,UAAU,CAoDZ"}
1
+ {"version":3,"file":"speech.d.ts","sourceRoot":"","sources":["../../src/lyrics/speech.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAazC,MAAM,WAAW,aAAa;IAC5B,qDAAqD;IACrD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qGAAqG;AACrG,MAAM,WAAW,UAAW,SAAQ,QAAQ;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,yHAAyH;AACzH,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,wDAAwD;IACxD,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,SAAS,QAAQ,EAAE,EAC9B,IAAI,GAAE,aAAkB,EACxB,SAAS,GAAE,SAAS,OAAO,EAAO,GACjC,UAAU,CAwDZ"}
package/dist/text.d.ts CHANGED
@@ -5,7 +5,7 @@ export { tokenizeIpa } from './lyrics/ipa';
5
5
  export { arpabetToSegments } from './lyrics/arpabet';
6
6
  export { parseCmudict } from './lyrics/cmudict';
7
7
  export { planSung, type PlanSungOptions } from './lyrics/sing';
8
- export { ACCENTS, GENERAL_AMERICAN, SOUTHERN_BRITISH, LONDON, AUSTRALIAN, NEW_ZEALAND, IRISH, SCOTTISH, SOUTHERN_US, DEFAULT_PROSODY, resolveAccent, applyAccent, type Accent, type Prosody, type TRule, type LRule, type ThRule, type RRule, } from './lyrics/accents';
8
+ export { ACCENTS, 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, DEFAULT_PROSODY, resolveAccent, applyAccent, type Accent, type Prosody, type TRule, type LRule, type ThRule, type RRule, } from './lyrics/accents';
9
9
  export { LEXICAL_SETS, tagLexicalSets, type LexicalSet } from './lyrics/lexical-sets';
10
10
  export { pronounce, toIPA, type PronounceOptions, type PronouncedWord, type Pronunciation } from './lyrics/pronounce';
11
11
  export { speechPlan, type SpeechOptions, type SpeechPlan, type SpokenNote } from './lyrics/speech';
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EACL,OAAO,EACP,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,EACN,UAAU,EACV,WAAW,EACX,KAAK,EACL,QAAQ,EACR,WAAW,EACX,eAAe,EACf,aAAa,EACb,WAAW,EACX,KAAK,MAAM,EACX,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,KAAK,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACn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tH,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACnG,YAAY,EACV,OAAO,EACP,QAAQ,EACR,qBAAqB,EACrB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,UAAU,EACV,QAAQ,GACT,MAAM,gBAAgB,CAAC"}
package/dist/text.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /*! bellows-voice | MIT, Copyright (c) 2026 Moheeb Zara | includes code from CHIMERA, https://github.com/jamesondh/chimera-vocal-synth, Copyright (c) 2026 Jameson Hodge, MIT License | notices in THIRD_PARTY_NOTICES.md */
2
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y}from"./chunk-QJYKYLE2.js";export{p as ACCENTS,k as AUSTRALIAN,g as DEFAULT_PROSODY,h as GENERAL_AMERICAN,m as IRISH,c as LEXICAL_SETS,j as LONDON,l as NEW_ZEALAND,n as SCOTTISH,i as SOUTHERN_BRITISH,o as SOUTHERN_US,r as applyAccent,b as arpabetToSegments,e as englishFrontEnd,f as ipaFrontEnd,t as lyricsToSyllables,w as parseCmudict,v as planSung,x as pronounce,s as readLyrics,q as resolveAccent,u as speechPlan,d as tagLexicalSets,y as toIPA,a as tokenizeIpa};
2
+ import{A,B,C,D,E,F,G,H,I,J,K,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-4LLNG2YR.js";export{B as ACCENTS,k as AUSTRALIAN,q as CALIFORNIAN,p as CANADIAN,g as DEFAULT_PROSODY,h as GENERAL_AMERICAN,t as GEORDIE,z as INDIAN,m as IRISH,y as JAMAICAN,c as LEXICAL_SETS,j as LONDON,r as NEW_YORK,l as NEW_ZEALAND,x as NIGERIAN,s as NORTHERN_ENGLISH,v as NORTHERN_IRISH,n as SCOTTISH,A as SINGAPOREAN,i as SOUTHERN_BRITISH,o as SOUTHERN_US,w as SOUTH_AFRICAN,u as WELSH,D as applyAccent,b as arpabetToSegments,e as englishFrontEnd,f as ipaFrontEnd,F as lyricsToSyllables,I as parseCmudict,H as planSung,J as pronounce,E as readLyrics,C as resolveAccent,G as speechPlan,d as tagLexicalSets,K as toIPA,a as tokenizeIpa};
3
3
  //# sourceMappingURL=text.js.map
@@ -0,0 +1,54 @@
1
+ /** The articulators, in the order postures use. */
2
+ export declare const ARTICULATOR_NAMES: readonly ["jaw", "tbX", "tbY", "ttX", "ttY", "ttCurl", "root", "lipAp", "lipProt", "lipWidth", "labiodental", "velum", "larynx", "epilarynx", "ventricular", "lateral", "dorsum"];
3
+ /** A drawable midsagittal view of the tract, centimetres, glottis to lips. */
4
+ export interface TractShape {
5
+ /** The lower wall (the tongue, the floor of the mouth, the lower lip), as x, y pairs. */
6
+ lower: Float32Array;
7
+ /** The upper wall (the back of the pharynx, the palate, the upper lip), as x, y pairs. */
8
+ upper: Float32Array;
9
+ /** Cross-sectional area at each point, cm^2. */
10
+ area: Float32Array;
11
+ /** Opening into the nose, cm^2 (0 for an oral sound, larger for m, n, ŋ). */
12
+ velumPort: number;
13
+ /** Area between the lips, cm^2. */
14
+ lipArea: number;
15
+ /** The tongue tip. */
16
+ tipX: number;
17
+ tipY: number;
18
+ /** Each point's region: 1 the pharynx, 2 the mouth, 3 the lips. */
19
+ region: Uint8Array;
20
+ /** Index of the first mouth point, where the pharynx turns into the mouth below the velum (-1 if none). */
21
+ split: number;
22
+ }
23
+ /**
24
+ * The articulator targets of one phoneme for a body (0 male, 1 female, 2 child), 17 values, NaN
25
+ * where the phoneme sets none. Undefined for a symbol the voice does not have.
26
+ */
27
+ export declare function phonemeTargets(body: number, ipa: string): Float64Array | undefined;
28
+ export declare class TractModel {
29
+ /** The current posture, 17 articulators. */
30
+ readonly posture: Float64Array<ArrayBuffer>;
31
+ private readonly velocity;
32
+ private readonly goal;
33
+ /** The vowel posture a consonant overlays. */
34
+ private readonly vowelGoal;
35
+ private geometry;
36
+ private bodyIndex;
37
+ /** The phoneme the model is moving toward. */
38
+ current: string;
39
+ constructor(body?: number);
40
+ /** Change body (0 male, 1 female, 2 child, rounded). */
41
+ setBody(body: number): void;
42
+ /**
43
+ * Move toward a phoneme: a vowel sets the whole posture, a consonant its own articulators over the
44
+ * vowel's, silence ('_') the rest position. False for a symbol the voice does not have.
45
+ */
46
+ target(ipa: string): boolean;
47
+ /** Advance the articulators by dt seconds, critically damped at their own speeds. */
48
+ step(dt: number): void;
49
+ /** Jump straight to the target. */
50
+ settle(): void;
51
+ /** The tract the current posture makes. */
52
+ shape(): TractShape;
53
+ }
54
+ //# sourceMappingURL=tract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tract.d.ts","sourceRoot":"","sources":["../../src/view/tract.ts"],"names":[],"mappings":"AA4BA,mDAAmD;AACnD,eAAO,MAAM,iBAAiB,mLAA0B,CAAC;AAEzD,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,yFAAyF;IACzF,KAAK,EAAE,YAAY,CAAC;IACpB,0FAA0F;IAC1F,KAAK,EAAE,YAAY,CAAC;IACpB,gDAAgD;IAChD,IAAI,EAAE,YAAY,CAAC;IACnB,6EAA6E;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,MAAM,EAAE,UAAU,CAAC;IACnB,2GAA2G;IAC3G,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAOlF;AAED,qBAAa,UAAU;IACrB,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,4BAAoC;IACpD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0C;IACnE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAoC;IACzD,8CAA8C;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoC;IAC9D,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,SAAS,CAAK;IACtB,8CAA8C;IAC9C,OAAO,SAAO;gBAEF,IAAI,SAAI;IAKpB,wDAAwD;IACxD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAQ3B;;;OAGG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IA0B5B,qFAAqF;IACrF,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAgBtB,mCAAmC;IACnC,MAAM,IAAI,IAAI;IAKd,2CAA2C;IAC3C,KAAK,IAAI,UAAU;CA2BpB"}
package/dist/view.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { TractModel, phonemeTargets, ARTICULATOR_NAMES, type TractShape } from './view/tract';
2
+ //# sourceMappingURL=view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../src/view.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC"}
package/dist/view.js ADDED
@@ -0,0 +1,3 @@
1
+ /*! bellows-voice | MIT, Copyright (c) 2026 Moheeb Zara | includes code from CHIMERA, https://github.com/jamesondh/chimera-vocal-synth, Copyright (c) 2026 Jameson Hodge, MIT License | notices in THIRD_PARTY_NOTICES.md */
2
+ import{a as f,b as A,c,d as v,e as a,f as T,h,i as p,k as u,l as y}from"./chunk-TIHSSFTZ.js";import{b as m,d}from"./chunk-BUKRW4C6.js";var O=.45,_=f;function b(l,e){let r=m(e);if(r<0)return;let n=h[Math.max(0,Math.min(h.length-1,Math.round(l)))];if(T[r]===void 0)return;let s=n.vowelTargets[r];return Float64Array.from(s.some(t=>t===t)?s:n.consonantTargets[r])}var g=class{posture=Float64Array.from(a);velocity=new Float64Array(a.length);goal=Float64Array.from(a);vowelGoal=Float64Array.from(a);geometry;bodyIndex=0;current="_";constructor(e=0){this.bodyIndex=I(e),this.geometry=new y(u[this.bodyIndex])}setBody(e){let r=I(e);r!==this.bodyIndex&&(this.bodyIndex=r,this.geometry=new y(u[r]),this.current!=="_"&&this.target(this.current))}target(e){if(e==="_"||e==="")return this.goal.set(a),this.vowelGoal.set(a),this.current="_",!0;let r=b(this.bodyIndex,e);if(!r)return!1;let n=m(e),s=h[this.bodyIndex].vowelTargets[n].some(t=>t===t);for(let t=0;t<r.length;t++){let i=r[t];s?(this.vowelGoal[t]=i===i?i:a[t],this.goal[t]=this.vowelGoal[t]):this.goal[t]=i===i?i:this.vowelGoal[t]}return this.goal[p.velum]=d[n]?.cls==="nasal"?O:this.vowelGoal[p.velum],this.current=e,!0}step(e){if(!(e>0))return;let r=Math.min(200,Math.ceil(e/.002)),n=e/r;for(let s=0;s<r;s++)for(let t=0;t<this.posture.length;t++){let i=2*Math.PI*v[t],o=i*i*(this.goal[t]-this.posture[t])-2*i*this.velocity[t];this.velocity[t]+=o*n,this.posture[t]+=this.velocity[t]*n,this.posture[t]<A[t]&&(this.posture[t]=A[t]),this.posture[t]>c[t]&&(this.posture[t]=c[t])}}settle(){this.posture.set(this.goal),this.velocity.fill(0)}shape(){let e=this.geometry;e.evaluate(this.posture);let r=e.gN,n=new Float32Array(2*r),s=new Float32Array(2*r),t=new Float32Array(r),i=Uint8Array.from(e.gRegion.subarray(0,r));for(let o=0;o<r;o++)n[2*o]=e.gInX[o],n[2*o+1]=e.gInY[o],s[2*o]=e.gOutX[o],s[2*o+1]=e.gOutY[o],t[o]=e.gArea[o];return{lower:n,upper:s,area:t,velumPort:e.velumPort,lipArea:e.lipArea,tipX:e.tipX,tipY:e.tipY,region:i,split:e.splitIndex}}};function I(l){return Math.max(0,Math.min(u.length-1,Math.round(Number.isFinite(l)?l:0)))}export{_ as ARTICULATOR_NAMES,g as TractModel,b as phonemeTargets};
3
+ //# sourceMappingURL=view.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/view/tract.ts"],
4
+ "sourcesContent": ["/*\n * The vocal tract as a picture: what the voice's mouth is doing, for a UI to draw. It runs the same\n * geometry the engine runs (ChimeraGeometry) on the same per-phoneme articulator targets\n * (vocal-tables.gen.ts), with the velum lowered for a nasal as the planner lowers it, moving each\n * articulator toward its target critically damped at the engine's own speeds (VOCAL_ARTICULATOR_HZ), so a consonant's targets overlay the vowel's posture\n * the way the engine's do: what a consonant does not set stays where the vowel put it.\n *\n * It does not listen to the audio thread; it follows the plan. Given the spans a sung or spoken\n * line returns, call target() with the phoneme at each moment and step() with the time passed.\n * Main-thread code: it allocates on construction and in shape(), never per sample.\n */\n\nimport { ChimeraGeometry, GEOMETRY_BODIES } from '../engines/vocal-geometry';\nimport {\n VOCAL_ARTICULATOR_HZ,\n VOCAL_ARTICULATOR_MAX,\n VOCAL_ARTICULATOR_MIN,\n VOCAL_ARTICULATOR_NAMES,\n VOCAL_BODIES,\n VOCAL_NEUTRAL,\n VOCAL_TABLE_PHONEMES,\n} from '../engines/vocal-tables.gen';\nimport { VOCAL_ACOUSTICS, vocalPhonemeIndex } from '../engines/vocal-phonemes';\nimport { ART } from '../engines/vocal-articulators';\n\n/* The velum's target for a nasal: the gesture the planner keys (vocal-planner.ts, M_NASAL). */\nconst NASAL_VELUM = 0.45;\n\n/** The articulators, in the order postures use. */\nexport const ARTICULATOR_NAMES = VOCAL_ARTICULATOR_NAMES;\n\n/** A drawable midsagittal view of the tract, centimetres, glottis to lips. */\nexport interface TractShape {\n /** The lower wall (the tongue, the floor of the mouth, the lower lip), as x, y pairs. */\n lower: Float32Array;\n /** The upper wall (the back of the pharynx, the palate, the upper lip), as x, y pairs. */\n upper: Float32Array;\n /** Cross-sectional area at each point, cm^2. */\n area: Float32Array;\n /** Opening into the nose, cm^2 (0 for an oral sound, larger for m, n, \u014B). */\n velumPort: number;\n /** Area between the lips, cm^2. */\n lipArea: number;\n /** The tongue tip. */\n tipX: number;\n tipY: number;\n /** Each point's region: 1 the pharynx, 2 the mouth, 3 the lips. */\n region: Uint8Array;\n /** Index of the first mouth point, where the pharynx turns into the mouth below the velum (-1 if none). */\n split: number;\n}\n\n/**\n * The articulator targets of one phoneme for a body (0 male, 1 female, 2 child), 17 values, NaN\n * where the phoneme sets none. Undefined for a symbol the voice does not have.\n */\nexport function phonemeTargets(body: number, ipa: string): Float64Array | undefined {\n const idx = vocalPhonemeIndex(ipa);\n if (idx < 0) return undefined;\n const b = VOCAL_BODIES[Math.max(0, Math.min(VOCAL_BODIES.length - 1, Math.round(body)))];\n if (VOCAL_TABLE_PHONEMES[idx] === undefined) return undefined;\n const vowel = b.vowelTargets[idx];\n return Float64Array.from(vowel.some((v) => v === v) ? vowel : b.consonantTargets[idx]);\n}\n\nexport class TractModel {\n /** The current posture, 17 articulators. */\n readonly posture = Float64Array.from(VOCAL_NEUTRAL);\n private readonly velocity = new Float64Array(VOCAL_NEUTRAL.length);\n private readonly goal = Float64Array.from(VOCAL_NEUTRAL);\n /** The vowel posture a consonant overlays. */\n private readonly vowelGoal = Float64Array.from(VOCAL_NEUTRAL);\n private geometry: ChimeraGeometry;\n private bodyIndex = 0;\n /** The phoneme the model is moving toward. */\n current = '_';\n\n constructor(body = 0) {\n this.bodyIndex = clampBody(body);\n this.geometry = new ChimeraGeometry(GEOMETRY_BODIES[this.bodyIndex]);\n }\n\n /** Change body (0 male, 1 female, 2 child, rounded). */\n setBody(body: number): void {\n const b = clampBody(body);\n if (b === this.bodyIndex) return;\n this.bodyIndex = b;\n this.geometry = new ChimeraGeometry(GEOMETRY_BODIES[b]);\n if (this.current !== '_') this.target(this.current);\n }\n\n /**\n * Move toward a phoneme: a vowel sets the whole posture, a consonant its own articulators over the\n * vowel's, silence ('_') the rest position. False for a symbol the voice does not have.\n */\n target(ipa: string): boolean {\n if (ipa === '_' || ipa === '') {\n this.goal.set(VOCAL_NEUTRAL);\n this.vowelGoal.set(VOCAL_NEUTRAL);\n this.current = '_';\n return true;\n }\n const row = phonemeTargets(this.bodyIndex, ipa);\n if (!row) return false;\n const idx = vocalPhonemeIndex(ipa);\n const isVowel = VOCAL_BODIES[this.bodyIndex].vowelTargets[idx].some((v) => v === v);\n for (let k = 0; k < row.length; k++) {\n const v = row[k];\n if (isVowel) {\n this.vowelGoal[k] = v === v ? v : VOCAL_NEUTRAL[k];\n this.goal[k] = this.vowelGoal[k];\n } else {\n this.goal[k] = v === v ? v : this.vowelGoal[k];\n }\n }\n // the velum is not in the target tables: the planner lowers it for a nasal, as here\n this.goal[ART.velum] = VOCAL_ACOUSTICS[idx]?.cls === 'nasal' ? NASAL_VELUM : this.vowelGoal[ART.velum];\n this.current = ipa;\n return true;\n }\n\n /** Advance the articulators by dt seconds, critically damped at their own speeds. */\n step(dt: number): void {\n if (!(dt > 0)) return;\n const n = Math.min(200, Math.ceil(dt / 0.002));\n const h = dt / n;\n for (let i = 0; i < n; i++) {\n for (let k = 0; k < this.posture.length; k++) {\n const w = 2 * Math.PI * VOCAL_ARTICULATOR_HZ[k];\n const acc = w * w * (this.goal[k] - this.posture[k]) - 2 * w * this.velocity[k];\n this.velocity[k] += acc * h;\n this.posture[k] += this.velocity[k] * h;\n if (this.posture[k] < VOCAL_ARTICULATOR_MIN[k]) this.posture[k] = VOCAL_ARTICULATOR_MIN[k];\n if (this.posture[k] > VOCAL_ARTICULATOR_MAX[k]) this.posture[k] = VOCAL_ARTICULATOR_MAX[k];\n }\n }\n }\n\n /** Jump straight to the target. */\n settle(): void {\n this.posture.set(this.goal);\n this.velocity.fill(0);\n }\n\n /** The tract the current posture makes. */\n shape(): TractShape {\n const g = this.geometry;\n g.evaluate(this.posture);\n const n = g.gN;\n const lower = new Float32Array(2 * n);\n const upper = new Float32Array(2 * n);\n const area = new Float32Array(n);\n const region = Uint8Array.from(g.gRegion.subarray(0, n));\n for (let i = 0; i < n; i++) {\n lower[2 * i] = g.gInX[i];\n lower[2 * i + 1] = g.gInY[i];\n upper[2 * i] = g.gOutX[i];\n upper[2 * i + 1] = g.gOutY[i];\n area[i] = g.gArea[i];\n }\n return {\n lower,\n upper,\n area,\n velumPort: g.velumPort,\n lipArea: g.lipArea,\n tipX: g.tipX,\n tipY: g.tipY,\n region,\n split: g.splitIndex,\n };\n }\n}\n\nfunction clampBody(body: number): number {\n return Math.max(0, Math.min(GEOMETRY_BODIES.length - 1, Math.round(Number.isFinite(body) ? body : 0)));\n}\n"],
5
+ "mappings": ";uIA0BA,IAAMA,EAAc,IAGPC,EAAoBC,EA2B1B,SAASC,EAAeC,EAAcC,EAAuC,CAClF,IAAMC,EAAMC,EAAkBF,CAAG,EACjC,GAAIC,EAAM,EAAG,OACb,IAAME,EAAIC,EAAa,KAAK,IAAI,EAAG,KAAK,IAAIA,EAAa,OAAS,EAAG,KAAK,MAAML,CAAI,CAAC,CAAC,CAAC,EACvF,GAAIM,EAAqBJ,CAAG,IAAM,OAAW,OAC7C,IAAMK,EAAQH,EAAE,aAAaF,CAAG,EAChC,OAAO,aAAa,KAAKK,EAAM,KAAMC,GAAMA,IAAMA,CAAC,EAAID,EAAQH,EAAE,iBAAiBF,CAAG,CAAC,CACvF,CAEO,IAAMO,EAAN,KAAiB,CAEb,QAAU,aAAa,KAAKC,CAAa,EACjC,SAAW,IAAI,aAAaA,EAAc,MAAM,EAChD,KAAO,aAAa,KAAKA,CAAa,EAEtC,UAAY,aAAa,KAAKA,CAAa,EACpD,SACA,UAAY,EAEpB,QAAU,IAEV,YAAYV,EAAO,EAAG,CACpB,KAAK,UAAYW,EAAUX,CAAI,EAC/B,KAAK,SAAW,IAAIY,EAAgBC,EAAgB,KAAK,SAAS,CAAC,CACrE,CAGA,QAAQb,EAAoB,CAC1B,IAAMI,EAAIO,EAAUX,CAAI,EACpBI,IAAM,KAAK,YACf,KAAK,UAAYA,EACjB,KAAK,SAAW,IAAIQ,EAAgBC,EAAgBT,CAAC,CAA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AK,MAAM,OAAO,SAASb,CAAI,EAAIA,EAAO,CAAC,CAAC,CAAC,CACvG",
6
+ "names": ["NASAL_VELUM", "ARTICULATOR_NAMES", "VOCAL_ARTICULATOR_NAMES", "phonemeTargets", "body", "ipa", "idx", "vocalPhonemeIndex", "b", "VOCAL_BODIES", "VOCAL_TABLE_PHONEMES", "vowel", "v", "TractModel", "VOCAL_NEUTRAL", "clampBody", "ChimeraGeometry", "GEOMETRY_BODIES", "row", "isVowel", "k", "ART", "VOCAL_ACOUSTICS", "dt", "n", "h", "i", "w", "VOCAL_ARTICULATOR_HZ", "acc", "VOCAL_ARTICULATOR_MIN", "VOCAL_ARTICULATOR_MAX", "g", "lower", "upper", "area", "region"]
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bellows-voice",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "An articulatory singing and speaking voice for bellowsjs: a physical model of a singer, lyrics and text in eight English accents, and text to IPA.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -23,6 +23,11 @@
23
23
  "import": "./dist/engine.js",
24
24
  "default": "./dist/engine.js"
25
25
  },
26
+ "./view": {
27
+ "types": "./dist/view.d.ts",
28
+ "import": "./dist/view.js",
29
+ "default": "./dist/view.js"
30
+ },
26
31
  "./worklet.js": "./dist/worklet.js"
27
32
  },
28
33
  "files": [
@@ -1,3 +0,0 @@
1
- /*! bellows-voice | MIT, Copyright (c) 2026 Moheeb Zara | includes code from CHIMERA, https://github.com/jamesondh/chimera-vocal-synth, Copyright (c) 2026 Jameson Hodge, MIT License | notices in THIRD_PARTY_NOTICES.md */
2
- var T=["_","\u0251","\xE6","\u028C","\u0254","\u025B","\u025D","\u026A","i","\u028A","u","e","o","a","\u0259","p","b","t","d","k","g","f","v","\u03B8","\xF0","s","z","\u0283","\u0292","h","t\u0283","d\u0292","m","n","\u014B","l","\u0279","w","j","\u027E","\u0294","\u026B","\u0252","\u0250","\u025C","\u0289","\u0268","\u0258","\u0275","y","\xF8","\u0153","\u026F","\u0264"],R={\u025A:"\u025D",\u0261:"g",r:"\u0279",\u02A7:"t\u0283",\u02A4:"d\u0292"},b=new Map(T.map((s,e)=>[s,e]));function J(s){let e=b.get(s);if(e!==void 0)return e;let t=R[s];return t===void 0?-1:b.get(t)??-1}var K=1,n={cls:"vowel",voiced:!0},D={_:{cls:"silence",voiced:!1},\u0251:n,\u00E6:n,\u028C:n,\u0254:n,\u025B:n,\u025D:n,\u026A:n,i:n,\u028A:n,u:n,e:n,o:n,a:n,\u0259:n,p:{cls:"stop",voiced:!1,aspiration:1,vot:.058},b:{cls:"stop",voiced:!0,vot:.001},t:{cls:"stop",voiced:!1,aspiration:1,vot:.07},d:{cls:"stop",voiced:!0,vot:.005},k:{cls:"stop",voiced:!1,aspiration:1,vot:.08},g:{cls:"stop",voiced:!0,vot:.021},f:{cls:"fricative",voiced:!1},v:{cls:"fricative",voiced:!0},\u03B8:{cls:"fricative",voiced:!1},\u00F0:{cls:"fricative",voiced:!0},s:{cls:"fricative",voiced:!1},z:{cls:"fricative",voiced:!0},\u0283:{cls:"fricative",voiced:!1},\u0292:{cls:"fricative",voiced:!0},h:{cls:"glottal",voiced:!1},t\u0283:{cls:"affricate",voiced:!1},d\u0292:{cls:"affricate",voiced:!0},m:{cls:"nasal",voiced:!0},n:{cls:"nasal",voiced:!0},\u014B:{cls:"nasal",voiced:!0},l:{cls:"approximant",voiced:!0},\u0279:{cls:"approximant",voiced:!0},w:{cls:"approximant",voiced:!0},j:{cls:"approximant",voiced:!0},\u027E:{cls:"flap",voiced:!0},\u0294:{cls:"glottal",voiced:!1},\u026B:{cls:"approximant",voiced:!0},\u0252:n,\u0250:n,\u025C:n,\u0289:n,\u0268:n,\u0258:n,\u0275:n,y:n,\u00F8:n,\u0153:n,\u026F:n,\u0264:n},m=T.map(s=>{let e=D[s];return{ipa:s,cls:e.cls,voiced:e.voiced,aspiration:e.aspiration??0,vot:e.vot??0}}),N=.012,C=b.get("s")??-1,_=new Uint8Array(m.length),g=new Uint8Array(m.length);m.forEach((s,e)=>{_[e]=s.cls==="vowel"||s.cls==="silence"?1:s.cls==="approximant"?2:0,g[e]=s.cls==="stop"?1:0});function f(s){return s>=0&&s<m.length&&s===Math.floor(s)}function U(s,e){return f(s)&&g[s]===1&&m[s].aspiration>0&&e!==C}function Q(s,e,t){if(!f(s)||g[s]!==1||!f(t))return 0;let i=_[t];if(i===0)return 0;let r=m[s].vot;return i===1&&U(s,e)||r<N?r:N}import{clamp as l}from"bellowsjs";var y=5.83392170191739,O=.001,x=1e9,A=2*Math.PI*10,u=1e15,G=.001,X=1e9;function L(s){if(!(s>=G&&s<=X))throw new RangeError(`step rate must be within [1e-3, 1e9] Hz, got ${s}`);return 1/s}function V(s){let e=l(s,0,Number.MAX_VALUE);return e>0?y/e:x}var h=1e-30,I=class{h;omega=A;decay;x=0;v=0;goal=0;constructor(e){this.h=L(e),this.decay=Math.exp(-this.omega*this.h)}setOmega(e){if(!Number.isFinite(e))return;let t=l(e,O,x);t<this.omega&&(this.v*=t/this.omega),this.omega=t,this.decay=Math.exp(-t*this.h)}setTime(e){Number.isFinite(e)&&this.setOmega(V(e))}setTarget(e){Number.isFinite(e)&&(this.goal=l(e,-u,u))}snap(e){Number.isFinite(e)&&(this.x=this.goal=l(e,-u,u),this.v=0)}step(){let e=this.omega,t=this.x-this.goal,i=(this.v+e*t)*this.h,r=(t+i)*this.decay,o=(this.v-e*i)*this.decay;return r<h&&r>-h&&o<h&&o>-h?(this.x=this.goal,this.v=0):(this.x=this.goal+r,this.v=o),this.x}get value(){return this.x}get velocity(){return this.v}get target(){return this.goal}},P=class{channels;values;h;v;goal;omega;decay;constructor(e,t){if(!(Number.isInteger(e)&&e>0&&e<=1<<20))throw new RangeError(`channel count must be an integer from 1 to 2^20, got ${e}`);this.channels=e,this.h=L(t),this.values=new Float64Array(e),this.v=new Float64Array(e),this.goal=new Float64Array(e),this.omega=new Float64Array(e).fill(A),this.decay=new Float64Array(e).fill(Math.exp(-A*this.h))}setOmega(e,t){if(!Number.isFinite(t))return;let i=l(t,O,x);i<this.omega[e]&&(this.v[e]*=i/this.omega[e]),this.omega[e]=i,this.decay[e]=Math.exp(-i*this.h)}setTime(e,t){Number.isFinite(t)&&this.setOmega(e,V(t))}setTarget(e,t){Number.isFinite(t)&&(this.goal[e]=l(t,-u,u))}snap(e,t){Number.isFinite(t)&&(this.values[e]=this.goal[e]=l(t,-u,u),this.v[e]=0)}place(e,t,i){!Number.isFinite(t)||!Number.isFinite(i)||(this.values[e]=l(t,-u,u),this.v[e]=l(i,-u,u))}placeFrom(e,t,i){let r=t[i],o=t[i+1];r-r!==0||o-o!==0||(this.values[e]=r<-1e15?-1e15:r>1e15?1e15:r,this.v[e]=o<-1e15?-1e15:o>1e15?1e15:o)}get velocities(){return this.v}value(e){return this.values[e]}velocity(e){return this.v[e]}target(e){return this.goal[e]}setAll(e,t){for(let i=0;i<this.channels;i++){let r=e[i];r===r&&r-r===0&&(this.goal[i]=r<-1e15?-1e15:r>1e15?1e15:r);let o=t[i];if(!(o===o&&o-o===0))continue;let c=o<.001?.001:o>1e9?1e9:o;c!==this.omega[i]&&(c<this.omega[i]&&(this.v[i]*=c/this.omega[i]),this.omega[i]=c,this.decay[i]=Math.exp(-c*this.h))}}step(){let e=this.values,t=this.v,i=this.goal,r=this.omega,o=this.decay,c=this.h;for(let a=0;a<this.channels;a++){let E=r[a],F=e[a]-i[a],w=(t[a]+E*F)*c,p=(F+w)*o[a],d=(t[a]-E*w)*o[a];p<h&&p>-h&&d<h&&d>-h?(e[a]=i[a],t[a]=0):(e[a]=i[a]+p,t[a]=d)}}};import{clamp as S}from"bellowsjs";import{clamp as M}from"bellowsjs";var k=.2,j=1,v=class{h;x=0;v=0;goal=0;w=2*Math.PI*5.5;zeta=.6;prep=0;a=1;b=0;c=0;d=1;constructor(e){if(!(e>=10&&e<=1e7))throw new RangeError(`PitchGlide step rate ${e} Hz is outside [10, 1e7]`);this.h=1/e,this.update()}setSpeed(e){Number.isFinite(e)&&(this.w=2*Math.PI*M(e,.1,200),this.update())}setDamping(e){Number.isFinite(e)&&(this.zeta=M(e,k,1),this.update())}setPreparation(e){Number.isFinite(e)&&(this.prep=M(e,0,j))}setTarget(e){if(!Number.isFinite(e))return;let t=e-this.goal;this.goal=e,t!==0&&this.prep>0&&(this.v-=this.w*this.prep*t)}snap(e){Number.isFinite(e)&&(this.x=this.goal=e,this.v=0)}step(){return this.advance(),this.x}advance(){let e=this.x-this.goal,t=this.v;this.x=this.goal+this.a*e+this.b*t,this.v=this.c*e+this.d*t}get value(){return this.x}get velocity(){return this.v}get target(){return this.goal}leadTime(){let e=0,t=10/this.w;for(let i=0;i<60;i++){let r=.5*(e+t);this.stepResponse(r)<.5?e=r:t=r}return .5*(e+t)}stepResponse(e){let t=this.w,i=this.zeta,r=-1,o=-t*this.prep,c=Math.exp(-i*t*e);if(i>=1-1e-9)return 1+c*(r+(o+t*r)*e);let a=t*Math.sqrt(1-i*i);return 1+c*(r*Math.cos(a*e)+(o+i*t*r)/a*Math.sin(a*e))}update(){let e=this.w,t=this.zeta,i=this.h,r=Math.exp(-t*e*i);if(t>=1-1e-9){this.a=(1+e*i)*r,this.b=i*r,this.c=-e*e*i*r,this.d=(1-e*i)*r;return}let o=e*Math.sqrt(1-t*t),c=Math.cos(o*i),a=Math.sin(o*i);this.a=r*(c+t*e/o*a),this.b=r*a/o,this.c=-r*e*e*a/o,this.d=r*(c-t*e/o*a)}};var re=.3,q={glide:.17,overshoot:.095,preparation:.25};function $(s){let e=s>0?s<.6?s:.6:0;if(!(e>1e-6))return 1;let t=Math.log(e);return-t/Math.sqrt(Math.PI*Math.PI+t*t)}function z(s){let e=S(s,.005,.5);return y/(2*Math.PI*e)}function se(s,e,t){let i=q,r=new v(1e3);return r.setSpeed(z(Number.isFinite(s)?s:i.glide)),r.setDamping($(Number.isFinite(e)?e:i.overshoot)),r.setPreparation(S(Number.isFinite(t)?t:i.preparation,0,1)),r.leadTime()}export{T as a,J as b,K as c,m as d,U as e,Q as f,y as g,O as h,x as i,I as j,P as k,v as l,re as m,q as n,$ as o,z as p,se as q};
3
- //# sourceMappingURL=chunk-HE3CF4RZ.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/engines/vocal-phonemes.ts", "../src/dsp/critdamp.ts", "../src/engines/vocal-lead.ts", "../src/dsp/pitchglide.ts"],
4
- "sourcesContent": ["/*\n * The phonemes the vocal engine can render, and the index each one answers\n * to on the engine's `phoneme` parameter.\n *\n * Parameters are numbers, so a phoneme crosses into the kernel as its index\n * in VOCAL_PHONEMES, carried by an ordinary Param event. That keeps a sung\n * phrase on the same sample-accurate event path as every other automation,\n * in realtime and offline alike.\n *\n * APPEND ONLY. A saved patch or a recorded event stream stores the index,\n * so reordering this list changes what old material sings.\n *\n * What each sound is made of (its articulators, targets and gestures)\n * lives in engines/vocal-tables.gen.ts and engines/vocal-planner.ts. This\n * file keeps what a caller needs without the engine: the list, the class\n * of each sound, and the stop release rules src/sing.ts times sung\n * releases by. The classes, the voicing and the release rules follow\n * CHIMERA by Jameson Hodge (crates/chimera/src/phonetics/inventory.rs and\n * phonetics/planner.rs, at 1d3ea49). Reimplemented here. See\n * THIRD_PARTY_NOTICES.md.\n */\n\nexport const VOCAL_PHONEMES = [\n /* 0: silence inside a phrase, voicing and noise off */\n '_',\n /* 1 to 14: vowels. Diphthongs are sung as two of these. */\n '\u0251', '\u00E6', '\u028C', '\u0254', '\u025B', '\u025D', '\u026A', 'i', '\u028A', 'u', 'e', 'o', 'a', '\u0259',\n /* 15 to 20: stops */\n 'p', 'b', 't', 'd', 'k', 'g',\n /* 21 to 29: fricatives */\n 'f', 'v', '\u03B8', '\u00F0', 's', 'z', '\u0283', '\u0292', 'h',\n /* 30 to 31: affricates */\n 't\u0283', 'd\u0292',\n /* 32 to 34: nasals */\n 'm', 'n', '\u014B',\n /* 35 to 38: approximants */\n 'l', '\u0279', 'w', 'j',\n /* 39 to 40: flap and glottal stop */\n '\u027E', '\u0294',\n /* 41: the velarized (dark) lateral of a syllable coda, \"tell\", \"milk\" */\n '\u026B',\n /*\n * 42 to 53: vowels other accents need and General American lacks, bellows' own, solved from formant\n * targets (scripts/gen-extra-vowels.mjs): British LOT and NURSE, Australian STRUT and GOOSE, the\n * central and rounded front and unrounded back qualities.\n */\n '\u0252', '\u0250', '\u025C', '\u0289', '\u0268', '\u0258', '\u0275', 'y', '\u00F8', '\u0153', '\u026F', '\u0264',\n] as const;\n\nexport type VocalPhoneme = (typeof VOCAL_PHONEMES)[number];\n\n/** Spellings that mean a phoneme above. */\nconst ALIASES: Readonly<Record<string, VocalPhoneme>> = {\n \u025A: '\u025D',\n \u0261: 'g',\n r: '\u0279',\n \u02A7: 't\u0283',\n \u02A4: 'd\u0292',\n};\n\nconst INDEX = new Map<string, number>(VOCAL_PHONEMES.map((s, i) => [s, i]));\n\n/** Index of an IPA symbol on the `phoneme` parameter, through the aliases; -1 if the engine has no such sound. */\nexport function vocalPhonemeIndex(ipa: string): number {\n const direct = INDEX.get(ipa);\n if (direct !== undefined) return direct;\n const alias = ALIASES[ipa];\n return alias === undefined ? -1 : (INDEX.get(alias) ?? -1);\n}\n\n/** The default phoneme, an open /\u0251/, so a plain note-on sings \"ah\". */\nexport const VOCAL_DEFAULT_PHONEME = 1;\n\n/* ------------------------------------------------------------------ */\n/* Classes and release times */\n/* ------------------------------------------------------------------ */\n\nexport type VocalClass =\n | 'silence'\n | 'vowel'\n | 'stop'\n | 'fricative'\n | 'affricate'\n | 'nasal'\n | 'approximant'\n | 'flap'\n | 'glottal';\n\n/** One phoneme's class, voicing and release time. */\nexport interface VocalAcoustics {\n readonly ipa: VocalPhoneme;\n readonly cls: VocalClass;\n readonly voiced: boolean;\n /** 1 for a stop English aspirates (p t k), 0 otherwise. */\n readonly aspiration: number;\n /** Seconds from a stop's release to voicing (Lisker and Abramson 1964, word-initial English means); 0 for the rest. */\n readonly vot: number;\n}\n\ntype Row = { cls: VocalClass; voiced: boolean; aspiration?: number; vot?: number };\nconst V: Row = { cls: 'vowel', voiced: true };\n\n/*\n * VOT: 58, 70 and 80 ms for /p t k/, which are aspirated, and 1, 5 and 21\n * ms for /b d g/, the means usually quoted from Lisker and Abramson\n * (1964), A cross-language study of voicing in initial stops, Word 20,\n * 384-422 (CHIMERA's planner uses 50 ms for all three, planner.rs:492).\n * The classes and voicing agree with CHIMERA's inventory; /h/ is\n * 'glottal' there and here.\n */\nconst SOUNDS: Readonly<Record<VocalPhoneme, Row>> = {\n _: { cls: 'silence', voiced: false },\n \u0251: V, \u00E6: V, \u028C: V, \u0254: V, \u025B: V, \u025D: V, \u026A: V, i: V, \u028A: V, u: V, e: V, o: V, a: V, \u0259: V,\n p: { cls: 'stop', voiced: false, aspiration: 1, vot: 0.058 },\n b: { cls: 'stop', voiced: true, vot: 0.001 },\n t: { cls: 'stop', voiced: false, aspiration: 1, vot: 0.07 },\n d: { cls: 'stop', voiced: true, vot: 0.005 },\n k: { cls: 'stop', voiced: false, aspiration: 1, vot: 0.08 },\n g: { cls: 'stop', voiced: true, vot: 0.021 },\n f: { cls: 'fricative', voiced: false },\n v: { cls: 'fricative', voiced: true },\n \u03B8: { cls: 'fricative', voiced: false },\n \u00F0: { cls: 'fricative', voiced: true },\n s: { cls: 'fricative', voiced: false },\n z: { cls: 'fricative', voiced: true },\n \u0283: { cls: 'fricative', voiced: false },\n \u0292: { cls: 'fricative', voiced: true },\n h: { cls: 'glottal', voiced: false },\n t\u0283: { cls: 'affricate', voiced: false },\n d\u0292: { cls: 'affricate', voiced: true },\n m: { cls: 'nasal', voiced: true },\n n: { cls: 'nasal', voiced: true },\n \u014B: { cls: 'nasal', voiced: true },\n l: { cls: 'approximant', voiced: true },\n \u0279: { cls: 'approximant', voiced: true },\n w: { cls: 'approximant', voiced: true },\n j: { cls: 'approximant', voiced: true },\n \u027E: { cls: 'flap', voiced: true },\n \u0294: { cls: 'glottal', voiced: false },\n \u026B: { cls: 'approximant', voiced: true },\n \u0252: V, \u0250: V, \u025C: V, \u0289: V, \u0268: V, \u0258: V, \u0275: V, y: V, \u00F8: V, \u0153: V, \u026F: V, \u0264: V,\n};\n\n/** One row per entry of VOCAL_PHONEMES, in the same order. */\nexport const VOCAL_ACOUSTICS: readonly VocalAcoustics[] = VOCAL_PHONEMES.map((ipa): VocalAcoustics => {\n const s = SOUNDS[ipa];\n return { ipa, cls: s.cls, voiced: s.voiced, aspiration: s.aspiration ?? 0, vot: s.vot ?? 0 };\n});\n\n/**\n * Release to voicing of a stop that is not aspirated, in seconds: CHIMERA's\n * 12 ms for an unaspirated stop (crates/chimera/src/phonetics/planner.rs:340-349).\n */\nexport const VOCAL_UNASPIRATED_VOT = 0.012;\n\nconst S_INDEX = INDEX.get('s') ?? -1;\n/* What a stop's release is held for, by the sound it opens into: 0 nothing, 1 a vowel or silence, 2 an approximant. */\nconst RELEASE_INTO = new Uint8Array(VOCAL_ACOUSTICS.length);\nconst IS_STOP = new Uint8Array(VOCAL_ACOUSTICS.length);\nVOCAL_ACOUSTICS.forEach((row, i) => {\n RELEASE_INTO[i] = row.cls === 'vowel' || row.cls === 'silence' ? 1 : row.cls === 'approximant' ? 2 : 0;\n IS_STOP[i] = row.cls === 'stop' ? 1 : 0;\n});\n\nfunction inTable(i: number): boolean {\n return i >= 0 && i < VOCAL_ACOUSTICS.length && i === Math.floor(i);\n}\n\n/**\n * Whether the vocal engine aspirates the release of the stop at index\n * `stop`, `prev` being the sound before it (-1 at the start of a note): a\n * voiceless stop, except after /s/, where English does not aspirate (/sp\n * st sk/, CHIMERA's rule, planner.rs:340). One rule for the engine and for\n * src/sing.ts, which times sung releases by it.\n */\nexport function vocalReleaseAspirated(stop: number, prev: number): boolean {\n return inTable(stop) && IS_STOP[stop] === 1 && VOCAL_ACOUSTICS[stop].aspiration > 0 && prev !== S_INDEX;\n}\n\n/**\n * Seconds the vocal engine holds voicing at the stop's own level after\n * releasing the stop at index `stop` into the sound at `next`: the stop's\n * VOT before a vowel or silence when the release is aspirated, else\n * VOCAL_UNASPIRATED_VOT (or the stop's VOT if shorter); before an\n * approximant the short one either way, because a long aspiration would\n * devoice the whole glide of /tw/ or /kl/, which English devoices only at\n * its start. CHIMERA aspirates only before a vowel (planner.rs:341). 0\n * before any other consonant, where the release opens into that sound.\n */\nexport function vocalReleaseVot(stop: number, prev: number, next: number): number {\n if (!inTable(stop) || IS_STOP[stop] !== 1 || !inTable(next)) return 0;\n const into = RELEASE_INTO[next];\n if (into === 0) return 0;\n const vot = VOCAL_ACOUSTICS[stop].vot;\n if (into === 1 && vocalReleaseAspirated(stop, prev)) return vot;\n return vot < VOCAL_UNASPIRATED_VOT ? vot : VOCAL_UNASPIRATED_VOT;\n}\n", "/*\n * Critically damped second-order tracking: a value that glides to a target\n * the way an articulator does, starting slowly, arriving without overshoot,\n * and staying smooth in velocity when the target moves mid-glide.\n *\n * The technique follows CHIMERA by Jameson Hodge\n * (crates/chimera/src/control/articulators.rs:24-147, at 1d3ea49).\n * Reimplemented here. CHIMERA moves each articulator by\n *\n * x'' = w^2 (target - x) - 2 w x'\n *\n * with w = 2 pi times a natural frequency of 6 to 13 Hz per articulator,\n * set, its comment says, against VocalTractLab's fitted time constants of\n * 5 to 40 ms, so that step targets turn into physiologically plausible\n * motion. It steps the equation with semi-implicit Euler, which its own\n * comment notes is stable only for w dt < 1.\n *\n * This file integrates the same equation exactly instead. With the target\n * held over a step of length h, the error e = x - target obeys\n * e'' + 2w e' + w^2 e = 0, whose critically damped solution is\n *\n * e(t) = (e0 + (v0 + w e0) t) exp(-w t)\n * v(t) = (v0 - w (v0 + w e0) t) exp(-w t)\n *\n * so one step is a few multiply-adds and a precomputed exp(-w h). The result\n * is the continuous solution sampled at the step times, whatever the step\n * rate: stable for any w h, with no overshoot from rest, and the same\n * trajectory at control rate as at audio rate (the tests measure both).\n * Changing the target keeps x and x' continuous, so a new phoneme bends a\n * formant glide rather than kinking it.\n *\n * The time constant: from rest, the fraction of a step still to go after t\n * is (1 + w t) exp(-w t). It reaches 2 percent at w t = 5.8339, so setTime(s)\n * sets w = 5.8339 / s and the value is 98 percent of the way there s seconds\n * later. CHIMERA's 10 Hz articulators take 93 ms.\n *\n * Setters ignore non-finite arguments and keep the last good setting, the\n * policy of dsp/filters.ts and dsp/envelopes.ts: a NaN in x or x' would\n * never leave. Finite values go through clamp() from ../types. The only\n * state is number fields (CritDamp) or Float64Arrays sized at construction\n * (CritDampBank), so step() allocates nothing.\n */\n\nimport { clamp } from 'bellowsjs';\n\n/** The root of (1 + u) exp(-u) = 0.02: w times the 98 percent settling time. */\nexport const CRITDAMP_SETTLE_98 = 5.83392170191739;\n/** Slowest w in rad/s (98 percent in about 97 minutes). Zero would let a moving value drift forever. */\nexport const CRITDAMP_MIN_OMEGA = 1e-3;\n/** Fastest w in rad/s. Far past any step rate, so it reads as \"arrive on the next step\". */\nexport const CRITDAMP_MAX_OMEGA = 1e9;\n/** CHIMERA's most common articulator speed, 10 Hz natural frequency, as w. */\nconst DEFAULT_OMEGA = 2 * Math.PI * 10;\n/*\n * Bounds that keep every intermediate of step() finite at every legal\n * setting: with |value| <= 1e15, w <= 1e9 and h <= 1e3, w e h stays below\n * 1e28. Nothing a voice tracks (Hz, levels, semitones) comes near them.\n */\nconst VALUE_LIMIT = 1e15;\nconst MIN_STEP_RATE = 1e-3;\nconst MAX_STEP_RATE = 1e9;\n\nfunction checkRate(stepRateHz: number): number {\n if (!(stepRateHz >= MIN_STEP_RATE && stepRateHz <= MAX_STEP_RATE)) {\n throw new RangeError(`step rate must be within [1e-3, 1e9] Hz, got ${stepRateHz}`);\n }\n return 1 / stepRateHz;\n}\n\nfunction omegaForTime(seconds: number): number {\n const t = clamp(seconds, 0, Number.MAX_VALUE);\n return t > 0 ? CRITDAMP_SETTLE_98 / t : CRITDAMP_MAX_OMEGA;\n}\n\n/** An error and a velocity both under this settle on the target exactly. */\nconst SETTLED = 1e-30;\n\nexport class CritDamp {\n /** Step length in seconds. */\n private readonly h: number;\n private omega = DEFAULT_OMEGA;\n private decay: number;\n private x = 0;\n private v = 0;\n private goal = 0;\n\n /**\n * stepRateHz is how many times per second step() will be called: a\n * sample rate, or a control rate. It throws outside [1e-3, 1e9] Hz,\n * because a step length that is not a finite positive number would turn\n * every value NaN.\n */\n constructor(stepRateHz: number) {\n this.h = checkRate(stepRateHz);\n this.decay = Math.exp(-this.omega * this.h);\n }\n\n /**\n * Natural angular frequency w in rad/s, clamped to [1e-3, 1e9]. Slowing\n * down scales the velocity by the same factor: kept whole, the speed built\n * at the faster rate carries the value past its target (a 40 ms glide\n * stretched to 300 ms mid-move went 6 semitones past it), and a move that\n * was not overshooting would start to.\n */\n setOmega(radPerSec: number): void {\n if (!Number.isFinite(radPerSec)) return;\n const w = clamp(radPerSec, CRITDAMP_MIN_OMEGA, CRITDAMP_MAX_OMEGA);\n if (w < this.omega) this.v *= w / this.omega;\n this.omega = w;\n this.decay = Math.exp(-w * this.h);\n }\n\n /** Seconds for a step from rest to cover 98 percent of the way. 0 means the next step arrives. */\n setTime(seconds: number): void {\n if (!Number.isFinite(seconds)) return;\n this.setOmega(omegaForTime(seconds));\n }\n\n /** Where the value heads next, clamped to +-1e15. */\n setTarget(target: number): void {\n if (!Number.isFinite(target)) return;\n this.goal = clamp(target, -VALUE_LIMIT, VALUE_LIMIT);\n }\n\n /** Jump to value and rest there: target and value both become value, velocity 0. */\n snap(value: number): void {\n if (!Number.isFinite(value)) return;\n this.x = this.goal = clamp(value, -VALUE_LIMIT, VALUE_LIMIT);\n this.v = 0;\n }\n\n /** Advance one step and return the new value. */\n step(): number {\n const w = this.omega;\n const e = this.x - this.goal;\n const ch = (this.v + w * e) * this.h;\n const ne = (e + ch) * this.decay;\n const nv = (this.v - w * ch) * this.decay;\n // settle exactly once the motion is far under anything audible, so no\n // subnormal stays in the state (x86 without flush-to-zero pays for those)\n if (ne < SETTLED && ne > -SETTLED && nv < SETTLED && nv > -SETTLED) {\n this.x = this.goal;\n this.v = 0;\n } else {\n this.x = this.goal + ne;\n this.v = nv;\n }\n return this.x;\n }\n\n get value(): number {\n return this.x;\n }\n\n /** Units per second. */\n get velocity(): number {\n return this.v;\n }\n\n get target(): number {\n return this.goal;\n }\n}\n\n/**\n * N independent CritDamp channels in Float64Arrays with one step() over all\n * of them, for an engine that tracks a dozen or more values (formant\n * frequencies and bandwidths, source levels) at the same rate. Each channel\n * steps exactly as a CritDamp with the same settings would, bit for bit.\n * step() returns nothing, so no double crosses a call boundary for V8 to\n * box when the call is not inlined; read the results from `values`.\n */\nexport class CritDampBank {\n readonly channels: number;\n /**\n * Current values, one per channel. Exposed so a caller can read many\n * channels without a call each. Treat as read only: writing a value here\n * moves it without touching its velocity; use snap() instead.\n */\n readonly values: Float64Array;\n private readonly h: number;\n private readonly v: Float64Array;\n private readonly goal: Float64Array;\n private readonly omega: Float64Array;\n private readonly decay: Float64Array;\n\n constructor(channels: number, stepRateHz: number) {\n if (!(Number.isInteger(channels) && channels > 0 && channels <= 1 << 20)) {\n throw new RangeError(`channel count must be an integer from 1 to 2^20, got ${channels}`);\n }\n this.channels = channels;\n this.h = checkRate(stepRateHz);\n this.values = new Float64Array(channels);\n this.v = new Float64Array(channels);\n this.goal = new Float64Array(channels);\n this.omega = new Float64Array(channels).fill(DEFAULT_OMEGA);\n this.decay = new Float64Array(channels).fill(Math.exp(-DEFAULT_OMEGA * this.h));\n }\n\n /** As CritDamp.setOmega, for channel i. */\n setOmega(i: number, radPerSec: number): void {\n if (!Number.isFinite(radPerSec)) return;\n const w = clamp(radPerSec, CRITDAMP_MIN_OMEGA, CRITDAMP_MAX_OMEGA);\n if (w < this.omega[i]) this.v[i] *= w / this.omega[i];\n this.omega[i] = w;\n this.decay[i] = Math.exp(-w * this.h);\n }\n\n /** As CritDamp.setTime, for channel i. */\n setTime(i: number, seconds: number): void {\n if (!Number.isFinite(seconds)) return;\n this.setOmega(i, omegaForTime(seconds));\n }\n\n /** As CritDamp.setTarget, for channel i. */\n setTarget(i: number, target: number): void {\n if (!Number.isFinite(target)) return;\n this.goal[i] = clamp(target, -VALUE_LIMIT, VALUE_LIMIT);\n }\n\n /** As CritDamp.snap, for channel i. */\n snap(i: number, value: number): void {\n if (!Number.isFinite(value)) return;\n this.values[i] = this.goal[i] = clamp(value, -VALUE_LIMIT, VALUE_LIMIT);\n this.v[i] = 0;\n }\n\n /**\n * Move channel i to `value` with velocity `velocity`, keeping its target:\n * for a constraint that pushes a value back (a tongue against the\n * palate) and removes only the part of its motion that went into it.\n */\n place(i: number, value: number, velocity: number): void {\n if (!Number.isFinite(value) || !Number.isFinite(velocity)) return;\n this.values[i] = clamp(value, -VALUE_LIMIT, VALUE_LIMIT);\n this.v[i] = clamp(velocity, -VALUE_LIMIT, VALUE_LIMIT);\n }\n\n /**\n * Channel i moved as place() would, to src[at] with velocity src[at + 1]:\n * no double crosses the call (V8 boxes doubles passed to a call it does\n * not inline).\n */\n placeFrom(i: number, src: Float64Array, at: number): void {\n const value = src[at];\n const velocity = src[at + 1];\n if (!(value - value === 0) || !(velocity - velocity === 0)) return;\n this.values[i] = value < -1e15 ? -1e15 : value > 1e15 ? 1e15 : value;\n this.v[i] = velocity < -1e15 ? -1e15 : velocity > 1e15 ? 1e15 : velocity;\n }\n\n /** Current velocities, one per channel (read only, like values). */\n get velocities(): Float64Array {\n return this.v;\n }\n\n value(i: number): number {\n return this.values[i];\n }\n\n velocity(i: number): number {\n return this.v[i];\n }\n\n target(i: number): number {\n return this.goal[i];\n }\n\n /**\n * Every channel's target from targets[i] and natural frequency from\n * omegas[i] (rad/s), as setTarget and setOmega would set them one by one;\n * one call with arrays passes no doubles for V8 to box.\n */\n setAll(targets: Float64Array, omegas: Float64Array): void {\n for (let i = 0; i < this.channels; i++) {\n const t = targets[i];\n // the limits are literals here: a module constant merged with a double in a conditional made V8\n // box the double (MEASURED: 7 bytes a sample of the vocal engine's control path)\n if (t === t && t - t === 0) this.goal[i] = t < -1e15 ? -1e15 : t > 1e15 ? 1e15 : t;\n const r = omegas[i];\n if (!(r === r && r - r === 0)) continue;\n const w = r < 1e-3 ? 1e-3 : r > 1e9 ? 1e9 : r;\n if (w !== this.omega[i]) {\n if (w < this.omega[i]) this.v[i] *= w / this.omega[i];\n this.omega[i] = w;\n this.decay[i] = Math.exp(-w * this.h);\n }\n }\n }\n\n /** Advance every channel one step. */\n step(): void {\n const x = this.values;\n const v = this.v;\n const goal = this.goal;\n const omega = this.omega;\n const decay = this.decay;\n const h = this.h;\n for (let i = 0; i < this.channels; i++) {\n const w = omega[i];\n const e = x[i] - goal[i];\n const ch = (v[i] + w * e) * h;\n const ne = (e + ch) * decay[i];\n const nv = (v[i] - w * ch) * decay[i];\n if (ne < SETTLED && ne > -SETTLED && nv < SETTLED && nv > -SETTLED) {\n x[i] = goal[i];\n v[i] = 0;\n } else {\n x[i] = goal[i] + ne;\n v[i] = nv;\n }\n }\n }\n}\n", "/*\n * The vocal engine's timing, apart from its DSP: how far ahead sing() posts each sound and each\n * bend. The facade needs these on the main thread to plan a sung line, and importing them from\n * engines/vocal.ts pulled the whole voice (airway, geometry, planner, tables) into every page that\n * sings, beside the copy the AudioWorklet already carries. Only the glide filter comes along here.\n */\n\nimport { clamp } from 'bellowsjs';\nimport { CRITDAMP_SETTLE_98 } from '../dsp/critdamp';\nimport { PitchGlide } from '../dsp/pitchglide';\n\n/** How far ahead src/sing.ts posts each sound as `nextPhoneme`, seconds. */\nexport const VOCAL_PLAN_LEAD = 0.3;\n\n/** The glide, overshoot and preparation defaults of the vocal engine's params. */\nexport const VOCAL_GLIDE_DEFAULTS = { glide: 0.17, overshoot: 0.095, preparation: 0.25 } as const;\n\n/** Damping for an overshoot fraction of a step without preparation: the inverse of exp(-pi zeta / sqrt(1 - zeta^2)). */\nexport function vocalDamping(overshoot: number): number {\n const os = overshoot > 0 ? (overshoot < 0.6 ? overshoot : 0.6) : 0;\n if (!(os > 1e-6)) return 1;\n const l = Math.log(os);\n return -l / Math.sqrt(Math.PI * Math.PI + l * l);\n}\n\n/** The glide's natural frequency for a `glide` time, Hz. */\nexport function vocalGlideSpeed(glide: number): number {\n const g = clamp(glide, 0.005, 0.5);\n return CRITDAMP_SETTLE_98 / (2 * Math.PI * g);\n}\n\n/**\n * Seconds a pitch change takes to be half way, for a channel's glide,\n * overshoot and preparation (the engine's defaults where undefined): post a\n * bend this much early and the glide crosses the middle on the note.\n */\nexport function vocalGlideLead(glide?: number, overshoot?: number, preparation?: number): number {\n const d = VOCAL_GLIDE_DEFAULTS;\n const g = new PitchGlide(1000);\n g.setSpeed(vocalGlideSpeed(Number.isFinite(glide) ? (glide as number) : d.glide));\n g.setDamping(vocalDamping(Number.isFinite(overshoot) ? (overshoot as number) : d.overshoot));\n g.setPreparation(clamp(Number.isFinite(preparation) ? (preparation as number) : d.preparation, 0, 1));\n return g.leadTime();\n}\n", "/*\n * A sung note change: pitch that prepares, glides, overshoots and settles,\n * as a singer's does, from one second-order system stepped exactly.\n *\n * Saitou, Unoki and Akagi model sung F0 as the score's step melody plus\n * components a singer adds: preparation (a small move opposite to a note\n * change, just before it), overshoot (passing the new note just after it),\n * vibrato and fine fluctuation. They make overshoot and preparation with\n * second-order systems, and in their listening tests every component\n * affected perceived quality and overshoot affected it most (Speech\n * Communication 47, 2005). A critically damped glide, which the first vocal\n * engine and CHIMERA both use, has neither.\n *\n * Here both come from one transfer function,\n *\n * H(s) = w^2 (1 - s/z) / (s^2 + 2 zeta w s + w^2),\n *\n * whose damping below 1 overshoots and whose right-half-plane zero at z\n * makes a step start out the wrong way: the preparation. Written as\n * x'' + 2 zeta w x' + w^2 x = w^2 u - (w^2 / z) u', a step of size d in the\n * target u is an impulse in u', so it adds -(w^2 / z) d = -w p d to the\n * velocity at that instant, with p = w / z the preparation amount. Between\n * steps the error e = x - u decays exactly:\n *\n * e(t) = exp(-zeta w t) (e0 cos(wd t) + (v0 + zeta w e0) / wd sin(wd t))\n * v(t) = exp(-zeta w t) (v0 cos(wd t) - (zeta w v0 + w^2 e0) / wd sin(wd t))\n *\n * with wd = w sqrt(1 - zeta^2), and at zeta = 1 the critically damped limit\n * of src/dsp/critdamp.ts. So one step is a few multiply-adds and a\n * precomputed exp, cos and sin, the trajectory is the continuous one\n * sampled at the step times whatever the step rate, and a preparation that\n * should land before the note means posting the target early by\n * leadTime().\n *\n * The defaults are INFERRED, not Saitou's fitted values: about 5.5 Hz\n * natural frequency and damping 0.6 (an overshoot of 9.5 percent of the\n * interval), and no preparation.\n */\n\nimport { clamp } from 'bellowsjs';\n\nconst MIN_DAMPING = 0.2;\nconst MAX_PREPARATION = 1;\n\nexport class PitchGlide {\n private readonly h: number;\n private x = 0;\n private v = 0;\n private goal = 0;\n private w = 2 * Math.PI * 5.5;\n private zeta = 0.6;\n private prep = 0;\n // the step's coefficients: [e', v'] = [[a, b], [c, d]] [e, v]\n private a = 1;\n private b = 0;\n private c = 0;\n private d = 1;\n\n /** stepRateHz: how often step() runs, a sample rate or a control rate. Throws outside [10, 1e7] Hz. */\n constructor(stepRateHz: number) {\n if (!(stepRateHz >= 10 && stepRateHz <= 1e7)) throw new RangeError(`PitchGlide step rate ${stepRateHz} Hz is outside [10, 1e7]`);\n this.h = 1 / stepRateHz;\n this.update();\n }\n\n /** Natural frequency in Hz: how fast a glide moves, about 3 to 10 for a voice. */\n setSpeed(hz: number): void {\n if (!Number.isFinite(hz)) return;\n this.w = 2 * Math.PI * clamp(hz, 0.1, 200);\n this.update();\n }\n\n /** Damping, [0.2, 1]: 1 glides without overshoot, 0.5 overshoots by 16 percent of the interval. */\n setDamping(zeta: number): void {\n if (!Number.isFinite(zeta)) return;\n this.zeta = clamp(zeta, MIN_DAMPING, 1);\n this.update();\n }\n\n /** Preparation, [0, 1]: how far a note change first moves the wrong way. 0 is none. */\n setPreparation(amount: number): void {\n if (!Number.isFinite(amount)) return;\n this.prep = clamp(amount, 0, MAX_PREPARATION);\n }\n\n /** Move toward a new target from wherever the glide is, with preparation and overshoot. */\n setTarget(target: number): void {\n if (!Number.isFinite(target)) return;\n const jump = target - this.goal;\n this.goal = target;\n if (jump !== 0 && this.prep > 0) this.v -= this.w * this.prep * jump;\n }\n\n /** Jump straight to a value, at rest. */\n snap(value: number): void {\n if (!Number.isFinite(value)) return;\n this.x = this.goal = value;\n this.v = 0;\n }\n\n /** Advance one step; returns the value. */\n step(): number {\n this.advance();\n return this.x;\n }\n\n /** Advance one step and leave the value in `value`: no double crosses the call. */\n advance(): void {\n const e = this.x - this.goal;\n const v = this.v;\n this.x = this.goal + this.a * e + this.b * v;\n this.v = this.c * e + this.d * v;\n }\n\n get value(): number {\n return this.x;\n }\n\n get velocity(): number {\n return this.v;\n }\n\n get target(): number {\n return this.goal;\n }\n\n /**\n * Seconds a step from rest takes to cover half the interval: post a note\n * change this much early and its glide is half way at the note's time,\n * with the preparation before it and the overshoot after.\n */\n leadTime(): number {\n // the step response is monotone in the first half, so bisect on it in closed form\n let lo = 0;\n let hi = 10 / this.w;\n for (let i = 0; i < 60; i++) {\n const t = 0.5 * (lo + hi);\n if (this.stepResponse(t) < 0.5) lo = t;\n else hi = t;\n }\n return 0.5 * (lo + hi);\n }\n\n /** The unit step response at time t (from rest at 0, target 1), closed form. */\n stepResponse(t: number): number {\n const w = this.w;\n const zeta = this.zeta;\n const e0 = -1;\n const v0 = -w * this.prep;\n const k = Math.exp(-zeta * w * t);\n if (zeta >= 1 - 1e-9) return 1 + k * (e0 + (v0 + w * e0) * t);\n const wd = w * Math.sqrt(1 - zeta * zeta);\n return 1 + k * (e0 * Math.cos(wd * t) + ((v0 + zeta * w * e0) / wd) * Math.sin(wd * t));\n }\n\n private update(): void {\n const w = this.w;\n const zeta = this.zeta;\n const h = this.h;\n const k = Math.exp(-zeta * w * h);\n if (zeta >= 1 - 1e-9) {\n // e(h) = (e0 + (v0 + w e0) h) k, v(h) = (v0 - w (v0 + w e0) h) k\n this.a = (1 + w * h) * k;\n this.b = h * k;\n this.c = -w * w * h * k;\n this.d = (1 - w * h) * k;\n return;\n }\n const wd = w * Math.sqrt(1 - zeta * zeta);\n const cs = Math.cos(wd * h);\n const sn = Math.sin(wd * h);\n this.a = k * (cs + ((zeta * w) / wd) * sn);\n this.b = (k * sn) / wd;\n this.c = (-k * w * w * sn) / wd;\n this.d = k * (cs - ((zeta * w) / wd) * sn);\n }\n}\n"],
5
- "mappings": ";AAsBO,IAAMA,EAAiB,CAE5B,IAEA,SAAK,OAAK,SAAK,SAAK,SAAK,SAAK,SAAK,IAAK,SAAK,IAAK,IAAK,IAAK,IAAK,SAEjE,IAAK,IAAK,IAAK,IAAK,IAAK,IAEzB,IAAK,IAAK,SAAK,OAAK,IAAK,IAAK,SAAK,SAAK,IAExC,UAAM,UAEN,IAAK,IAAK,SAEV,IAAK,SAAK,IAAK,IAEf,SAAK,SAEL,SAMA,SAAK,SAAK,SAAK,SAAK,SAAK,SAAK,SAAK,IAAK,OAAK,SAAK,SAAK,QACzD,EAKMC,EAAkD,CACtD,OAAG,SACH,OAAG,IACH,EAAG,SACH,OAAG,UACH,OAAG,SACL,EAEMC,EAAQ,IAAI,IAAoBF,EAAe,IAAI,CAAC,EAAGG,IAAM,CAAC,EAAGA,CAAC,CAAC,CAAC,EAGnE,SAASC,EAAkBC,EAAqB,CACrD,IAAMC,EAASJ,EAAM,IAAIG,CAAG,EAC5B,GAAIC,IAAW,OAAW,OAAOA,EACjC,IAAMC,EAAQN,EAAQI,CAAG,EACzB,OAAOE,IAAU,OAAY,GAAML,EAAM,IAAIK,CAAK,GAAK,EACzD,CAGO,IAAMC,EAAwB,EA6B/BC,EAAS,CAAE,IAAK,QAAS,OAAQ,EAAK,EAUtCC,EAA8C,CAClD,EAAG,CAAE,IAAK,UAAW,OAAQ,EAAM,EACnC,OAAGD,EAAG,OAAGA,EAAG,OAAGA,EAAG,OAAGA,EAAG,OAAGA,EAAG,OAAGA,EAAG,OAAGA,EAAG,EAAGA,EAAG,OAAGA,EAAG,EAAGA,EAAG,EAAGA,EAAG,EAAGA,EAAG,EAAGA,EAAG,OAAGA,EACjF,EAAG,CAAE,IAAK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AAG,CAAC,CAAC,EAC7FL,EAAE,SAAS,CACpB",
6
- "names": ["VOCAL_PHONEMES", "ALIASES", "INDEX", "i", "vocalPhonemeIndex", "ipa", "direct", "alias", "VOCAL_DEFAULT_PHONEME", "V", "SOUNDS", "VOCAL_ACOUSTICS", "s", "VOCAL_UNASPIRATED_VOT", "S_INDEX", "RELEASE_INTO", "IS_STOP", "row", "inTable", "vocalReleaseAspirated", "stop", "prev", "vocalReleaseVot", "next", "into", "vot", "clamp", "CRITDAMP_SETTLE_98", "CRITDAMP_MIN_OMEGA", "CRITDAMP_MAX_OMEGA", "DEFAULT_OMEGA", "VALUE_LIMIT", "MIN_STEP_RATE", "MAX_STEP_RATE", "checkRate", "stepRateHz", "omegaForTime", "seconds", "t", "SETTLED", "CritDamp", "radPerSec", "w", "target", "value", "e", "ch", "ne", "nv", "CritDampBank", "channels", "i", "velocity", "src", "at", "targets", "omegas", "r", "x", "v", "goal", "omega", "decay", "h", "clamp", "clamp", "MIN_DAMPING", "MAX_PREPARATION", "PitchGlide", "stepRateHz", "hz", "zeta", "amount", "target", "jump", "value", "v", "lo", "hi", "t", "w", "e0", "v0", "k", "wd", "h", "cs", "sn", "VOCAL_PLAN_LEAD", "VOCAL_GLIDE_DEFAULTS", "vocalDamping", "overshoot", "os", "l", "vocalGlideSpeed", "glide", "g", "clamp", "CRITDAMP_SETTLE_98", "vocalGlideLead", "preparation", "d", "PitchGlide"]
7
- }
@@ -1,6 +0,0 @@
1
- /*! bellows-voice | MIT, Copyright (c) 2026 Moheeb Zara | includes code from CHIMERA, https://github.com/jamesondh/chimera-vocal-synth, Copyright (c) 2026 Jameson Hodge, MIT License | notices in THIRD_PARTY_NOTICES.md */
2
- var ee="iy\u0268\u0289\u026Fu\u026A\u028F\u028Ae\xF8\u0258\u0275\u0264o\u0259\u025B\u0153\u025C\u025E\u028C\u0254\xE6\u0250a\u0276\u0251\u0252\u025D\u025A",Ce="pbtd\u0288\u0256c\u025Fkgq\u0262\u0294m\u0271n\u0273\u0272\u014B\u0274\u0278\u03B2fv\u03B8\xF0sz\u0283\u0292\u0282\u0290\xE7\u029Dx\u0263\u03C7\u0281\u0127\u0295h\u0266\u026C\u026E\u0255\u0291w\u028B\u0279\u027Bj\u0265\u0270l\u026B\u026D\u028E\u027E\u027Dr\u0280\u0299",ne=["t\u0283","d\u0292","a\u026A","a\u028A","\u0254\u026A","e\u026A","o\u028A"],Ne=new Map([["\u0261","g"],["\u02A7","t\u0283"],["\u02A4","d\u0292"],["\u03B5","\u025B"],["\u03B1","\u0251"],["\u1D7B","\u026A"],["\u1D7F","\u028A"],["\u0269","\u026A"],["\u0277","\u028A"],["\u02A6","ts"],["\u02A3","dz"],["\u02A8","t\u0255"],["\u02A5","d\u0291"]]),Le=/^(?=[\p{Ll}\p{Lo}])[\p{Script=Latin}\p{Script=Greek}]$/u,xe=new Set(Array.from(ee)),v=new Set([...ee,...Ce,...ne]),H="_",Ie=.16,Pe=.15,Ue=.09,De=1.7,We="\u0329",Fe="\u030D",ve=/[\u035C\u0361]/g,N=0,M=1,L=2;function p(e){let n=e.codePointAt(0);return n!==void 0&&xe.has(String.fromCodePoint(n))}function Me(e){return k(e).segments}function k(e){let n=Array.from(Ye(e)),r=[],t=[],o=0,s=0;for(;s<n.length;){let i=n[s];if(i==="\u02C8"||i==="'"){o=1,s++;continue}if(i==="\u02CC"){o=2,s++;continue}if(i==="."){F(t,M),s++;continue}if(i===","||i==="|"||i==="\u2016"){F(t,L),r.push({ipa:H,dur:Ie}),t.push(N),s++;continue}if(/\s/.test(i)){F(t,L),s++;continue}if(i==="\u02D0"||i===":"){let f=r[r.length-1];if(f){let u=p(f.ipa)?Pe:Ue;f.dur=(f.dur??u)*De}s++;continue}let a=i;for(let f of ne)ke(n,s,f)&&(a=f);s+=a===i?1:Array.from(a).length;let l=!1;for(;s<n.length&&ze(n[s]);)(n[s]===We||n[s]===Fe)&&(l=!0),s++;if(!(!v.has(a)&&!Le.test(a))){if(p(a)){r.push({ipa:a,stress:o}),t.push(N),o=0;continue}l&&(r.push({ipa:"\u0259",stress:o}),t.push(N),o=0),r.push({ipa:a}),t.push(N)}}return{segments:r,breaks:t}}function F(e,n){let r=e.length-1;r>=0&&e[r]<n&&(e[r]=n)}function ke(e,n,r){let t=n;for(let o of r){if(e[t]!==o)return!1;t++}return!0}function ze(e){return e>="\u0300"&&e<="\u036F"}function Ye(e){let n="";for(let r of e.normalize("NFC")){if(v.has(r)){n+=r;continue}let t=Ne.get(r);if(t!==void 0){n+=t;continue}let o=Array.from(r.normalize("NFD"));if(o.length>1){let s=(o[0]+o[1]).normalize("NFC");if(v.has(s)){n+=s+o.slice(2).join("");continue}}n+=o.join("")}return n.replace(ve,"")}var Ge=new Map([["AA","\u0251"],["AE","\xE6"],["AH","\u028C"],["AO","\u0254"],["AW","a\u028A"],["AY","a\u026A"],["EH","\u025B"],["ER","\u025D"],["EY","e\u026A"],["IH","\u026A"],["IY","i"],["OW","o\u028A"],["OY","\u0254\u026A"],["UH","\u028A"],["UW","u"],["B","b"],["CH","t\u0283"],["D","d"],["DH","\xF0"],["F","f"],["G","g"],["HH","h"],["JH","d\u0292"],["K","k"],["L","l"],["M","m"],["N","n"],["NG","\u014B"],["P","p"],["R","\u0279"],["S","s"],["SH","\u0283"],["T","t"],["TH","\u03B8"],["V","v"],["W","w"],["Y","j"],["Z","z"],["ZH","\u0292"]]),Ve=/^([A-Z]+)([012])?$/;function z(e){let n=[];for(let r of e.trim().split(/\s+/)){let t=Ve.exec(r);if(!t)continue;let o=t[1],s=t[2]==="1"?1:t[2]==="2"?2:0,i=Ge.get(o);i!==void 0&&(s===0&&o==="AH"&&(i="\u0259"),s===0&&o==="ER"&&(i="\u025A"),n.push(p(i)?{ipa:i,stress:s}:{ipa:i}))}return n}var Y=[["#C","ed","#","\u025B d"],["#CC","ed","#","\u025B d"],["#CCC","ed","#","\u025B d"],["#C","es","#","\u025B s"],["#CC","es","#","\u025B s"],["#y","es","#","\u025B s"],["t","ed","#","\u026A d"],["d","ed","#","\u026A d"],["k","ed","#","t"],["p","ed","#","t"],["s","ed","#","t"],["f","ed","#","t"],["x","ed","#","t"],["h","ed","#","t"],["c","ed","#","t"],["s","es","#","\u026A z"],["z","es","#","\u026A z"],["x","es","#","\u026A z"],["h","es","#","\u026A z"],["c","es","#","\u026A z"],["g","es","#","\u026A z"],["r","s","#","z"],["l","s","#","z"],["m","s","#","z"],["n","s","#","z"],["d","s","#","z"],["g","s","#","z"],["b","s","#","z"],["v","s","#","z"],["w","s","#","z"],["u","s","#","s"],["","ng","s#","\u014B"],["","ng","ing","\u014B"],["","ng","ly","\u014B"],["","ng","ed#","\u014B"],["","n","k","\u014B"],["","iew","","j u"],["f","ew","","j u"],["p","ew","","j u"],["m","ew","","j u"],["h","ew","","j u"],["","ew","","u"],["","cious","","\u0283 \u0259 s"],["","tious","","\u0283 \u0259 s"],["","ous","#","\u0259 s"],["#h","ow","","a\u028A"],["#n","ow","","a\u028A"],["#c","ow","","a\u028A"],["#w","ow","","a\u028A"],["#v","ow","","a\u028A"],["#all","ow","","a\u028A"],["","ow","s#","o\u028A"],["","ow","ing","o\u028A"],["","ow","ly","o\u028A"],["","ow","ed#","o\u028A"],["#","ow","n","o\u028A"],["l","ow","n","o\u028A"],["h","ow","n","o\u028A"],["n","ow","n","o\u028A"],["gr","ow","n","o\u028A"],["thr","ow","n","o\u028A"],["","o","#","o\u028A"],["","o","ld","o\u028A"],["","o","lt","o\u028A"],["","i","nd#","a\u026A"],["","i","nds#","a\u026A"],["","i","nding","a\u026A"],["","i","ndly","a\u026A"],["","i","ndness","a\u026A"],["","i","ld#","a\u026A"],["","i","ldly","a\u026A"],["","all","#","\u0254 l"],["","all","s#","\u0254 l"],["","all","ing","\u0254 l"],["","all","ed#","\u0254 l"],["","alk","","\u0254 k"],["w","ar","","\u0254 \u0279"],["w","a","CC","\u0251"],["w","a","C#","\u0251"],["","ea","d#","\u025B"],["","ea","dy","\u025B"],["","ea","lth","\u025B"],["","ea","th#","\u025B"],["","ea","ther","\u025B"],["","ea","vy","\u025B"],["","ea","ven","\u025B"],["","ea","sant","\u025B"],["","ea","sure","\u025B"],["","ea","dow","\u025B"],["","oo","k","\u028A"],["g","oo","d","\u028A"],["w","oo","d","\u028A"],["h","oo","d","\u028A"],["t","oo","d","\u028A"],["f","oo","t","\u028A"],["d","oo","r","\u0254"],["fl","oo","r","\u0254"],["l","o","ve","\u028C"],["l","o","vi","\u028C"],["b","o","ve#","\u028C"],["c","o","ver","\u028C"],["s","o","me","\u028C"],["c","o","me","\u028C"],["w","o","n","\u028C"],["","o","ney","\u028C"],["","o","nth","\u028C"],["","o","ther","\u028C"],["","o","thing","\u028C"],["","th","er","\xF0"],["","th","e#","\xF0"],["","ear","l","\u025D"],["","ear","n","\u025D"],["","ear","ch","\u025D"],["","ear","th","\u025D"],["h","ear","d#","\u025D"],["h","ear","t","\u0251 \u0279"],["C","are","#","\u025B \u0279"],["","a","rr","\xE6"],["C","a","rV","\u025B"],["","i","re#","a\u026A"],["V","sure","","\u0292 \u025A"],["#","s","ure","\u0283"],["","ure","#","\u028A \u0279"],["","i","ty#","\u026A"],["t","i","ve#","\u026A"],["C","i","ly#","\u0259"],["","i","ver","\u026A"],["","i","ven","\u026A"],["#","a","Ce#","e\u026A"],["#","a","wa","\u0259"],["#","a","CV","\u0259"],["#","u","CV","j u"],["m","u","CV","j u"],["f","u","CV","j u"],["p","u","CV","j u"],["b","u","CV","j u"],["c","u","CV","j u"],["h","u","CV","j u"],["","ough","t","\u0254"],["","ou","l","o\u028A"],["","ou","ng","\u028C"],["","ou","ble","\u028C"],["","ou","ntry","\u028C"],["f","our","","\u0254 \u0279"],["p","our","","\u0254 \u0279"],["c","our","","\u0254 \u0279"],["s","our","","\u0254 \u0279"],["#","g","i","g"],["w","or","n","\u0254 \u0279"],["w","or","C","\u025D"],["","er","r","\u025B"],["VC","er","y#","\u025A"],["VC","or","y#","\u025A"],["VC","or","ies#","\u025A"],["","a","nge#","e\u026A"],["","a","nges#","e\u026A"],["","a","nged#","e\u026A"],["","a","ngel","e\u026A"],["","n","ge#","n"],["","n","ges#","n"],["","n","ged#","n"],["","n","gel","n"],["m","n","#",""],["#gu","y","#","a\u026A"],["#","gu","V","g"],["","eau","t","j u"],["#","al","so","\u0254 l"],["#","al","w","\u0254 l"],["#","al","r","\u0254 l"],["#","al","mo","\u0254 l"],["#","al","th","\u0254 l"],["Co","s","e#","z"],["Ci","s","e#","z"],["au","s","e#","z"],["ai","s","e#","z"],["oi","s","e#","z"],["ea","s","on","z"],["#h","ere","#","\u026A \u0279"],["h","ere","#","\u025B \u0279"],["","ere","#","\u026A \u0279"],["m","o","st","o\u028A"],["p","o","st","o\u028A"],["h","o","st","o\u028A"],["#","o","nly","o\u028A"],["VC","e","ly#",""],["VC","e","ful",""],["VC","e","ness",""],["VC","e","ment",""],["VC","e","less",""],["w","a","ter","\u0254"],["f","a","ther","\u0251"],["","a","Cow","\xE6"],["","i","Cow","\u026A"],["","i","rV","\u026A"],["#f","or","ev","\u025A"],["#f","or","g","\u025A"],["#","o","h#","o\u028A"],["V","h","#",""],["","aa","","\u0251"],["#y","e","#","i"],["#h","ey","#","e\u026A"],["","eah","#","\xE6"],["","tion","","\u0283 \u0259 n"],["","sion","","\u0292 \u0259 n"],["","ture","","t\u0283 \u025A"],["","ough","#","o\u028A"],["","augh","","\u0254"],["","igh","","a\u026A"],["","eigh","","e\u026A"],["","tch","","t\u0283"],["","dge","","d\u0292"],["","sch","","s k"],["","ch","","t\u0283"],["","sh","","\u0283"],["","th","","\u03B8"],["","ph","","f"],["","wh","","w"],["","ck","","k"],["","ng","#","\u014B"],["","ng","","\u014B g"],["","qu","","k w"],["#","kn","","n"],["#","wr","","\u0279"],["","gh","",""],["","ee","","i"],["","ea","","i"],["","oo","","u"],["","ou","","a\u028A"],["","ow","#","o\u028A"],["","ow","","a\u028A"],["","oi","","\u0254\u026A"],["","oy","","\u0254\u026A"],["","ai","","e\u026A"],["","ay","","e\u026A"],["","au","","\u0254"],["","aw","","\u0254"],["","ie","#","a\u026A"],["","ie","","i"],["","ei","","e\u026A"],["","ey","#","i"],["","oa","","o\u028A"],["","ue","#","u"],["","er","#","\u025A"],["","er","C","\u025D"],["","ir","","\u025D"],["","ur","","\u025D"],["","or","","\u0254 \u0279"],["","ar","","\u0251 \u0279"],["C","le","#","\u0259 \u026B"],["","ed","#","d"],["","es","#","z"],["C","s","#","s"],["V","s","#","z"],["#C","y","#","a\u026A"],["#CC","y","#","a\u026A"],["#CCC","y","#","a\u026A"],["","y","#","i"],["#","y","","j"],["C","y","","a\u026A"],["#C","e","#","i"],["#CC","e","#","i"],["","e","#",""],["#C","a","#","\u0251"],["#CC","a","#","\u0251"],["","a","CV","e\u026A"],["","a","","\xE6"],["","e","","\u025B"],["","i","CV","a\u026A"],["","i","","\u026A"],["","o","CV","o\u028A"],["","o","","\u0251"],["","u","CV","u"],["","u","","\u028C"],["","y","","\u026A"],["","c","e","s"],["","c","i","s"],["","c","y","s"],["","c","","k"],["","g","e","d\u0292"],["","g","i","d\u0292"],["","g","","g"],["","x","","k s"],["","j","","d\u0292"],["","q","","k"],["","b","","b"],["","d","","d"],["","f","","f"],["","h","","h"],["","k","","k"],["","l","","l"],["","m","","m"],["","n","","n"],["","p","","p"],["","r","","\u0279"],["","s","","s"],["","t","","t"],["","v","","v"],["","w","","w"],["","z","","z"]],_e=Y.map(e=>e[3]?e[3].split(" "):[]);function re(e){let n=[],r=0;for(;r<e.length;){let s=!1;for(let i=0;i<Y.length;i++){let[a,l,f]=Y[i];if(e.startsWith(l,r)&&oe(e,r-1,a,-1)&&oe(e,r+l.length,f,1)){for(let u of _e[i])!p(u)&&u===n[n.length-1]||n.push(u);r+=l.length,s=!0;break}}s||r++}let t=[],o=n.findIndex(s=>p(s)&&s!=="\u0259"&&s!=="\u025A");o<0&&(o=n.findIndex(s=>p(s)));for(let s=0;s<n.length;s++){let i=n[s];p(i)?t.push({ipa:i,stress:s===o?1:0}):t.push({ipa:i})}return t}function te(e){return e==="a"||e==="e"||e==="i"||e==="o"||e==="u"||e==="y"}function oe(e,n,r,t){let o=n;for(let s=0;s<r.length;s++){let i=t===1?r[s]:r[r.length-1-s],a=o>=0&&o<e.length?e[o]:void 0;if(i==="#"){if(a!==void 0)return!1}else if(i==="V"){if(!te(a))return!1}else if(i==="C"){if(a===void 0||te(a))return!1}else if(a!==i)return!1;o+=t}return!0}var je=new Set(["p","b","t","d","k","g","f","v","\u03B8","\xF0","s","z","\u0283","\u0292","h","m","n","l","\u0279","w","j","t\u0283","d\u0292","pl","bl","kl","gl","fl","sl","p\u0279","b\u0279","t\u0279","d\u0279","k\u0279","g\u0279","f\u0279","\u03B8\u0279","\u0283\u0279","sp","st","sk","sm","sn","sw","sf","tw","kw","dw","gw","\u03B8w","pj","bj","kj","gj","mj","nj","fj","vj","hj","lj","spl","sp\u0279","st\u0279","sk\u0279","skw","skj","spj"]),Be=new Map([["r","\u0279"],["\u026B","l"]]),Ze=new Set(Array.from("m\u0271n\u0273\u0272\u014B\u0274l\u026B\u026D\u028E\u0279\u027Br\u0280\u0299\u027E\u027Djw\u028B\u0265\u0270")),Ke=new Set(Array.from("\u0278\u03B2fv\u03B8\xF0sz\u0283\u0292\u0282\u0290\xE7\u029Dx\u0263\u03C7\u0281\u0127\u0295h\u0266\u026C\u026E\u0255\u0291"));function se(e){return Ze.has(e)?2:Ke.has(e)?1:0}function I(e){if(e.length===0)return;let n=0;for(let r=1;r<e.length;r++)se(e[r].ipa)>se(e[n].ipa)&&(n=r);return{onset:e.slice(0,n),nucleus:e[n],coda:e.slice(n+1)}}var Qe=3;function R(e){let n=[];for(let o=0;o<e.length;o++)p(e[o].ipa)&&n.push(o);let r=[],t=0;for(let o=0;o<n.length;o++){let s=n[o],i=e.length;if(o+1<n.length){let a=n[o+1],l=a-(s+1),f=0;for(let u=Math.min(Qe,l);u>=1;u--)if($e(e,a-u,a)){f=u;break}i=a-f}r.push({onset:e.slice(t,s),nucleus:e[s],coda:e.slice(s+1,i)}),t=i}return r}function $e(e,n,r){if(r-n===1){let o=e[n].ipa;return o!=="\u014B"&&o!==H}let t="";for(let o=n;o<r;o++)t+=Be.get(e[o].ipa)??e[o].ipa;return je.has(t)}var qe=new Set(["th","sh","ch","ph","wh","ck","gh"]);function ie(e,n){let r=Math.floor(n);if(!(r>1)||!Number.isFinite(r))return[e];let t=Array.from(e),o=t.length,s=[];for(let d=0;d<o;){if(!x(t[d])){d++;continue}let g=d;do d++;while(d<o&&x(t[d])&&!Xe(t[d]));s.push([g,d])}let i=o>=2&&(t[o-1]==="e"||t[o-1]==="E"),a=i&&!x(t[o-2]),l=i&&o>=3&&(t[o-2]==="l"||t[o-2]==="L")&&!x(t[o-3])&&t[o-3]!=="l"&&t[o-3]!=="L";if(s.length>1&&a&&!l&&s[s.length-1][0]+1===o&&s.pop(),s.length<r){let d=[e];for(let g=1;g<r;g++)d.push("~");return d}for(;s.length>r;){let d=s.pop();s[s.length-1][1]=d[1]}let f=[0];for(let d=0;d<s.length-1;d++){let g=s[d][1],c=s[d+1][0],h=c-g,S=h>=2&&qe.has((t[c-2]+t[c-1]).toLowerCase());f.push(S?c-2:g+(h<=1?0:Math.floor(h/2)))}f.push(o);let u=[];for(let d=0;d<f.length-1;d++)u.push(t.slice(f[d],f[d+1]).join(""));return u}function x(e){switch(e.length===1&&e<"\x80"?e:e.normalize("NFD")[0]){case"a":case"e":case"i":case"o":case"u":case"y":case"A":case"E":case"I":case"O":case"U":case"Y":return!0;default:return!1}}function Xe(e){return e.length===1&&e<"\xC0"?!1:e.normalize("NFD").includes("\u0308")}var Je=["KIT","DRESS","TRAP","LOT","STRUT","FOOT","BATH","CLOTH","NURSE","FLEECE","FACE","PALM","THOUGHT","GOAT","GOOSE","PRICE","CHOICE","MOUTH","NEAR","SQUARE","START","NORTH","FORCE","CURE","happY","lettER","commA"],en=new Set(["dance","dancer","dancing","chance","glance","lance","prance","trance","france","advance","enhance","plant","grant","slant","chant","aunt","can't","shan't","branch","answer","example","sample","demand","command","commander","remand","rather","father","half","calf","laugh","laughter","banana","drama"]),nn=new Set(["after","nasty","master","disaster","plaster","pastor","rafter","castle","fasten"]),tn=/au|aw|al[lkt]|ough|augh|oa|wa/;function G(e,n){let r=e.toLowerCase(),t=[];for(let o=0;o<n.length;o++)p(n[o].ipa)&&t.push(o);for(let o=0;o<t.length;o++){let s=t[o],i=n[s],a=n[s+1]?.ipa,l=n[s+2]?.ipa,u=a==="\u0279"&&(l===void 0||!p(l)),d=i.stress!==void 0&&i.stress>0,g=o===t.length-1;i.set=on(i.ipa,{w:r,next:a,after:l,rCoda:u,stressed:d,last:g})}}function on(e,n){switch(e){case"i":return n.rCoda?"NEAR":!n.stressed&&n.last?"happY":"FLEECE";case"\u026A":return n.rCoda?"NEAR":"KIT";case"\u025B":return n.rCoda?"SQUARE":"DRESS";case"e\u026A":return n.rCoda?"SQUARE":"FACE";case"\xE6":return en.has(n.w)||nn.has(n.w)||(n.next==="f"||n.next==="\u03B8"||n.next==="s")&&(n.after===void 0||!p(n.after))?"BATH":"TRAP";case"\u0251":return n.rCoda?"START":/(w|qu)a/.test(n.w)||n.w.includes("o")&&!/a(?!u|w)/.test(n.w)?"LOT":n.w.includes("a")&&!n.w.includes("o")?"PALM":"LOT";case"\u0254":return n.rCoda?"NORTH":tn.test(n.w)?"THOUGHT":"CLOTH";case"o\u028A":return n.rCoda?"FORCE":"GOAT";case"\u028C":return"STRUT";case"\u028A":return n.rCoda?"CURE":"FOOT";case"u":return n.rCoda?"CURE":"GOOSE";case"\u025D":case"\u025A":return n.stressed?"NURSE":"lettER";case"\u0259":return n.last&&n.next===void 0?"commA":void 0;case"a\u026A":return"PRICE";case"a\u028A":return"MOUTH";case"\u0254\u026A":return"CHOICE";default:return}}var rn=new Map([["wind","W IH1 N D"],["read","R IY1 D"],["live","L IH1 V"],["lead","L IY1 D"],["close","K L OW1 Z"],["wound","W UW1 N D"]]),ae=new Map([["a","AH0"],["an","AE1 N"],["the","DH AH0"],["of","AH1 V"],["to","T UW1"],["in","IH0 N"],["on","AA1 N"],["at","AE1 T"],["by","B AY1"],["for","F AO1 R"],["from","F R AH1 M"],["with","W IH1 DH"],["as","AE1 Z"],["and","AH0 N D"],["or","AO1 R"],["but","B AH1 T"],["nor","N AO1 R"],["so","S OW1"],["if","IH1 F"],["is","IH1 Z"],["am","AE1 M"],["are","AA1 R"],["was","W AA1 Z"],["were","W ER1"],["be","B IY1"],["been","B IH1 N"],["do","D UW1"],["does","D AH1 Z"],["did","D IH1 D"],["has","HH AE1 Z"],["have","HH AE1 V"],["had","HH AE1 D"],["will","W IH1 L"],["would","W UH1 D"],["can","K AE1 N"],["could","K UH1 D"],["should","SH UH1 D"],["shall","SH AE1 L"],["may","M EY1"],["might","M AY1 T"],["must","M AH1 S T"],["it","IH1 T"],["its","IH1 T S"],["i","AY1"],["you","Y UW1"],["he","HH IY1"],["she","SH IY1"],["we","W IY1"],["they","DH EY1"],["me","M IY1"],["him","HH IH1 M"],["her","HH ER1"],["us","AH1 S"],["them","DH EH1 M"],["my","M AY1"],["your","Y AO1 R"],["his","HH IH1 Z"],["our","AW1 ER0"],["their","DH EH1 R"],["this","DH IH1 S"],["that","DH AE1 T"],["than","DH AE1 N"],["then","DH EH1 N"],["there","DH EH1 R"],["not","N AA1 T"],["no","N OW1"]]),sn=new Map([["one","W AH1 N"],["once","W AH1 N S"],["what","W AH1 T"],["who","HH UW1"],["two","T UW1"],["into","IH1 N T UW0"],["through","TH R UW1"],["where","W EH1 R"],["these","DH IY1 Z"],["those","DH OW1 Z"],["thee","DH IY1"],["thou","DH AW1"],["thy","DH AY1"],["thine","DH AY1 N"],["though","DH OW1"],["people","P IY1 P AH0 L"],["eye","AY1"],["eyes","AY1 Z"],["said","S EH1 D"],["any","EH1 N IY0"],["many","M EH1 N IY0"],["anywhere","EH1 N IY0 W EH2 R"],["anything","EH1 N IY0 TH IH2 NG"],["anyone","EH1 N IY0 W AH2 N"],["everything","EH1 V R IY0 TH IH2 NG"],["everywhere","EH1 V R IY0 W EH2 R"],["everyone","EH1 V R IY0 W AH2 N"],["great","G R EY1 T"],["friend","F R EH1 N D"],["hour","AW1 R"],["whole","HH OW1 L"],["woman","W UH1 M AH0 N"],["women","W IH1 M AH0 N"],["touch","T AH1 CH"],["ocean","OW1 SH AH0 N"],["together","T AH0 G EH1 DH ER0"],["get","G EH1 T"],["forget","F ER0 G EH1 T"],["give","G IH1 V"],["again","AH0 G EH1 N"],["against","AH0 G EH1 N S T"],["because","B IH0 K AO1 Z"],["even","IY1 V IH0 N"],["busy","B IH1 Z IY0"],["sure","SH UH1 R"],["sugar","SH UH1 G ER0"],["enough","IH0 N AH1 F"],["young","Y AH1 NG"],["done","D AH1 N"],["gone","G AO1 N"],["none","N AH1 N"],["bear","B EH1 R"],["wear","W EH1 R"],["break","B R EY1 K"],["guy","G AY1"],["buy","B AY1"],["lose","L UW1 Z"],["move","M UW1 V"],["goes","G OW1 Z"],["door","D AO1 R"],["fire","F AY1 R"],["desire","D IH0 Z AY1 R"],["i'm","AY1 M"],["i'll","AY1 L"],["i've","AY1 V"],["i'd","AY1 D"],["you're","Y UH1 R"],["you'll","Y UW1 L"],["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"],["won't","W OW1 N T"],["can't","K AE1 N T"],["isn't","IH1 Z AH0 N T"],["it's","IH1 T S"],["that's","DH AE1 T S"],["there's","DH EH1 R Z"],["let's","L EH1 T S"],["ain't","EY1 N T"],["didn't","D IH1 D AH0 N T"],["doesn't","D AH1 Z AH0 N T"],["wasn't","W AA1 Z AH0 N T"],["couldn't","K UH1 D AH0 N T"],["wouldn't","W UH1 D AH0 N T"],["shouldn't","SH UH1 D AH0 N T"],["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"],["e'er","EH1 R"]]),an=new Set(["\u028C","\xE6","\u0251","\u025B","\u0254","u","\u028A"]),ln=new Set(["you","do","to","who","not","no"]),cn=/[\u0300-\u036F]/g,un=/^'+|'+$/g;function ce(e,n={}){let r=e.toLowerCase().replace(un,""),t=r.normalize("NFD").replace(cn,""),o=rn.get(t)??dn(n.dictionary,r,t)??ae.get(t)??sn.get(t);if(o){let s=z(o);return n.reduce&&ae.has(t)&&fn(s,t),s}if(r.includes("-")){let s=[];for(let i of r.split("-"))s.push(...ce(i,n));return s}return re(t)}function dn(e,n,r){if(e)return e.get(n)||(r!==n?e.get(r):void 0)}function fn(e,n){let r=0;for(let t of e)p(t.ipa)&&r++;for(let t of e)p(t.ipa)&&(t.stress=0,r===1&&an.has(t.ipa)&&!ln.has(n)&&(t.ipa="\u0259"))}function V(e={}){return{starts:le,continues:n=>n==="-"||le(n)||n>="\u0300"&&n<="\u036F",word:n=>pn(n,e)}}function pn(e,n){let r=e.split("-").filter(o=>o!==""),t=[];for(let o of r){let s=ce(o,n);G(o,s);let i=R(s);if(i.length===0){let l=I(s);l&&i.push(l)}let a=r.length>1?[o]:ie(o,i.length);for(let l=0;l<i.length;l++){let{onset:f,nucleus:u,coda:d}=i[l];t.push({text:a[l]??"~",onset:f,nucleus:u,coda:d,wordEnd:!1,phraseEnd:!1})}}return t}function le(e){if(e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="'")return!0;if(e<"\xC0")return!1;let n=e.normalize("NFD");if(n.length<2)return!1;let r=n[0];if(!(r>="a"&&r<="z"||r>="A"&&r<="Z"))return!1;for(let t=1;t<n.length;t++)if(n[t]<"\u0300"||n[t]>"\u036F")return!1;return!0}var P="/",_={starts:e=>e===P,continues:e=>e!==P&&e!==`
3
- `&&e!=="\r",word:e=>hn(En(e))};function hn(e){let{segments:n,breaks:r}=k(e),t=[],o=[[]];for(let s=0;s<n.length;s++){let i=n[s];if(i.ipa===H){t.length>0&&(t[t.length-1].phraseEnd=!0);continue}o[o.length-1].push(i),r[s]===L||s===n.length-1?(gn(o,t),o=[[]]):r[s]===M&&o.push([])}return t}function gn(e,n){let r=e.length>1?mn(e):R(e[0]);if(r.length===0){let t=I(e.flat());if(!t)return;r.push(t)}for(let t=0;t<r.length;t++){let{onset:o,nucleus:s,coda:i}=r[t];n.push({text:Sn(r[t]),onset:o,nucleus:s,coda:i,wordEnd:t===r.length-1,phraseEnd:!1})}}function mn(e){let n=[],r=[];for(let t of e){let o=R(t);if(o.length===0){n.length>0?n[n.length-1].coda.push(...t):r.push(...t);continue}r.length>0&&(o[0].onset.unshift(...r),r=[]),n.push(...o)}return n}function Sn(e){let n=e.nucleus.stress===1?"\u02C8":e.nucleus.stress===2?"\u02CC":"";for(let r of e.onset)n+=r.ipa;n+=e.nucleus.ipa;for(let r of e.coda)n+=r.ipa;return n}function En(e){let n=e.startsWith(P)?1:0,r=e.length>n&&e.endsWith(P)?e.length-1:e.length;return e.slice(n,r)}function ue(e,n,r={}){let t=r.t??"flap",o=r.l??"dark-coda",s=[],i=()=>{s.length>0&&An(s,t,o),s=[]};for(let a of e){if(!n(a)||a.melisma){i();continue}let l=[...a.onset,a.nucleus,...a.coda];l.forEach((f,u)=>s.push({seg:f,wordEnd:a.wordEnd&&u===l.length-1})),a.phraseEnd&&i()}i()}function An(e,n,r){if(n==="flap")for(let t=1;t+1<e.length;t++){let o=e[t-1],s=e[t+1],i=e[t].seg;(i.ipa==="t"||i.ipa==="d")&&(p(o.seg.ipa)||o.seg.ipa==="\u0279")&&p(s.seg.ipa)&&!(s.seg.stress!==void 0&&s.seg.stress!==0)&&!o.wordEnd&&(i.ipa="\u027E")}else if(n==="glottal"||n==="glottal-coda")for(let t=1;t<e.length;t++){let o=e[t].seg,s=e[t-1].seg.ipa;if(o.ipa!=="t"||!(p(s)||s==="n"||s==="l"))continue;let i=e[t+1]?.seg,a=i===void 0?n==="glottal":!p(i.ipa)&&!yn.has(i.ipa),l=n==="glottal"&&i!==void 0&&p(i.ipa)&&!(i.stress!==void 0&&i.stress!==0)&&!e[t-1].wordEnd&&p(e[t-1].seg.ipa);(a||l)&&(o.ipa="\u0294")}if(r!=="clear")for(let t=0;t<e.length;t++){if(e[t].seg.ipa!=="l")continue;let s=!(t+1<e.length&&p(e[t+1].seg.ipa))||e[t].wordEnd;r==="dark"?e[t].seg.ipa="\u026B":s&&(e[t].seg.ipa=r==="vocalized"?"w":"\u026B")}}var yn=new Set(["\u0279","w","j"]);var B={tune:"fall",range:4,declination:2,rate:1},O={id:"general-american",name:"General American",rhotic:!0,sets:{},t:"flap",l:"dark-coda",th:"fricative",r:"approximant"},de={id:"southern-british",name:"Southern British",rhotic:!1,sets:{KIT:"\u026A",DRESS:"\u025B",TRAP:"a",LOT:"\u0252",STRUT:"\u0250",FOOT:"\u028A",BATH:"\u0251\u02D0",CLOTH:"\u0252",NURSE:"\u025C\u02D0",FLEECE:"i\u02D0",FACE:"e\u026A",PALM:"\u0251\u02D0",THOUGHT:"o\u02D0",GOAT:"\u0259\u028A",GOOSE:"\u0289\u02D0",PRICE:"a\u026A",CHOICE:"\u0254\u026A",MOUTH:"a\u028A",NEAR:"\u026A\u0259",SQUARE:"\u025B\u02D0",START:"\u0251\u02D0",NORTH:"o\u02D0",FORCE:"o\u02D0",CURE:"o\u02D0",happY:"i",lettER:"\u0259",commA:"\u0259"},hold:.55,t:"glottal-coda",l:"dark-coda",th:"fricative",r:"approximant",prosody:{tune:"fall",range:6,declination:3,rate:1}},fe={id:"london",name:"London",rhotic:!1,sets:{KIT:"\u026A",DRESS:"e",TRAP:"\xE6",LOT:"\u0252",STRUT:"\u0250",FOOT:"\u028A",BATH:"\u0251\u02D0",CLOTH:"\u0252",NURSE:"\u025C\u02D0",FLEECE:"\u0259i",FACE:"\xE6\u026A",PALM:"\u0251\u02D0",THOUGHT:"o\u02D0",GOAT:"\u028C\u028A",GOOSE:"\u0289\u02D0",PRICE:"\u0251\u026A",CHOICE:"o\u026A",MOUTH:"\xE6\u028A",NEAR:"\u026A\u0259",SQUARE:"e\u02D0",START:"\u0251\u02D0",NORTH:"o\u02D0",FORCE:"o\u02D0",CURE:"o\u02D0",happY:"i",lettER:"\u0259",commA:"\u0259"},hold:.5,t:"glottal",l:"vocalized",th:"front",r:"approximant",hDrop:!0,prosody:{tune:"fall",range:5,declination:2,rate:1.05}},pe={id:"australian",name:"Australian",rhotic:!1,sets:{KIT:"\u026A",DRESS:"e",TRAP:"\xE6",LOT:"\u0254",STRUT:"\u0250",FOOT:"\u028A",BATH:"\u0250\u02D0",CLOTH:"\u0254",NURSE:"\u0275\u02D0",FLEECE:"\u026Ai",FACE:"\xE6\u026A",PALM:"\u0250\u02D0",THOUGHT:"o\u02D0",GOAT:"\u0250\u0289",GOOSE:"\u0289\u02D0",PRICE:"\u0252e",CHOICE:"o\u026A",MOUTH:"\xE6\u0254",NEAR:"\u026A\u0259",SQUARE:"e\u02D0",START:"\u0250\u02D0",NORTH:"o\u02D0",FORCE:"o\u02D0",CURE:"o\u02D0",happY:"i",lettER:"\u0259",commA:"\u0259"},hold:.45,t:"flap",l:"dark-coda",th:"fricative",r:"approximant",prosody:{tune:"rise",range:4,declination:1.5,rate:1}},he={id:"new-zealand",name:"New Zealand",rhotic:!1,sets:{KIT:"\u0258",DRESS:"e",TRAP:"\u025B",LOT:"\u0252",STRUT:"\u0250",FOOT:"\u028A",BATH:"\u0250\u02D0",CLOTH:"\u0252",NURSE:"\xF8\u02D0",FLEECE:"\u026Ai",FACE:"\xE6\u026A",PALM:"\u0250\u02D0",THOUGHT:"o\u02D0",GOAT:"\u0250\u0289",GOOSE:"\u0289\u02D0",PRICE:"\u0252e",CHOICE:"oe",MOUTH:"\xE6\u028A",NEAR:"i\u0259",SQUARE:"i\u0259",START:"\u0250\u02D0",NORTH:"o\u02D0",FORCE:"o\u02D0",CURE:"\u0289\u0259",happY:"i",lettER:"\u0258",commA:"\u0258"},hold:.45,t:"flap",l:"dark",th:"fricative",r:"approximant",prosody:{tune:"rise",range:3.5,declination:1.5,rate:1.05}},ge={id:"irish",name:"Irish",rhotic:!0,sets:{KIT:"\u026A",DRESS:"\u025B",TRAP:"a",LOT:"\u0251",STRUT:"\u0250",FOOT:"\u028A",BATH:"a\u02D0",CLOTH:"\u0252",FLEECE:"i\u02D0",FACE:"e\u02D0",PALM:"a\u02D0",THOUGHT:"\u0252\u02D0",GOAT:"o\u02D0",GOOSE:"u\u02D0",PRICE:"\u0251\u026A",CHOICE:"\u0252\u026A",MOUTH:"\u0250\u028A",NEAR:"i",SQUARE:"e",START:"a",NORTH:"\u0252",FORCE:"o",CURE:"u",happY:"i"},hold:.6,t:"released",l:"clear",th:"stop",r:"approximant",prosody:{tune:"fall",range:5,declination:2,rate:1.05}},me={id:"scottish",name:"Scottish",rhotic:!0,sets:{KIT:"\u0258",DRESS:"\u025B",TRAP:"a",LOT:"\u0254",STRUT:"\u028C",FOOT:"\u0289",BATH:"a",CLOTH:"\u0254",NURSE:"\u028C\u027E",FLEECE:"i",FACE:"e",PALM:"a",THOUGHT:"\u0254",GOAT:"o",GOOSE:"\u0289",PRICE:"\u028C\u026A",CHOICE:"\u0254\u026A",MOUTH:"\u028C\u0289",NEAR:"i\u027E",SQUARE:"e\u027E",START:"a\u027E",NORTH:"\u0254\u027E",FORCE:"o\u027E",CURE:"\u0289\u027E",happY:"e",lettER:"\u0259\u027E",commA:"\u028C"},hold:.5,t:"glottal-coda",l:"dark",th:"fricative",r:"tap",prosody:{tune:"fall",range:4,declination:2,rate:1}},Se={id:"southern-us",name:"Southern US",rhotic:!0,sets:{DRESS:"\u025B",TRAP:"\xE6",BATH:"\xE6",FACE:"\u025B\u026A",THOUGHT:"\u0252\u0254",CLOTH:"\u0252\u0254",GOAT:"\u025C\u0289",GOOSE:"\u0289",PRICE:"a\u02D0",MOUTH:"\xE6\u028A",CHOICE:"o\u026A"},hold:.5,t:"flap",l:"dark",th:"fricative",r:"approximant",prosody:{tune:"fall",range:5,declination:2,rate:.85}},j=Object.freeze(Object.fromEntries([O,de,fe,pe,he,ge,me,Se].map(e=>[e.id,e])));function Z(e){if(e===void 0)return O;if(typeof e!="string")return e;let n=j[e];if(!n)throw new Error(`unknown accent "${e}"; built in: ${Object.keys(j).join(", ")}`);return n}var Tn=/[ːˑ:]/g;function Hn(e){let n=Array.from(e.replace(Tn,"")),r,t=n[n.length-1];(t==="\u0279"||t==="\u027E"||t==="r")&&(r=t==="r"?"\u0279":t,n.pop());let o=n.filter(s=>p(s));if(o.length===0||o.length>2||o.length!==n.length)throw new Error(`accent realization "${e}" is not one or two vowels and an optional r`);return{vowels:o,r}}var Ee=new Set(["\u0279","\u027E","r"]);function K(e,n,r){for(let t=0;t<e.length;t++){let o=e[t];if(!n(o)||o.melisma)continue;let s=e[t+1],i=!o.phraseEnd&&s!==void 0&&n(s)&&!s.melisma&&s.onset.length===0;Rn(o,r,i),bn(o,r,t===0||e[t-1].wordEnd)}}function Rn(e,n,r){let t=e.nucleus,o=t.set,s=o===void 0?void 0:n.sets[o],i=t.ipa==="\u025D"||t.ipa==="\u025A";if(s!==void 0){let a=Hn(s);if(t.ipa=a.vowels.join(""),a.r!==void 0){let l=n.r==="tap"?"\u027E":a.r;e.coda.length>0&&Ee.has(e.coda[0].ipa)?e.coda[0].ipa=l:e.coda.unshift({ipa:l})}else i&&!n.rhotic&&r&&e.coda.unshift({ipa:"\u0279"})}if(n.rhotic||On(e,r),Array.from(t.ipa).length===2&&o!==void 0){let a=n.holds?.[o]??n.hold;a!==void 0&&(t.hold=Math.max(0,Math.min(1,a)))}}function On(e,n){for(let r=e.coda.length-1;r>=0;r--)!Ee.has(e.coda[r].ipa)||r===e.coda.length-1&&n||e.coda.splice(r,1)}function bn(e,n,r){let t=[e.onset,e.coda];for(let o of t)for(let s=0;s<o.length;s++){let i=o[s],a=r&&o===e.onset&&s===0;n.th==="stop"?i.ipa==="\u03B8"?i.ipa="t":i.ipa==="\xF0"&&(i.ipa="d"):n.th==="front"&&(i.ipa==="\u03B8"?i.ipa="f":i.ipa==="\xF0"&&(i.ipa=a?"d":"v")),n.r==="tap"&&i.ipa==="\u0279"&&(i.ipa="\u027E")}n.hDrop&&r&&e.onset.length>0&&e.onset[0].ipa==="h"&&e.onset.shift()}var U=/\s/,wn=/[\p{L}\p{M}\p{N}]/u;function Cn(e){return e==="."||e===","||e===";"||e===":"||e==="!"||e==="?"||e===`
4
- `}function Ae(e,n){let r=Array.from(e.normalize("NFC").replace(/’/g,"'")),t=[],o=0;for(;o<r.length;){let s=r[o],i=n.find(a=>a.starts(s));if(i){let a=i.continues(s)?Ln(r,o,i):xn(r,o,i);if(a>o){Nn(t,i.word(r.slice(o,a).join(""))),o=a;continue}}if(Cn(s))t.length>0&&(t[t.length-1].phraseEnd=!0);else if(In(r,o)){let a=t[t.length-1];a&&t.push({text:"~",onset:[],nucleus:{...a.nucleus},coda:[],melisma:!0,wordEnd:a.wordEnd,phraseEnd:!1})}o++}return t}function Q(e,n={}){let r=V({dictionary:n.dictionary,reduce:n.reduce}),t=new WeakSet,o={starts:r.starts,continues:r.continues,word:l=>{let f=r.word(l);for(let u of f)t.add(u);return f}},s=Ae(e,[o,_]),i=Z(n.accent),a=l=>t.has(l);return i!==O&&K(s,a,i),n.allophones!==!1&&ue(s,a,{t:i.t,l:i.l}),s}function Nn(e,n){if(n.length!==0){n[n.length-1].wordEnd=!0;for(let r of n)e.push(r)}}function Ln(e,n,r){let t=n+1;for(;t<e.length&&r.continues(e[t]);)t++;return t}function xn(e,n,r){let t=e[n];if(n>0&&wn.test(e[n-1])||n+1>=e.length||e[n+1]===t||U.test(e[n+1]))return n;let o=n+1;for(;o<e.length&&e[o]!==t&&r.continues(e[o]);)o++;return o>=e.length||e[o]!==t||U.test(e[o-1])?n:o+1}function In(e,n){let r=e[n];if(r!=="-"&&r!=="~")return!1;let t=n===0||U.test(e[n-1]),o=n+1===e.length||U.test(e[n+1]);return t&&o}var Pn=/^(\S+)\s+(.+)$/,Un=/\(\d+\)$/;function Dn(e){let n=new Map;for(let r of e.split(`
5
- `)){let t=r.trim();if(t===""||t.startsWith(";;;"))continue;let o=Pn.exec(t);if(!o)continue;let s=o[1];if(Un.test(s))continue;let i=o[2].indexOf("#"),a=(i<0?o[2]:o[2].slice(0,i)).trim().split(/\s+/).join(" ");if(a==="")continue;let l=s.toLowerCase();n.has(l)||n.set(l,a)}return n}import{clamp as W}from"bellowsjs";var Wn=Object.freeze({p:.085,b:.07,t:.075,d:.06,\u0288:.075,\u0256:.065,c:.08,\u025F:.07,k:.08,g:.07,q:.085,\u0262:.075,\u0294:.06,m:.075,\u0271:.075,n:.07,\u0273:.07,\u0272:.075,\u014B:.08,\u0274:.08,\u0278:.11,\u03B2:.09,f:.11,v:.08,\u03B8:.11,\u00F0:.07,s:.12,z:.09,\u0283:.12,\u0292:.09,\u0282:.12,\u0290:.09,\u00E7:.12,\u029D:.09,x:.12,\u0263:.09,\u03C7:.12,\u0281:.09,\u0127:.12,\u0295:.09,h:.09,\u0266:.08,\u026C:.12,\u026E:.09,ts:.14,dz:.12,t\u0283:.15,d\u0292:.13,\u0255:.12,\u0291:.09,t\u0255:.14,d\u0291:.12,t\u0282:.14,d\u0290:.12,pf:.14,w:.06,\u028B:.06,\u0279:.065,\u027B:.065,j:.055,\u0265:.055,\u0270:.06,l:.065,\u026B:.075,\u026D:.065,\u028E:.07,\u027E:.025,\u027D:.03,r:.11,\u0280:.11,\u0299:.12}),Fn=.07,He=.8;var ye=new Map(Object.entries(Wn)),vn=new Map([["\u0261","g"],["\u02A3","dz"],["\u02A4","d\u0292"],["\u02A5","d\u0291"],["\u02A6","ts"],["\u02A7","t\u0283"],["\u02A8","t\u0255"]]),Mn=/[ʰ-˿̀-ͯ]/g;function Te(e){let n=ye.get(e);if(n!==void 0)return n;let r=vn.get(e);return r===void 0?void 0:ye.get(r)}function T(e){return Te(e)??Te(e.replace(Mn,""))??Fn}var kn=.05,zn=.012,Yn=.02,Gn=.12,Vn=.3,_n=.8,jn=.001,Bn=.8,Zn=4,Kn=86400,Qn=10,$n=new Map([["a\u026A",["a","\u026A"]],["a\u028A",["a","\u028A"]],["e\u026A",["e","i"]],["o\u028A",["o","u"]],["\u0254\u026A",["\u0254","\u026A"]]]);function qn(e){let n=$n.get(e);if(n!==void 0||e.length!==2)return n;let r=e[0],t=e[1];return p(r)&&p(t)?[r,t]:void 0}var Xn={text:"ah",onset:[],nucleus:{ipa:"\u0251",stress:1},coda:[],wordEnd:!0,phraseEnd:!1};function Jn(e,n,r={}){let t=W(r.consonantScale??He,0,Zn),o=et(e,n),s=o.length;if(s===0)return{phrases:[],leadIn:0};let i=new Array(s);for(let c=0;c<s;c++){let h=o[c];i[c]=c===s-1||h.syl.phraseEnd||o[c+1].time-(h.time+h.len)>jn}let a=new Array(s),l=new Array(s),f=0;for(let c=0;c<s;c++){c>0&&i[c-1]&&(f=c),a[c]=o[c].syl.melisma===!0?[]:Re(o[c].syl.onset,t);let h=!i[c]&&o[c+1].syl.melisma===!0;l[c]=h?[]:Re(nt(o,c,f).coda,t)}let u=new Array(s);for(let c=0;c<s;c++){let h=o[c];if(i[c])if(c+1<s){let S=o[c+1].time,E=S-h.time,m=Math.min(h.len,E),A=h.syl.phraseEnd?Math.min(Gn,Vn*m):0;D(l[c].concat(a[c+1]),E-A),D(l[c],m),u[c]=Math.max(h.time,Math.min(h.time+m,S-b(a[c+1])-A))}else D(l[c],h.len),u[c]=h.time+h.len;else{let S=o[c+1].time;D(l[c].concat(a[c+1]),S-h.time),u[c]=Math.max(h.time,S-b(a[c+1]))}}let d=[],g=0;for(let c=0;c<s;){let h=c;for(;!i[h];)h++;let S=tt(o,a,l,u,c,h);S!==void 0&&(d.push(S),g=Math.max(g,o[c].time-S.start)),c=h+1}return{phrases:d,leadIn:g}}function et(e,n){let r=[];for(let o of e)Number.isFinite(o.time)&&Number.isFinite(o.hz)&&o.hz>0&&r.push(o);r.sort((o,s)=>o.time-s.time);let t=n.length>0?n:[Xn];return r.map((o,s)=>({time:o.time,len:W(o.dur,0,Kn),hz:o.hz,vel:W(o.vel??Bn,0,1),syl:t[s%t.length]}))}function nt(e,n,r){let t=n;for(;t>r&&e[t].syl.melisma===!0;)t--;return e[t].syl}function Re(e,n){let r=[];for(let t of e){let o=t.dur,s=typeof o=="number"&&Number.isFinite(o)?W(o,0,Qn):T(t.ipa)*n;r.push({ipa:t.ipa,dur:s})}return r}function b(e){let n=0;for(let r of e)n+=r.dur;return n}function D(e,n){let r=b(e),t=n-kn;if(r<=t||r<=0)return;let o=Math.max(0,t)/r,s=0;for(let a of e)a.dur=Math.max(Math.min(a.dur,zn),a.dur*o),s+=a.dur;let i=s+Yn;if(i>n){let a=Math.max(0,n)/i;for(let l of e)l.dur*=a}}function tt(e,n,r,t,o,s){let i=[],a=e[o].time,l=a-b(n[o]),f=[{time:l,hz:e[o].hz}];$(i,n[o],l,a,"onset");for(let u=o;u<=s;u++){let d=e[u],g=t[u],c=Math.max(d.time,g-b(r[u])),h=u===s||e[u+1].syl.melisma!==!0,S=u>o&&d.syl.melisma===!0;ot(i,d.syl.nucleus,d.time,c,h,S),$(i,r[u],c,g,"coda"),u<s&&(f.push({time:g,hz:e[u+1].hz}),$(i,n[u+1],g,e[u+1].time,"onset"))}if(i.length!==0)return{start:i[0].start,end:i[i.length-1].end,vel:e[o].vel,spans:i,pitches:f}}function $(e,n,r,t,o){let s=r;for(let i=0;i<n.length;i++){let a=i===n.length-1?t:Math.min(t,s+n[i].dur);a>s&&e.push({ipa:n[i].ipa,start:s,end:a,kind:o}),s=a}}function ot(e,n,r,t,o,s){let i=n.ipa,a=qn(i);if(a!==void 0&&o){let l=r+(n.hold??_n)*(t-r);q(e,a[0],r,l,s),q(e,a[1],l,t,!1)}else q(e,a===void 0?i:a[0],r,t,s)}function q(e,n,r,t,o){if(!(t>r))return;let s=e[e.length-1],i=s!==void 0&&s.kind==="nucleus"&&s.ipa===n;if(o&&i&&s.end===r){s.end=t;return}e.push({ipa:n,start:r,end:t,kind:"nucleus"})}function be(e,n={}){let r=Q(e,n),t=[],o=[],s=[];for(let i of r){if(o.push(i),!i.wordEnd)continue;let a=Oe(o);t.push(a),s.push(a.ipa,i.phraseEnd?" | ":" "),o=[]}if(o.length>0){let i=Oe(o);t.push(i),s.push(i.ipa)}return{words:t,ipa:s.join("").replace(/ \| $/,"").trim(),syllables:r}}function rt(e,n={}){return be(e,n).ipa}function Oe(e){let n=e.filter(t=>!t.melisma).length>1,r=e.filter(t=>!t.melisma).map(t=>{let o=n&&t.nucleus.stress===1?"\u02C8":n&&t.nucleus.stress===2?"\u02CC":"",s=[...t.onset,t.nucleus,...t.coda].map(i=>i.ipa).join("");return o+s}).join(".");return{text:e.map(t=>t.text).join("-"),ipa:r,syllables:e,sets:e.map(t=>t.nucleus.set)}}var st=.18,it=.09,at=1.5,lt=.28;function ct(e,n={},r=[]){let t=n.prosody??B,o=n.hz!==void 0&&n.hz>0?n.hz:110,s=Math.max(.1,(n.rate??1)*t.rate),i=[],a=[],l=0,f=0;for(let u=0;u<e.length;){let d=u;for(;d<e.length-1&&!e[d].phraseEnd;)d++;let g=e.slice(u,d+1),c=r[f]??t.tune==="rise",{pitches:h,endTone:S}=ut(g,t,c);for(let E=0;E<g.length;E++){let m=g[E],A=E===g.length-1,we=m.nucleus.stress!==void 0&&m.nucleus.stress>0,w=m.nucleus.dur??(we?st:it);A&&(w*=at);let C=0;for(let y of m.coda)C+=y.dur??T(y.ipa);if(!A)for(let y of g[E+1].onset)C+=y.dur??T(y.ipa);if(A&&S!==void 0){let y=.45*w/s,J=(.55*w+C)/s;a.push({...m,coda:[],phraseEnd:!1,wordEnd:!1}),a.push({text:"~",onset:[],nucleus:{...m.nucleus},coda:m.coda,melisma:!0,wordEnd:m.wordEnd,phraseEnd:m.phraseEnd}),i.push({time:l,dur:y,hz:o*2**(h[E]/12)}),i.push({time:l+y,dur:J,hz:o*2**(S/12)}),l+=y+J;continue}let X=(w+C)/s;a.push(m),i.push({time:l,dur:X,hz:o*2**(h[E]/12)}),l+=X}if(d<e.length-1){let E=0;for(let A of e[d+1].onset)E+=A.dur??T(A.ipa);let m=lt/s+E;i.push({time:l,dur:m,hz:0,rest:!0}),l+=m}f++,u=d+1}return{syllables:a,notes:i}}function ut(e,n,r){let t=e.length,o=-1;for(let i=t-1;i>=0;i--){let a=e[i].nucleus.stress;if(a!==void 0&&a>0){o=i;break}}o<0&&(o=t-1);let s=[];for(let i=0;i<t;i++){let a=t>1?-n.declination*(i/(t-1)):0,l=e[i].nucleus.stress??0,f=a;if(i<o)l===1?f+=n.range*(i===dt(e)?1:.7):l===2&&(f+=n.range*.35);else if(i===o)f+=r?-.25*n.range:n.range;else{let u=(i-o)/(t-1-o);f+=r?n.range*(.4+.8*u):-.6*n.range*u-.2*n.range}s.push(f)}return o<t-1?{pitches:s}:{pitches:s,endTone:r?-n.declination+n.range:-n.declination-.4*n.range}}function dt(e){for(let n=0;n<e.length;n++)if(e[n].nucleus.stress===1)return n;return-1}export{Me as a,z as b,Je as c,G as d,V as e,_ as f,B as g,O as h,de as i,fe as j,pe as k,he as l,ge as m,me as n,Se as o,j as p,Z as q,K as r,Ae as s,Q as t,ct as u,Jn as v,Dn as w,be as x,rt as y};
6
- //# sourceMappingURL=chunk-QJYKYLE2.js.map