@yomiscript/kokoro 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,18 @@
1
- # Temporary Holding Version
1
+ # @yomiscript/kokoro
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Kokoro-82M Katarite: YomiScript -> Kokoro's phoneme string and ids -> ONNX (split export enc / f0n / dec) -> audio.
4
+ Given a YomiScript written by the original Kokoro front end, it hands Kokoro exactly what the original pipeline does
5
+ (D21, D22; `eval/kokoro_parity`).
6
+
7
+ - `plan(ys)`: what Kokoro is given, per language section (no ONNX). Japanese ` ‖ ` and an inner `↘` become `,` and `.`
8
+ as in English, so Kokoro pauses there (D26); `plan(ys, { original: true })` drops them as the original does.
9
+ - `Engine(ort, loadBytes)`: the ONNX engine, for onnxruntime-web (browser; `W16`, fp16 weights) or onnxruntime-node
10
+ (`FP32`, identical to the original). `nodeEngine({ dir, model, download })` from `@yomiscript/kokoro/node`; with `download: KOKORO_MODELS_URL`, missing
11
+ files are downloaded into `dir` once.
12
+ - `KokoroKatarite(engine, { voice })`: core's `Katarite` (audio at 24 kHz and the time of each `<t:…>` span).
13
+ - `KokoroProsody`: Kokoro's predicted pitch written back as `<f0:…>` values (a Yomite tool).
14
+
15
+ Models: `models/{enc,f0n,dec}[_w16].onnx` and `voices/<voice>.bin` in one directory, on Hugging Face as
16
+ [receptron/yomiscript-kokoro](https://huggingface.co/receptron/yomiscript-kokoro) (`KOKORO_MODELS_URL`; made by
17
+ `demo/ys_web/export_split.py`, `exact_stft.py` and `quant.py`). `onnxruntime-node` is an optional peer dependency: install it
18
+ for `./node`; in the browser, pass onnxruntime-web to `Engine`.
@@ -0,0 +1,53 @@
1
+ import type { InferenceSession, Tensor } from "onnxruntime-common";
2
+ import { type Plan, type PlannedSection } from "./plan.ts";
3
+ import type { LoadBytes } from "@yomiscript/core";
4
+ export type { LoadBytes };
5
+ /** the parts of onnxruntime this engine uses (onnxruntime-web and onnxruntime-node both have them) */
6
+ export interface Ort {
7
+ InferenceSession: {
8
+ create(model: Uint8Array | ArrayBuffer, options?: InferenceSession.SessionOptions): Promise<InferenceSession>;
9
+ };
10
+ Tensor: new (type: "float32" | "int64", data: Float32Array | BigInt64Array, dims: readonly number[]) => Tensor;
11
+ }
12
+ export interface EngineOptions {
13
+ /** model file suffix per part: {} = fp32 (identical to the original Kokoro), W16 = fp16 weights */
14
+ suffix?: Partial<Record<"enc" | "f0n" | "dec", string>>;
15
+ executionProviders?: string[];
16
+ }
17
+ export declare const FP32: {}, W16: {
18
+ enc: string;
19
+ f0n: string;
20
+ dec: string;
21
+ };
22
+ /** pitch: "values" renders the YomiScript's <f0:…> values; "engine" keeps Kokoro's own F0 (the original's audio) */
23
+ export type PitchMode = "values" | "engine";
24
+ export interface Prediction {
25
+ ref: Tensor;
26
+ dur: number[];
27
+ t_en: Tensor;
28
+ f0: Float32Array;
29
+ N: Tensor;
30
+ }
31
+ export interface Synthesis {
32
+ audio: Float32Array;
33
+ plan: Plan;
34
+ }
35
+ export declare class Engine {
36
+ private V;
37
+ private enc;
38
+ private f0n;
39
+ private dec;
40
+ private ort;
41
+ private load;
42
+ constructor(ort: Ort, load: LoadBytes);
43
+ init(opts?: EngineOptions): Promise<this>;
44
+ voice(name: string): Promise<Float32Array>;
45
+ predict(sec: PlannedSection): Promise<Prediction>;
46
+ synthSection(sec: PlannedSection, pitch?: PitchMode): Promise<{
47
+ audio: Float32Array;
48
+ f0: Float32Array;
49
+ f0new: Float32Array;
50
+ dur: number[];
51
+ }>;
52
+ synth(ys: string, pitch?: PitchMode): Promise<Synthesis>;
53
+ }
package/dist/engine.js ADDED
@@ -0,0 +1,81 @@
1
+ import { plan } from "./plan.js";
2
+ import { f0Override, join } from "./render.js";
3
+ export const FP32 = {}, W16 = { enc: "_w16", f0n: "_w16", dec: "_w16" };
4
+ export class Engine {
5
+ V = {};
6
+ enc;
7
+ f0n;
8
+ dec;
9
+ ort;
10
+ load;
11
+ constructor(ort, load) {
12
+ this.ort = ort;
13
+ this.load = load;
14
+ }
15
+ async init(opts = {}) {
16
+ const sf = opts.suffix ?? {}, executionProviders = opts.executionProviders ?? ["wasm"];
17
+ const mk = async (n) => this.ort.InferenceSession.create(await this.load(`models/${n}${sf[n] ?? ""}.onnx`), { executionProviders });
18
+ [this.enc, this.f0n, this.dec] = [await mk("enc"), await mk("f0n"), await mk("dec")];
19
+ return this;
20
+ }
21
+ async voice(name) {
22
+ if (this.V[name])
23
+ return this.V[name];
24
+ const m = name.match(/^([^+]+)\+([^@]+)@([\d.]+)$/); // a blend: a+b@weight
25
+ let v;
26
+ if (m) {
27
+ const a = await this.voice(m[1]), b = await this.voice(m[2]), w = +m[3];
28
+ v = a.map((x, i) => x * (1 - w) + b[i] * w);
29
+ }
30
+ else {
31
+ const bytes = await this.load(`voices/${name}.bin`);
32
+ v =
33
+ bytes instanceof ArrayBuffer
34
+ ? new Float32Array(bytes)
35
+ : new Float32Array(bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength));
36
+ }
37
+ this.V[name] = v;
38
+ return v;
39
+ }
40
+ // Kokoro's own prosody prediction (durations, F0, energy) for one planned section; also used by the Yomite (prosody.ts)
41
+ async predict(sec) {
42
+ const T = this.ort.Tensor;
43
+ const L = sec.ids.length;
44
+ const V = await this.voice(sec.voice);
45
+ const k = (sec.ps ?? "x".repeat(L - 1)).length - 1; // voice-pack entry as in KPipeline: pack[len(ps)-1]
46
+ const ref = new T("float32", V.slice(k * 256, (k + 1) * 256), [1, 256]);
47
+ const r1 = await this.enc.run({ ids: new T("int64", BigInt64Array.from(sec.ids.map(BigInt)), [1, L]), ref });
48
+ const dur = Array.from(r1.dur.data, Number);
49
+ const Tn = dur.reduce((a, b) => a + b, 0);
50
+ const expand = (t) => {
51
+ const C = t.dims[1], src = t.data, out = new Float32Array(C * Tn);
52
+ for (let c = 0; c < C; c++) {
53
+ let q = c * Tn;
54
+ for (let l = 0; l < L; l++) {
55
+ const v = src[c * L + l];
56
+ for (let r = 0; r < dur[l]; r++)
57
+ out[q++] = v;
58
+ }
59
+ }
60
+ return new T("float32", out, [1, C, Tn]);
61
+ };
62
+ const r2 = await this.f0n.run({ en: expand(r1.d), ref });
63
+ return { ref, dur, t_en: expand(r1.t_en), f0: r2.F0.data, N: r2.N };
64
+ }
65
+ async synthSection(sec, pitch = "values") {
66
+ const T = this.ort.Tensor;
67
+ const { ref, dur, t_en, f0, N } = await this.predict(sec);
68
+ const F = pitch === "engine" ? Float32Array.from(f0) : f0Override(f0, sec.uid, dur, sec.U);
69
+ const r3 = await this.dec.run({ asr: t_en, F0: new T("float32", F, [1, F.length]), N, ref });
70
+ return { audio: Float32Array.from(r3.audio.data), f0: Float32Array.from(f0), f0new: F, dur };
71
+ }
72
+ async synth(ys, pitch = "values") {
73
+ const P = plan(ys);
74
+ const outs = [];
75
+ for (const s of P)
76
+ outs.push((await this.synthSection(s, pitch)).audio);
77
+ // one section: the model's audio as is (like the original); several language sections: joined
78
+ return { audio: outs.length === 1 ? outs[0] : join(outs), plan: P };
79
+ }
80
+ }
81
+ //# sourceMappingURL=engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAkC,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAc/C,MAAM,CAAC,MAAM,IAAI,GAAG,EAAE,EACpB,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;AAelD,MAAM,OAAO,MAAM;IACT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CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QAC7F,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAoB,CAAC,EAAE,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;IAC/G,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,EAAU,EAAE,QAAmB,QAAQ;QACjD,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;QACnB,MAAM,IAAI,GAAmB,EAAE,CAAC;QAChC,KAAK,MAAM,CAAC,IAAI,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACxE,8FAA8F;QAC9F,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IACtE,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ export * from "./plan.ts";
2
+ export * from "./render.ts";
3
+ export * from "./engine.ts";
4
+ export * from "./prosody.ts";
5
+ export { VOCAB } from "./vocab.ts";
6
+ export * from "./katarite.ts";
7
+ export * from "./models.ts";
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export * from "./plan.js";
2
+ export * from "./render.js";
3
+ export * from "./engine.js";
4
+ export * from "./prosody.js";
5
+ export { VOCAB } from "./vocab.js";
6
+ export * from "./katarite.js";
7
+ export * from "./models.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { type Katarite, type Speech } from "@yomiscript/core";
2
+ import type { Engine } from "./engine.ts";
3
+ /** audio samples per duration step of Kokoro's predictor (24 kHz, 2 frames of 300 samples) */
4
+ export declare const SAMPLES_PER_STEP = 600;
5
+ export interface KokoroOptions {
6
+ /** a voice (e.g. jm_kumo, or a blend a+b@0.3) for every section instead of each language's default */
7
+ voice?: string;
8
+ }
9
+ export declare class KokoroKatarite implements Katarite {
10
+ readonly name = "kokoro";
11
+ readonly languages: readonly ["ja", "en", "fr", "zh"];
12
+ private E;
13
+ private voice?;
14
+ constructor(engine: Engine, options?: KokoroOptions);
15
+ speak(ys: string): Promise<Speech>;
16
+ }
@@ -0,0 +1,47 @@
1
+ // The Kokoro Katarite behind the shared interface (core's Katarite): YomiScript in, audio and span times out.
2
+ import { parse } from "@yomiscript/core";
3
+ import { plan, SR } from "./plan.js";
4
+ import { join } from "./render.js";
5
+ /** audio samples per duration step of Kokoro's predictor (24 kHz, 2 frames of 300 samples) */
6
+ export const SAMPLES_PER_STEP = 600;
7
+ function spanTimes(sec, dur, offset) {
8
+ // a unit lasts as long as its ids; a span from its first unit's start to its last unit's end
9
+ const T = new Map();
10
+ let t = offset;
11
+ sec.uid.forEach((k, i) => {
12
+ const d = (dur[i] * SAMPLES_PER_STEP) / SR, span = k >= 0 ? sec.toks[k]?.span : undefined;
13
+ if (span !== undefined) {
14
+ const x = T.get(span);
15
+ if (x)
16
+ x.end = t + d;
17
+ else
18
+ T.set(span, { span, start: t, end: t + d });
19
+ }
20
+ t += d;
21
+ });
22
+ return [...T.values()];
23
+ }
24
+ export class KokoroKatarite {
25
+ name = "kokoro";
26
+ languages = ["ja", "en", "fr", "zh"];
27
+ E;
28
+ voice;
29
+ constructor(engine, options = {}) {
30
+ this.E = engine;
31
+ this.voice = options.voice;
32
+ }
33
+ async speak(ys) {
34
+ const P = plan(ys), audio = [], times = [];
35
+ let offset = 0;
36
+ for (const sec of P) {
37
+ if (this.voice)
38
+ sec.voice = this.voice;
39
+ const r = await this.E.synthSection(sec);
40
+ audio.push(r.audio);
41
+ times.push(...spanTimes(sec, r.dur, offset)); // several sections: approximate, join() trims and adds a gap
42
+ offset += r.audio.length / SR;
43
+ }
44
+ return { samples: audio.length === 1 ? audio[0] : join(audio), sampleRate: SR, texts: parse(ys).texts, times };
45
+ }
46
+ }
47
+ //# sourceMappingURL=katarite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"katarite.js","sourceRoot":"","sources":["../src/katarite.ts"],"names":[],"mappings":"AAAA,8GAA8G;AAC9G,OAAO,EAAE,KAAK,EAA6C,MAAM,kBAAkB,CAAC;AAEpF,OAAO,EAAE,IAAI,EAAE,EAAE,EAAuB,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,8FAA8F;AAC9F,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAEpC,SAAS,SAAS,CAAC,GAAmB,EAAE,GAAa,EAAE,MAAc;IACnE,6FAA6F;IAC7F,MAAM,CAAC,GAAG,IAAI,GAAG,EAAoB,CAAC;IACtC,IAAI,CAAC,GAAG,MAAM,CAAC;IACf,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACvB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,GAAG,EAAE,EACxC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE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,CAAC,KAAK,CAAC,CAAC;YACpB,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,6DAA6D;YAC3G,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC;QAChC,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC;IACjH,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ /** the split ONNX export and the voices on Hugging Face (models/<part>[_w16].onnx, voices/<voice>.bin) */
2
+ export declare const KOKORO_MODELS_URL = "https://huggingface.co/receptron/yomiscript-kokoro/resolve/main/";
package/dist/models.js ADDED
@@ -0,0 +1,3 @@
1
+ /** the split ONNX export and the voices on Hugging Face (models/<part>[_w16].onnx, voices/<voice>.bin) */
2
+ export const KOKORO_MODELS_URL = "https://huggingface.co/receptron/yomiscript-kokoro/resolve/main/";
3
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,MAAM,CAAC,MAAM,iBAAiB,GAAG,kEAAkE,CAAC"}
package/dist/node.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { Engine } from "./engine.ts";
2
+ export interface NodeEngineOptions {
3
+ /** directory with models/<part>[_w16].onnx and voices/<voice>.bin */
4
+ dir: string;
5
+ model?: "fp32" | "w16";
6
+ /** download missing files from here (KOKORO_MODELS_URL); none: every file must already be in dir */
7
+ download?: string;
8
+ onDownload?: (url: string) => void;
9
+ }
10
+ export declare function nodeEngine({ dir, model, download, onDownload }: NodeEngineOptions): Promise<Engine>;
package/dist/node.js ADDED
@@ -0,0 +1,10 @@
1
+ // The Kokoro Katarite in Node (CLI, MCP): onnxruntime-node and the fp32 models, identical to the original Kokoro.
2
+ // Files missing from the directory are downloaded once from Hugging Face when a download URL is given.
3
+ import * as ort from "onnxruntime-node";
4
+ import { cachedLoader } from "@yomiscript/core/node";
5
+ import { Engine, FP32, W16 } from "./engine.js";
6
+ export async function nodeEngine({ dir, model = "fp32", download, onDownload }) {
7
+ const load = cachedLoader({ dir, baseUrl: download, onDownload });
8
+ return new Engine(ort, load).init({ suffix: model === "fp32" ? FP32 : W16, executionProviders: ["cpu"] });
9
+ }
10
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,uGAAuG;AACvG,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAY,MAAM,aAAa,CAAC;AAU1D,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,EAAE,GAAG,EAAE,KAAK,GAAG,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAqB;IAC/F,MAAM,IAAI,GAAG,YAAY,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;IAClE,OAAO,IAAI,MAAM,CAAC,GAAqB,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,kBAAkB,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC9H,CAAC"}
package/dist/plan.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { type Token } from "@yomiscript/core";
2
+ export declare const SR = 24000, BLEND = 0.2;
3
+ export declare const VOICE: Readonly<Record<string, string>>;
4
+ export declare function voiceFor(top: string, l: string, x: string): string;
5
+ /** one unit of a planned section: Kokoro phonemes, pitch values (or null), accent phrase */
6
+ export type PlanUnit = [string, number[] | null, number];
7
+ export interface PlannedSection {
8
+ lang: string;
9
+ text: string;
10
+ voice: string;
11
+ /** the phoneme string Kokoro is given */
12
+ ps: string;
13
+ ids: number[];
14
+ /** the unit index of each id (-1 for BOS / EOS) */
15
+ uid: number[];
16
+ U: PlanUnit[];
17
+ toks: Token[];
18
+ }
19
+ export type Plan = PlannedSection[] & {
20
+ src: string;
21
+ };
22
+ export interface PlanOptions {
23
+ /** Japanese punctuation as the original Kokoro gets it (D22), for the parity checks */
24
+ original?: boolean;
25
+ }
26
+ export declare function plan(ys: string, opts?: PlanOptions): Plan;
package/dist/plan.js ADDED
@@ -0,0 +1,232 @@
1
+ // Katarite (Kokoro-82M): YomiScript -> what Kokoro is given. Pitch comes only from <f0:…> values; accent / stress /
2
+ // tone marks are not interpreted here (the Yomite turns them into values). What stays here is engine-specific:
3
+ // YomiScript IPA -> Kokoro's phoneme symbols and input ids, and the voice for each section.
4
+ import { parse, isJa, VOWELS } from "@yomiscript/core";
5
+ import { VOCAB } from "./vocab.js";
6
+ export const SR = 24000, BLEND = 0.2;
7
+ export const VOICE = {
8
+ ja: "jf_alpha",
9
+ "en-US": "af_heart",
10
+ "en-GB": "bf_emma",
11
+ en: "af_heart",
12
+ fr: "ff_siwis",
13
+ zh: "zf_xiaoxiao",
14
+ };
15
+ const voiceOf = (l) => {
16
+ const v = VOICE[l] ?? VOICE[l.split("-")[0]];
17
+ if (!v)
18
+ throw new Error(`this Katarite does not support language ${l}`);
19
+ return v;
20
+ };
21
+ function jaKokoro(on, v) {
22
+ // canonical Japanese YomiScript IPA -> the phoneme symbols Kokoro was trained on
23
+ on = on.replace("tɕ", "ʨ").replace("dʑ", "ʥ").replace("ts", "ʦ").replace("w", "β").replace("ʷ", "ᵝ");
24
+ if (on === "dz" || on === "ʣ")
25
+ on = "ʣ";
26
+ if (v === "i" && /^[kɡbpmɾvɸtdʦ]$/.test(on))
27
+ on += "ʲ";
28
+ if (v === "ɯ" && (/ʲ$/.test(on) || /^[ɕʥʨçsʦɲ]$/.test(on)))
29
+ v = "ɨ";
30
+ if (v === "ɯ" && on === "ʣ") {
31
+ on = "z";
32
+ v = "ɨ";
33
+ }
34
+ return on + v;
35
+ }
36
+ const FOREIGN_JA = { ɨ: "u", ɕ: "ʃ", ʑ: "ʒ", ʨ: "ʧ", ʥ: "ʤ" };
37
+ const INI = [
38
+ ["zh", "ʈʂ"],
39
+ ["ch", "ʈʂʰ"],
40
+ ["sh", "ʂ"],
41
+ ["b", "p"],
42
+ ["p", "pʰ"],
43
+ ["m", "m"],
44
+ ["f", "f"],
45
+ ["d", "t"],
46
+ ["t", "tʰ"],
47
+ ["n", "n"],
48
+ ["l", "l"],
49
+ ["g", "k"],
50
+ ["k", "kʰ"],
51
+ ["h", "x"],
52
+ ["j", "ʨ"],
53
+ ["q", "ʨʰ"],
54
+ ["x", "ɕ"],
55
+ ["r", "ɻ"],
56
+ ["z", "ʦ"],
57
+ ["c", "ʦʰ"],
58
+ ["s", "s"],
59
+ ["y", ""],
60
+ ["w", ""],
61
+ ];
62
+ const FIN = {
63
+ a: "a",
64
+ o: "wo",
65
+ e: "ɤ",
66
+ ai: "aI",
67
+ ei: "eI",
68
+ ao: "aʊ",
69
+ ou: "oʊ",
70
+ an: "an",
71
+ en: "ən",
72
+ ang: "aŋ",
73
+ eng: "əŋ",
74
+ ong: "ʊŋ",
75
+ er: "ɚ",
76
+ i: "i",
77
+ ia: "ja",
78
+ ie: "je",
79
+ iao: "jaʊ",
80
+ iu: "joʊ",
81
+ ian: "jɛn",
82
+ in: "in",
83
+ iang: "jaŋ",
84
+ ing: "iŋ",
85
+ iong: "jʊŋ",
86
+ u: "u",
87
+ ua: "wa",
88
+ uo: "wo",
89
+ uai: "waI",
90
+ ui: "weI",
91
+ uan: "wan",
92
+ un: "wən",
93
+ uang: "waŋ",
94
+ v: "y",
95
+ ue: "ɥe",
96
+ ve: "ɥe",
97
+ uan_j: "ɥɛn",
98
+ un_j: "yn",
99
+ };
100
+ const TONE = { 1: "→", 2: "↗", 3: "↓", 4: "↘", 5: "" };
101
+ function zsyl(syl) {
102
+ const m = syl.match(/^([a-zü]+)(\d)(?:>(\d))?/);
103
+ if (!m)
104
+ throw new Error(`bad pinyin syllable ${JSON.stringify(syl)}`);
105
+ const py = m[1], t = m[3] || m[2];
106
+ let ini = "", ip = "";
107
+ for (const [a, b] of INI)
108
+ if (py.startsWith(a)) {
109
+ ini = a;
110
+ ip = b;
111
+ break;
112
+ }
113
+ return ip + zhFinal(ini, py.slice(ini.length)) + TONE[t];
114
+ }
115
+ const Y_FIN = { u: "v", ue: "ve", uan: "uan_j", un: "un_j", i: "i", in: "in", ing: "ing" };
116
+ const JQX_FIN = { u: "v", ue: "ve", uan: "uan_j", un: "un_j" };
117
+ function zhFinal(ini, f) {
118
+ // the pinyin final after its initial -> Kokoro's symbols
119
+ if (ini === "y")
120
+ f = Y_FIN[f] ?? (f.startsWith("i") ? f : "i" + f);
121
+ if (ini === "w" && f !== "u")
122
+ f = "u" + f;
123
+ if (["j", "q", "x"].includes(ini) && f.startsWith("u"))
124
+ f = JQX_FIN[f];
125
+ if (f === "i" && ["z", "c", "s"].includes(ini))
126
+ return "ɹ";
127
+ if (f === "i" && ["zh", "ch", "sh", "r"].includes(ini))
128
+ return "ɻ";
129
+ return FIN[f] ?? f;
130
+ }
131
+ const KOKORO_VOWELS = "AIOQWY" + VOWELS; // after the conversion to Kokoro's symbols (A = eɪ …)
132
+ const EN_SYMBOLS = [
133
+ ["g", "ɡ"],
134
+ ["tʃ", "ʧ"],
135
+ ["dʒ", "ʤ"],
136
+ ["eɪ", "A"],
137
+ ["aɪ", "I"],
138
+ ["aʊ", "W"],
139
+ ["ɔɪ", "Y"],
140
+ ["oʊ", "O"],
141
+ ["əʊ", "Q"],
142
+ ["r", "ɹ"],
143
+ ["l̩", "ᵊl"],
144
+ ["x", "k"],
145
+ ["ɾ", "T"], // Kokoro's English flap token is T
146
+ ];
147
+ function enSyl(x, gb) {
148
+ for (const [a, b] of EN_SYMBOLS)
149
+ x = x.split(a).join(b);
150
+ x = x
151
+ .split("ɝ")
152
+ .join(gb ? "ɜː" : "ɜɹ")
153
+ .split("ɚ")
154
+ .join(gb ? "ə" : "əɹ");
155
+ let st = "";
156
+ if (x[0] === "ˈ" || x[0] === "ˌ") {
157
+ st = x[0];
158
+ x = x.slice(1);
159
+ }
160
+ if (st) {
161
+ const i = x.split("").findIndex((c) => KOKORO_VOWELS.includes(c)); // the stress mark goes before the vowel
162
+ x = i >= 0 ? x.slice(0, i) + st + x.slice(i) : st + x;
163
+ }
164
+ return x;
165
+ }
166
+ function jaPhonemes(t, foreign, original) {
167
+ // ‖ and an inner ↘ as in English (', ' and '.', D26); original: as Kokoro's Japanese front end (misaki Cutlet)
168
+ // writes them, 。 and 、 leave only the word space (D22)
169
+ if (t.kind === "space")
170
+ return " ";
171
+ if (t.kind === "pause")
172
+ return original ? " " : ", ";
173
+ if (t.kind === "end" || t.kind === "punct")
174
+ return t.sym === "." && (t.kind === "end" || (original && t.sent)) ? "" : (t.sym ?? "");
175
+ let p = t.ipa ?? "";
176
+ if (t.mk === "mora")
177
+ p = jaKokoro(t.on ?? "", t.v ?? "");
178
+ else if (t.mk === "Q")
179
+ p = "ʔ";
180
+ return foreign ? [...p].map((c) => FOREIGN_JA[c] ?? c).join("") : p;
181
+ }
182
+ function kokoroPhonemes(lang, t, foreign, original) {
183
+ if (isJa(lang))
184
+ return jaPhonemes(t, foreign, original);
185
+ if (t.kind === "space")
186
+ return " ";
187
+ if (t.kind === "pause")
188
+ return ", ";
189
+ if (t.kind === "end" || t.kind === "punct")
190
+ return t.sym ?? "";
191
+ const raw = t.raw ?? "";
192
+ if (lang === "zh" || lang.startsWith("zh-"))
193
+ return zsyl(raw);
194
+ if (lang === "fr" || lang.startsWith("fr-"))
195
+ return raw.replace(/g/g, "ɡ"); // IPA: g = ɡ
196
+ return enSyl(raw, lang === "en-GB");
197
+ }
198
+ export function voiceFor(top, l, x) {
199
+ if (l === top)
200
+ return voiceOf(top);
201
+ if (x.split(/\s+/).filter(Boolean).length === 1 && (isJa(top) || !isJa(l)))
202
+ return voiceOf(l);
203
+ return `${voiceOf(top)}+${voiceOf(l)}@${BLEND}`;
204
+ }
205
+ // plan: sections with Kokoro ids + units (no ONNX); used for parity tests and synthesis
206
+ export function plan(ys, opts = {}) {
207
+ const Y = parse(ys);
208
+ const P = Y.sections.map((sec) => {
209
+ const foreign = isJa(sec.lang) && !isJa(Y.top);
210
+ const U = [], toks = [];
211
+ for (const t of sec.toks) {
212
+ if (t.kind === "bound")
213
+ continue;
214
+ U.push([kokoroPhonemes(sec.lang, t, foreign, opts.original ?? false), t.kind === "unit" && t.f0 ? [...t.f0] : null, t.ph]);
215
+ toks.push(t);
216
+ }
217
+ const ids = [0], uid = [-1];
218
+ U.forEach(([p], k) => {
219
+ for (const ch of p)
220
+ if (ch in VOCAB) {
221
+ ids.push(VOCAB[ch]);
222
+ uid.push(k);
223
+ }
224
+ });
225
+ ids.push(0);
226
+ uid.push(-1);
227
+ const ps = U.map((u) => u[0]).join("");
228
+ return { lang: sec.lang, text: sec.text, voice: voiceFor(Y.top, sec.lang, sec.text), ps, ids, uid, U, toks };
229
+ });
230
+ return Object.assign(P, { src: Y.ys });
231
+ }
232
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,+GAA+G;AAC/G,4FAA4F;AAC5F,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAc,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,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E,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC;IAC/G,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { Engine } from "./engine.ts";
2
+ export declare class KokoroProsody {
3
+ private E;
4
+ constructor(E: Engine);
5
+ realize(ys: string): Promise<string>;
6
+ }
@@ -0,0 +1,40 @@
1
+ // Kokoro's prosody prediction, used on the Yomite side: runs Kokoro's duration + F0 predictor (enc + f0n) on a
2
+ // YomiScript and writes the predicted pitch back as <f0:…> values (semitones relative to the section's mean),
3
+ // up to three points per unit (start, middle, end). Units that already carry values, and unvoiced units, are left alone.
4
+ import { applyEdits, f0Mark } from "@yomiscript/core";
5
+ import { plan } from "./plan.js";
6
+ export class KokoroProsody {
7
+ E;
8
+ // shares the Katarite engine's ONNX sessions and voices
9
+ constructor(E) {
10
+ this.E = E;
11
+ }
12
+ async realize(ys) {
13
+ const P = plan(ys), E = [];
14
+ for (const sec of P) {
15
+ const { f0, dur } = await this.E.predict(sec);
16
+ const fu = [];
17
+ dur.forEach((d, l) => {
18
+ for (let r = 0; r < d * 2; r++)
19
+ fu.push(sec.uid[l]);
20
+ });
21
+ const fr = sec.U.map(() => []);
22
+ for (let i = 0; i < Math.min(fu.length, f0.length); i++)
23
+ if (fu[i] >= 0 && f0[i] > 60)
24
+ fr[fu[i]].push(12 * Math.log2(f0[i]));
25
+ const all = sec.toks.flatMap((t, k) => (t.kind === "unit" ? fr[k] : []));
26
+ if (!all.length)
27
+ continue;
28
+ const m = all.reduce((s, v) => s + v, 0) / all.length;
29
+ sec.toks.forEach((t, k) => {
30
+ const F = fr[k];
31
+ if (t.kind !== "unit" || t.f0 || !F.length)
32
+ return;
33
+ const c = F.length >= 3 ? [F[0], F[F.length >> 1], F[F.length - 1]] : [F.reduce((s, v) => s + v, 0) / F.length];
34
+ E.push({ at: t.end ?? 0, ins: f0Mark(c.map((v) => v - m)) });
35
+ });
36
+ }
37
+ return applyEdits(P.src, E);
38
+ }
39
+ }
40
+ //# sourceMappingURL=prosody.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prosody.js","sourceRoot":"","sources":["../src/prosody.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,8GAA8G;AAC9G,yHAAyH;AACzH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAa,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,OAAO,aAAa;IAChB,CAAC,CAAS;IAClB,wDAAwD;IACxD,YAAY,CAAS;QACnB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACb,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,EAAU;QACtB,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,EAChB,CAAC,GAAW,EAAE,CAAC;QACjB,KAAK,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;YACpB,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,MAAM,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC9C,MAAM,EAAE,GAAa,EAAE,CAAC;YACxB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;gBACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;oBAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YACtD,CAAC,CAAC,CAAC;YACH,MAAM,EAAE,GAAe,GAAG,CAAC,CAAC,CA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AAC,CAAC,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;gBAChH,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAC/D,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,UAAU,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC9B,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import { type PlanUnit } from "./plan.ts";
2
+ export declare function f0Override(f0: ArrayLike<number>, uid: number[], dur: number[], U: PlanUnit[], smooth?: number, dstep?: number): Float32Array;
3
+ export declare function join(P: Float32Array[]): Float32Array;
4
+ export declare function wav(a: Float32Array, sr?: number): ArrayBuffer;
package/dist/render.js ADDED
@@ -0,0 +1,150 @@
1
+ // Audio-side rendering, engine-independent: the YomiScript's pitch values put into the engine's F0, joining the
2
+ // audio of several language sections, and WAV encoding.
3
+ import { SR } from "./plan.js";
4
+ const mean = (a) => a.reduce((s, v) => s + v, 0) / a.length;
5
+ function unitFrames(uid, dur, n) {
6
+ // the unit index of each F0 frame (2 frames per duration step), -1 for BOS / EOS
7
+ const fu = [];
8
+ dur.forEach((d, l) => {
9
+ for (let r = 0; r < d * 2; r++)
10
+ fu.push(uid[l]);
11
+ });
12
+ fu.length = Math.min(fu.length, n);
13
+ return fu;
14
+ }
15
+ function valueAt(c, x) {
16
+ // a unit's contour c (points spread evenly) at position x in [0, 1]
17
+ if (c.length === 1)
18
+ return c[0];
19
+ const pos = x * (c.length - 1), a = Math.min(Math.floor(pos), c.length - 2);
20
+ return c[a] + (c[a + 1] - c[a]) * (pos - a);
21
+ }
22
+ function frameTargets(fu, U, n, dstep) {
23
+ // semitone target per frame from the units' values, lowered by dstep per phrase (declination)
24
+ const st = new Float64Array(n).fill(NaN);
25
+ U.forEach(([, c, ph], k) => {
26
+ if (c === null)
27
+ return;
28
+ const fr = [];
29
+ for (let i = 0; i < fu.length; i++)
30
+ if (fu[i] === k)
31
+ fr.push(i);
32
+ fr.forEach((i, j) => (st[i] = valueAt(c, fr.length > 1 ? j / (fr.length - 1) : 0) - dstep * ph));
33
+ });
34
+ return st;
35
+ }
36
+ function anchorPhrases(st, f0, fu, U) {
37
+ // values are relative: each phrase keeps its shape and takes the mean level of the engine's own F0 there
38
+ const n = f0.length, lo = Array.from(f0, (v) => Math.log2(Math.max(v, 1)) * 12);
39
+ const phr = Array.from({ length: n }, (_, i) => (i < fu.length && fu[i] >= 0 ? U[fu[i]][2] : -1));
40
+ const ok = Array.from({ length: n }, (_, i) => !isNaN(st[i]) && f0[i] > 60);
41
+ const tgt = new Float64Array(n).fill(NaN);
42
+ for (const ph of new Set(phr.filter((_, i) => ok[i]))) {
43
+ const sel = [];
44
+ for (let i = 0; i < n; i++)
45
+ if (ok[i] && phr[i] === ph)
46
+ sel.push(i);
47
+ const ms = mean(sel.map((i) => st[i])), ml = mean(sel.map((i) => lo[i]));
48
+ for (const i of sel)
49
+ tgt[i] = st[i] - ms + ml;
50
+ }
51
+ return tgt;
52
+ }
53
+ function interpolate(tgt, xs) {
54
+ // fill the frames between targets linearly, and hold the first / last target outside them
55
+ const n = tgt.length, full = new Float64Array(n);
56
+ let q = 0;
57
+ for (let i = 0; i < n; i++) {
58
+ if (i <= xs[0])
59
+ full[i] = tgt[xs[0]];
60
+ else if (i >= xs[xs.length - 1])
61
+ full[i] = tgt[xs[xs.length - 1]];
62
+ else {
63
+ while (xs[q + 1] < i)
64
+ q++;
65
+ const a = xs[q], b = xs[q + 1];
66
+ full[i] = tgt[a] + ((tgt[b] - tgt[a]) * (i - a)) / (b - a);
67
+ }
68
+ }
69
+ return full;
70
+ }
71
+ function movingAverage(full, smooth) {
72
+ const n = full.length, h = smooth >> 1, sm = new Float64Array(n);
73
+ for (let i = 0; i < n; i++) {
74
+ let s = 0;
75
+ for (let j = -h; j <= h; j++)
76
+ s += full[Math.min(n - 1, Math.max(0, i + j))];
77
+ sm[i] = s / smooth;
78
+ }
79
+ return sm;
80
+ }
81
+ // the engine's F0 with the YomiScript's pitch values put in (frames without a value keep the engine's F0)
82
+ export function f0Override(f0, uid, dur, U, smooth = 5, dstep = 0.6) {
83
+ const fu = unitFrames(uid, dur, f0.length);
84
+ const tgt = anchorPhrases(frameTargets(fu, U, f0.length, dstep), f0, fu, U);
85
+ const xs = [];
86
+ for (let i = 0; i < f0.length; i++)
87
+ if (!isNaN(tgt[i]))
88
+ xs.push(i);
89
+ if (!xs.length)
90
+ return Float32Array.from(f0);
91
+ const sm = movingAverage(interpolate(tgt, xs), smooth);
92
+ return Float32Array.from(f0, (v, i) => (isNaN(tgt[i]) ? v : 2 ** (sm[i] / 12)));
93
+ }
94
+ const rms = (a) => Math.sqrt(a.reduce((s, v) => s + v * v, 0) / a.length);
95
+ function trim(a, lead = true, th = 0.01) {
96
+ let i0 = -1, i1 = -1;
97
+ for (let i = 0; i < a.length; i++)
98
+ if (Math.abs(a[i]) > th) {
99
+ if (i0 < 0)
100
+ i0 = i;
101
+ i1 = i;
102
+ }
103
+ if (i0 < 0)
104
+ return a;
105
+ return a.slice(lead ? Math.max(i0 - 240, 0) : 0, Math.min(a.length, i1 + 480));
106
+ }
107
+ // the audio of several sections as one: trimmed, level-matched, crossfaded, with a short gap
108
+ export function join(P) {
109
+ const tgt = rms(P[0]);
110
+ let out = Float32Array.from(trim(P[0], false));
111
+ const n = Math.round(0.015 * SR), gap = Math.round(0.06 * SR);
112
+ for (const p0 of P.slice(1)) {
113
+ const g = tgt / Math.max(rms(p0), 1e-6);
114
+ const p = Float32Array.from(trim(p0), (v) => v * g);
115
+ for (let i = 0; i < n && i < out.length; i++)
116
+ out[out.length - n + i] *= 1 - i / (n - 1);
117
+ for (let i = 0; i < n && i < p.length; i++)
118
+ p[i] *= i / (n - 1);
119
+ const o = new Float32Array(out.length + gap + p.length);
120
+ o.set(out);
121
+ o.set(p, out.length + gap);
122
+ out = o;
123
+ }
124
+ let mx = 0;
125
+ for (const v of out)
126
+ mx = Math.max(mx, Math.abs(v));
127
+ const k = Math.max(1, mx / 0.95);
128
+ return out.map((v) => v / k);
129
+ }
130
+ // 16-bit mono WAV
131
+ export function wav(a, sr = SR) {
132
+ const b = new ArrayBuffer(44 + a.length * 2), d = new DataView(b);
133
+ const w = (o, s) => [...s].forEach((c, i) => d.setUint8(o + i, c.charCodeAt(0)));
134
+ w(0, "RIFF");
135
+ d.setUint32(4, 36 + a.length * 2, true);
136
+ w(8, "WAVE");
137
+ w(12, "fmt ");
138
+ d.setUint32(16, 16, true);
139
+ d.setUint16(20, 1, true);
140
+ d.setUint16(22, 1, true);
141
+ d.setUint32(24, sr, true);
142
+ d.setUint32(28, sr * 2, true);
143
+ d.setUint16(32, 2, true);
144
+ d.setUint16(34, 16, true);
145
+ w(36, "data");
146
+ d.setUint32(40, a.length * 2, true);
147
+ a.forEach((v, i) => d.setInt16(44 + i * 2, Math.max(-1, Math.min(1, v)) * 32767, true));
148
+ return b;
149
+ }
150
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,wDAAwD;AACxD,OAAO,EAAE,EAAE,EAAiB,MAAM,WAAW,CAAC;AAE9C,MAAM,IAAI,GAAG,CAAC,CAAW,EAAU,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAA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
package/dist/vocab.js ADDED
@@ -0,0 +1,118 @@
1
+ // Kokoro-82M's phoneme vocabulary (symbol -> input id), from the model's config.json.
2
+ export const VOCAB = {
3
+ ";": 1,
4
+ ":": 2,
5
+ ",": 3,
6
+ ".": 4,
7
+ "!": 5,
8
+ "?": 6,
9
+ "—": 9,
10
+ "…": 10,
11
+ '"': 11,
12
+ "(": 12,
13
+ ")": 13,
14
+ "“": 14,
15
+ "”": 15,
16
+ " ": 16,
17
+ "̃": 17,
18
+ ʣ: 18,
19
+ ʥ: 19,
20
+ ʦ: 20,
21
+ ʨ: 21,
22
+ ᵝ: 22,
23
+ "ꭧ": 23,
24
+ A: 24,
25
+ I: 25,
26
+ O: 31,
27
+ Q: 33,
28
+ S: 35,
29
+ T: 36,
30
+ W: 39,
31
+ Y: 41,
32
+ ᵊ: 42,
33
+ a: 43,
34
+ b: 44,
35
+ c: 45,
36
+ d: 46,
37
+ e: 47,
38
+ f: 48,
39
+ h: 50,
40
+ i: 51,
41
+ j: 52,
42
+ k: 53,
43
+ l: 54,
44
+ m: 55,
45
+ n: 56,
46
+ o: 57,
47
+ p: 58,
48
+ q: 59,
49
+ r: 60,
50
+ s: 61,
51
+ t: 62,
52
+ u: 63,
53
+ v: 64,
54
+ w: 65,
55
+ x: 66,
56
+ y: 67,
57
+ z: 68,
58
+ ɑ: 69,
59
+ ɐ: 70,
60
+ ɒ: 71,
61
+ æ: 72,
62
+ β: 75,
63
+ ɔ: 76,
64
+ ɕ: 77,
65
+ ç: 78,
66
+ ɖ: 80,
67
+ ð: 81,
68
+ ʤ: 82,
69
+ ə: 83,
70
+ ɚ: 85,
71
+ ɛ: 86,
72
+ ɜ: 87,
73
+ ɟ: 90,
74
+ ɡ: 92,
75
+ ɥ: 99,
76
+ ɨ: 101,
77
+ ɪ: 102,
78
+ ʝ: 103,
79
+ ɯ: 110,
80
+ ɰ: 111,
81
+ ŋ: 112,
82
+ ɳ: 113,
83
+ ɲ: 114,
84
+ ɴ: 115,
85
+ ø: 116,
86
+ ɸ: 118,
87
+ θ: 119,
88
+ œ: 120,
89
+ ɹ: 123,
90
+ ɾ: 125,
91
+ ɻ: 126,
92
+ ʁ: 128,
93
+ ɽ: 129,
94
+ ʂ: 130,
95
+ ʃ: 131,
96
+ ʈ: 132,
97
+ ʧ: 133,
98
+ ʊ: 135,
99
+ ʋ: 136,
100
+ ʌ: 138,
101
+ ɣ: 139,
102
+ ɤ: 140,
103
+ χ: 142,
104
+ ʎ: 143,
105
+ ʒ: 147,
106
+ ʔ: 148,
107
+ ˈ: 156,
108
+ ˌ: 157,
109
+ ː: 158,
110
+ ʰ: 162,
111
+ ʲ: 164,
112
+ "↓": 169,
113
+ "→": 171,
114
+ "↗": 172,
115
+ "↘": 173,
116
+ ᵻ: 177,
117
+ };
118
+ //# sourceMappingURL=vocab.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocab.js","sourceRoot":"","sources":["../src/vocab.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,MAAM,CAAC,MAAM,KAAK,GAAqC;IACrD,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,EAAE;IACP,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,GAAG,EAAE,EAAE;IACP,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,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C,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,CAAC,EAAE,GAAG;CACP,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@yomiscript/kokoro",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Kokoro-82M Katarite: YomiScript -> Kokoro input -> audio (onnxruntime-web w16 in the browser, onnxruntime-node fp32 in Node)",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/receptron/yomiscript.git",
9
+ "directory": "packages/kokoro"
10
+ },
11
+ "homepage": "https://github.com/receptron/yomiscript/tree/main/packages/kokoro#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/receptron/yomiscript/issues"
14
+ },
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js"
20
+ },
21
+ "./node": {
22
+ "types": "./dist/node.d.ts",
23
+ "import": "./dist/node.js"
24
+ }
25
+ },
26
+ "types": "./dist/index.d.ts",
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "scripts": {
34
+ "build": "tsc -p tsconfig.json",
35
+ "prepack": "yarn --cwd ../.. build && node ../../tools/prepack.mjs"
36
+ },
37
+ "dependencies": {
38
+ "@yomiscript/core": "^0.1.0",
39
+ "onnxruntime-common": "1.22.0"
40
+ },
41
+ "peerDependencies": {
42
+ "onnxruntime-node": "1.22.0"
43
+ },
44
+ "peerDependenciesMeta": {
45
+ "onnxruntime-node": {
46
+ "optional": true
47
+ }
48
+ },
49
+ "devDependencies": {
50
+ "onnxruntime-node": "1.22.0"
51
+ }
52
+ }