@onjmin/koe 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +440 -375
- package/dist/index.d.ts +432 -9
- package/dist/index.js +854 -87
- package/dist/index.js.map +1 -1
- package/dist/utautts/frame-intonation-v8.json +34590 -0
- package/dist/utautts/hts/COPYRIGHT.txt +30 -0
- package/dist/utautts/hts/README.md +11 -0
- package/dist/utautts/hts/tohoku-f01-neutral.htsvoice +0 -0
- package/dist/utautts/jpreprocess_wasm/jpreprocess_wasm.js +436 -0
- package/dist/utautts/jpreprocess_wasm/jpreprocess_wasm_bg.wasm +0 -0
- package/dist/utautts/jpreprocess_wasm/naist-jdic/char_def.bin.gz +0 -0
- package/dist/utautts/jpreprocess_wasm/naist-jdic/dict.da.gz +0 -0
- package/dist/utautts/jpreprocess_wasm/naist-jdic/dict.vals.gz +0 -0
- package/dist/utautts/jpreprocess_wasm/naist-jdic/dict.words.gz +0 -0
- package/dist/utautts/jpreprocess_wasm/naist-jdic/dict.wordsidx.gz +0 -0
- package/dist/utautts/jpreprocess_wasm/naist-jdic/matrix.mtx.gz +0 -0
- package/dist/utautts/jpreprocess_wasm/naist-jdic/metadata.json.gz +0 -0
- package/dist/utautts/jpreprocess_wasm/naist-jdic/unk.bin.gz +0 -0
- package/dist/utautts/utautts.wasm +0 -0
- package/dist/utautts/wasm_exec.js +575 -0
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
----------------------------------------------------------------------------------
|
|
2
|
+
HTS voice tohoku-f01-{angry,happy,neutral,sad}
|
|
3
|
+
Copyright(c) 2015 Intelligent Communication Network (Ito-Nose) Laboratory
|
|
4
|
+
Tohoku University.
|
|
5
|
+
|
|
6
|
+
tohoku-f01 is released by Intelligent Communication Network Laboratory, Tohoku University.
|
|
7
|
+
Some rights reserved.
|
|
8
|
+
|
|
9
|
+
This work is licensed under the Creative Commons Attribution 4.0 license (CC-BY 4.0).
|
|
10
|
+
----------------------------------------------------------------------------------
|
|
11
|
+
This is a human-readable summary of (and not a substitute for) the license.
|
|
12
|
+
|
|
13
|
+
You are free to:
|
|
14
|
+
|
|
15
|
+
Share — copy and redistribute the material in any medium or format
|
|
16
|
+
Adapt — remix, transform, and build upon the material
|
|
17
|
+
for any purpose, even commercially.
|
|
18
|
+
The licensor cannot revoke these freedoms as long as you follow the license terms.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
Under the following terms:
|
|
22
|
+
|
|
23
|
+
Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
|
|
24
|
+
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Notices:
|
|
28
|
+
|
|
29
|
+
You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.
|
|
30
|
+
No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# HTS voice tohoku-f01
|
|
2
|
+
Copyright (c) 2015 Intelligent Communication Network (Ito-Nose) Laboratory, Tohoku University.
|
|
3
|
+
|
|
4
|
+
tohoku-f01 is released by Intelligent Communication Network Laboratory, Tohoku University.
|
|
5
|
+
tohoku-f01 is made from Japanese female voice with four emotions {angry, happy, neutral, sad}.
|
|
6
|
+
|
|
7
|
+
HTS voice tohoku-f01 is licensed under the [Creative Commons Attributions 4.0](http://creativecommons.org/licenses/by/4.0/).
|
|
8
|
+
|
|
9
|
+
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="creativecommonslicense4.0" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />
|
|
10
|
+
|
|
11
|
+
Please see COPYRIGHT.txt.
|
|
Binary file
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
/* @ts-self-types="./jpreprocess_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* テキストから HTS が生成する音素長と F0 曲線を取り出す (JSON 文字列)。
|
|
5
|
+
* `speed` は話速 (1.0 が標準、大きいほど速い)。波形は生成しない。
|
|
6
|
+
* `gv_weight` は F0 の GV (global variance) 重み。省略時は音声モデルの既定値
|
|
7
|
+
* (hts_engine と同じ 1.0)。大きいほど音高の山谷が強調され、0 で GV 無効。
|
|
8
|
+
*
|
|
9
|
+
* 出力: `{frame_ms, sample_rate, phonemes: [{phone, start_ms, duration_ms}], f0_hz: [...]}`。
|
|
10
|
+
* 先頭と末尾の `sil`、句読点の `pau` も音素として含む。
|
|
11
|
+
* @param {string} text
|
|
12
|
+
* @param {number} speed
|
|
13
|
+
* @param {number | null} [gv_weight]
|
|
14
|
+
* @returns {string}
|
|
15
|
+
*/
|
|
16
|
+
export function analyze_prosody(text, speed, gv_weight) {
|
|
17
|
+
let deferred3_0;
|
|
18
|
+
let deferred3_1;
|
|
19
|
+
try {
|
|
20
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
21
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
22
|
+
const len0 = WASM_VECTOR_LEN;
|
|
23
|
+
wasm.analyze_prosody(retptr, ptr0, len0, speed, !isLikeNone(gv_weight), isLikeNone(gv_weight) ? 0 : gv_weight);
|
|
24
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
25
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
26
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
27
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
28
|
+
var ptr2 = r0;
|
|
29
|
+
var len2 = r1;
|
|
30
|
+
if (r3) {
|
|
31
|
+
ptr2 = 0; len2 = 0;
|
|
32
|
+
throw takeObject(r2);
|
|
33
|
+
}
|
|
34
|
+
deferred3_0 = ptr2;
|
|
35
|
+
deferred3_1 = len2;
|
|
36
|
+
return getStringFromWasm0(ptr2, len2);
|
|
37
|
+
} finally {
|
|
38
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
39
|
+
wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* テキストを NJD ノード列 (JSON 文字列) にする。各ノードは
|
|
45
|
+
* `{string, pos, pos_group1, pron, read, acc, mora_size, chain_flag}`。
|
|
46
|
+
* 半角英数などは naist-jdic 向けに全角へ正規化してから解析する。
|
|
47
|
+
*
|
|
48
|
+
* Open JTalk と同じ NJD 前処理 (読みの補完、数字列の読み、アクセント句の連結、
|
|
49
|
+
* アクセント型、無声化) を掛けてから返す。`extract_fullcontext` / `analyze_prosody`
|
|
50
|
+
* が見るモーラ列と一致させるためで、これが無いと「2024年」「koe」のような
|
|
51
|
+
* 数字・英字を含む文で HTS 韻律とモーラ数が食い違い、整列に失敗する。
|
|
52
|
+
* @param {string} text
|
|
53
|
+
* @returns {string}
|
|
54
|
+
*/
|
|
55
|
+
export function analyze_text(text) {
|
|
56
|
+
let deferred3_0;
|
|
57
|
+
let deferred3_1;
|
|
58
|
+
try {
|
|
59
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
60
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
61
|
+
const len0 = WASM_VECTOR_LEN;
|
|
62
|
+
wasm.analyze_text(retptr, ptr0, len0);
|
|
63
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
64
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
65
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
66
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
67
|
+
var ptr2 = r0;
|
|
68
|
+
var len2 = r1;
|
|
69
|
+
if (r3) {
|
|
70
|
+
ptr2 = 0; len2 = 0;
|
|
71
|
+
throw takeObject(r2);
|
|
72
|
+
}
|
|
73
|
+
deferred3_0 = ptr2;
|
|
74
|
+
deferred3_1 = len2;
|
|
75
|
+
return getStringFromWasm0(ptr2, len2);
|
|
76
|
+
} finally {
|
|
77
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
78
|
+
wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* HTS フルコンテキストラベル (Open JTalk と同じ書式) を 1 音素 1 行で返す。デバッグ用。
|
|
84
|
+
* @param {string} text
|
|
85
|
+
* @returns {string[]}
|
|
86
|
+
*/
|
|
87
|
+
export function extract_fullcontext(text) {
|
|
88
|
+
try {
|
|
89
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
90
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
91
|
+
const len0 = WASM_VECTOR_LEN;
|
|
92
|
+
wasm.extract_fullcontext(retptr, ptr0, len0);
|
|
93
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
94
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
95
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
96
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
97
|
+
if (r3) {
|
|
98
|
+
throw takeObject(r2);
|
|
99
|
+
}
|
|
100
|
+
var v2 = getArrayJsValueFromWasm0(r0, r1);
|
|
101
|
+
wasm.__wbindgen_export3(r0, r1 * 4, 4);
|
|
102
|
+
return v2;
|
|
103
|
+
} finally {
|
|
104
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 辞書ファイルの生バイト列から解析器を構築する。引数は naist-jdic のビルド成果物と同じ名前。
|
|
110
|
+
* 呼び出し後は `analyze_text` が使えるようになる。再呼び出しで辞書を差し替えられる。
|
|
111
|
+
* @param {Uint8Array} metadata
|
|
112
|
+
* @param {Uint8Array} char_def
|
|
113
|
+
* @param {Uint8Array} matrix
|
|
114
|
+
* @param {Uint8Array} dict_da
|
|
115
|
+
* @param {Uint8Array} dict_vals
|
|
116
|
+
* @param {Uint8Array} unk
|
|
117
|
+
* @param {Uint8Array} words_idx
|
|
118
|
+
* @param {Uint8Array} words
|
|
119
|
+
*/
|
|
120
|
+
export function init_dictionary(metadata, char_def, matrix, dict_da, dict_vals, unk, words_idx, words) {
|
|
121
|
+
try {
|
|
122
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
123
|
+
const ptr0 = passArray8ToWasm0(metadata, wasm.__wbindgen_export);
|
|
124
|
+
const len0 = WASM_VECTOR_LEN;
|
|
125
|
+
const ptr1 = passArray8ToWasm0(char_def, wasm.__wbindgen_export);
|
|
126
|
+
const len1 = WASM_VECTOR_LEN;
|
|
127
|
+
const ptr2 = passArray8ToWasm0(matrix, wasm.__wbindgen_export);
|
|
128
|
+
const len2 = WASM_VECTOR_LEN;
|
|
129
|
+
const ptr3 = passArray8ToWasm0(dict_da, wasm.__wbindgen_export);
|
|
130
|
+
const len3 = WASM_VECTOR_LEN;
|
|
131
|
+
const ptr4 = passArray8ToWasm0(dict_vals, wasm.__wbindgen_export);
|
|
132
|
+
const len4 = WASM_VECTOR_LEN;
|
|
133
|
+
const ptr5 = passArray8ToWasm0(unk, wasm.__wbindgen_export);
|
|
134
|
+
const len5 = WASM_VECTOR_LEN;
|
|
135
|
+
const ptr6 = passArray8ToWasm0(words_idx, wasm.__wbindgen_export);
|
|
136
|
+
const len6 = WASM_VECTOR_LEN;
|
|
137
|
+
const ptr7 = passArray8ToWasm0(words, wasm.__wbindgen_export);
|
|
138
|
+
const len7 = WASM_VECTOR_LEN;
|
|
139
|
+
wasm.init_dictionary(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7);
|
|
140
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
141
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
142
|
+
if (r1) {
|
|
143
|
+
throw takeObject(r0);
|
|
144
|
+
}
|
|
145
|
+
} finally {
|
|
146
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* HTS 音声モデル (.htsvoice の生バイト列) を読み込む。`analyze_prosody` の前に一度呼ぶ。
|
|
152
|
+
* @param {Uint8Array} htsvoice
|
|
153
|
+
*/
|
|
154
|
+
export function init_voice(htsvoice) {
|
|
155
|
+
try {
|
|
156
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
157
|
+
const ptr0 = passArray8ToWasm0(htsvoice, wasm.__wbindgen_export);
|
|
158
|
+
const len0 = WASM_VECTOR_LEN;
|
|
159
|
+
wasm.init_voice(retptr, ptr0, len0);
|
|
160
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
161
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
162
|
+
if (r1) {
|
|
163
|
+
throw takeObject(r0);
|
|
164
|
+
}
|
|
165
|
+
} finally {
|
|
166
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* 辞書が読み込まれ `analyze_text` が呼べる状態かを返す。
|
|
172
|
+
* @returns {boolean}
|
|
173
|
+
*/
|
|
174
|
+
export function is_ready() {
|
|
175
|
+
const ret = wasm.is_ready();
|
|
176
|
+
return ret !== 0;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* HTS 音声モデルが読み込まれ `analyze_prosody` が呼べる状態かを返す。
|
|
181
|
+
* @returns {boolean}
|
|
182
|
+
*/
|
|
183
|
+
export function is_voice_ready() {
|
|
184
|
+
const ret = wasm.is_voice_ready();
|
|
185
|
+
return ret !== 0;
|
|
186
|
+
}
|
|
187
|
+
function __wbg_get_imports() {
|
|
188
|
+
const import0 = {
|
|
189
|
+
__proto__: null,
|
|
190
|
+
__wbg_Error_67e7344beaa85059: function(arg0, arg1) {
|
|
191
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
192
|
+
return addHeapObject(ret);
|
|
193
|
+
},
|
|
194
|
+
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
195
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
196
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
197
|
+
return addHeapObject(ret);
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
return {
|
|
201
|
+
__proto__: null,
|
|
202
|
+
"./jpreprocess_wasm_bg.js": import0,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function addHeapObject(obj) {
|
|
207
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
208
|
+
const idx = heap_next;
|
|
209
|
+
heap_next = heap[idx];
|
|
210
|
+
|
|
211
|
+
heap[idx] = obj;
|
|
212
|
+
return idx;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function dropObject(idx) {
|
|
216
|
+
if (idx < 1028) return;
|
|
217
|
+
heap[idx] = heap_next;
|
|
218
|
+
heap_next = idx;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
222
|
+
ptr = ptr >>> 0;
|
|
223
|
+
const mem = getDataViewMemory0();
|
|
224
|
+
const result = [];
|
|
225
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
226
|
+
result.push(takeObject(mem.getUint32(i, true)));
|
|
227
|
+
}
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
let cachedDataViewMemory0 = null;
|
|
232
|
+
function getDataViewMemory0() {
|
|
233
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
234
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
235
|
+
}
|
|
236
|
+
return cachedDataViewMemory0;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function getStringFromWasm0(ptr, len) {
|
|
240
|
+
return decodeText(ptr >>> 0, len);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
let cachedUint8ArrayMemory0 = null;
|
|
244
|
+
function getUint8ArrayMemory0() {
|
|
245
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
246
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
247
|
+
}
|
|
248
|
+
return cachedUint8ArrayMemory0;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function getObject(idx) { return heap[idx]; }
|
|
252
|
+
|
|
253
|
+
let heap = new Array(1024).fill(undefined);
|
|
254
|
+
heap.push(undefined, null, true, false);
|
|
255
|
+
|
|
256
|
+
let heap_next = heap.length;
|
|
257
|
+
|
|
258
|
+
function isLikeNone(x) {
|
|
259
|
+
return x === undefined || x === null;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
263
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
264
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
265
|
+
WASM_VECTOR_LEN = arg.length;
|
|
266
|
+
return ptr;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
270
|
+
if (realloc === undefined) {
|
|
271
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
272
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
273
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
274
|
+
WASM_VECTOR_LEN = buf.length;
|
|
275
|
+
return ptr;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
let len = arg.length;
|
|
279
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
280
|
+
|
|
281
|
+
const mem = getUint8ArrayMemory0();
|
|
282
|
+
|
|
283
|
+
let offset = 0;
|
|
284
|
+
|
|
285
|
+
for (; offset < len; offset++) {
|
|
286
|
+
const code = arg.charCodeAt(offset);
|
|
287
|
+
if (code > 0x7F) break;
|
|
288
|
+
mem[ptr + offset] = code;
|
|
289
|
+
}
|
|
290
|
+
if (offset !== len) {
|
|
291
|
+
if (offset !== 0) {
|
|
292
|
+
arg = arg.slice(offset);
|
|
293
|
+
}
|
|
294
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
295
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
296
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
297
|
+
|
|
298
|
+
offset += ret.written;
|
|
299
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
WASM_VECTOR_LEN = offset;
|
|
303
|
+
return ptr;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function takeObject(idx) {
|
|
307
|
+
const ret = getObject(idx);
|
|
308
|
+
dropObject(idx);
|
|
309
|
+
return ret;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
313
|
+
cachedTextDecoder.decode();
|
|
314
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
315
|
+
let numBytesDecoded = 0;
|
|
316
|
+
function decodeText(ptr, len) {
|
|
317
|
+
numBytesDecoded += len;
|
|
318
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
319
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
320
|
+
cachedTextDecoder.decode();
|
|
321
|
+
numBytesDecoded = len;
|
|
322
|
+
}
|
|
323
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const cachedTextEncoder = new TextEncoder();
|
|
327
|
+
|
|
328
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
329
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
330
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
331
|
+
view.set(buf);
|
|
332
|
+
return {
|
|
333
|
+
read: arg.length,
|
|
334
|
+
written: buf.length
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
let WASM_VECTOR_LEN = 0;
|
|
340
|
+
|
|
341
|
+
let wasmModule, wasmInstance, wasm;
|
|
342
|
+
function __wbg_finalize_init(instance, module) {
|
|
343
|
+
wasmInstance = instance;
|
|
344
|
+
wasm = instance.exports;
|
|
345
|
+
wasmModule = module;
|
|
346
|
+
cachedDataViewMemory0 = null;
|
|
347
|
+
cachedUint8ArrayMemory0 = null;
|
|
348
|
+
return wasm;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
async function __wbg_load(module, imports) {
|
|
352
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
353
|
+
if (!module.ok) {
|
|
354
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
358
|
+
try {
|
|
359
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
360
|
+
} catch (e) {
|
|
361
|
+
const validResponse = expectedResponseType(module.type);
|
|
362
|
+
|
|
363
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
364
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
365
|
+
|
|
366
|
+
} else { throw e; }
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const bytes = await module.arrayBuffer();
|
|
371
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
372
|
+
} else {
|
|
373
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
374
|
+
|
|
375
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
376
|
+
return { instance, module };
|
|
377
|
+
} else {
|
|
378
|
+
return instance;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function expectedResponseType(type) {
|
|
383
|
+
switch (type) {
|
|
384
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
385
|
+
}
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function initSync(module) {
|
|
391
|
+
if (wasm !== undefined) return wasm;
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
if (module !== undefined) {
|
|
395
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
396
|
+
({module} = module)
|
|
397
|
+
} else {
|
|
398
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const imports = __wbg_get_imports();
|
|
403
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
404
|
+
module = new WebAssembly.Module(module);
|
|
405
|
+
}
|
|
406
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
407
|
+
return __wbg_finalize_init(instance, module);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
async function __wbg_init(module_or_path) {
|
|
411
|
+
if (wasm !== undefined) return wasm;
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
if (module_or_path !== undefined) {
|
|
415
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
416
|
+
({module_or_path} = module_or_path)
|
|
417
|
+
} else {
|
|
418
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if (module_or_path === undefined) {
|
|
423
|
+
module_or_path = new URL('jpreprocess_wasm_bg.wasm', import.meta.url);
|
|
424
|
+
}
|
|
425
|
+
const imports = __wbg_get_imports();
|
|
426
|
+
|
|
427
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
428
|
+
module_or_path = fetch(module_or_path);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
432
|
+
|
|
433
|
+
return __wbg_finalize_init(instance, module);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|