samiam-rs 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/samiam.d.ts +14 -1
- package/samiam.js +84 -13
- package/samiam_bg.wasm +0 -0
package/package.json
CHANGED
package/samiam.d.ts
CHANGED
|
@@ -12,9 +12,14 @@ export class Voice {
|
|
|
12
12
|
constructor();
|
|
13
13
|
speak(text: string): Float32Array;
|
|
14
14
|
wav(text: string): Uint8Array;
|
|
15
|
+
cutoff: number;
|
|
15
16
|
pitch: number;
|
|
16
17
|
sample_rate: number;
|
|
18
|
+
get source(): Float32Array;
|
|
19
|
+
set source(value: Float32Array | number[]);
|
|
17
20
|
speed: number;
|
|
21
|
+
tract: number;
|
|
22
|
+
width: number;
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
export function phonemes(text: string): string;
|
|
@@ -23,12 +28,20 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
23
28
|
|
|
24
29
|
export interface InitOutput {
|
|
25
30
|
readonly memory: WebAssembly.Memory;
|
|
31
|
+
readonly __wbg_get_voice_cutoff: (a: number) => number;
|
|
26
32
|
readonly __wbg_get_voice_pitch: (a: number) => number;
|
|
27
33
|
readonly __wbg_get_voice_sample_rate: (a: number) => number;
|
|
34
|
+
readonly __wbg_get_voice_source: (a: number) => [number, number];
|
|
28
35
|
readonly __wbg_get_voice_speed: (a: number) => number;
|
|
36
|
+
readonly __wbg_get_voice_tract: (a: number) => number;
|
|
37
|
+
readonly __wbg_get_voice_width: (a: number) => number;
|
|
38
|
+
readonly __wbg_set_voice_cutoff: (a: number, b: number) => void;
|
|
29
39
|
readonly __wbg_set_voice_pitch: (a: number, b: number) => void;
|
|
30
40
|
readonly __wbg_set_voice_sample_rate: (a: number, b: number) => void;
|
|
41
|
+
readonly __wbg_set_voice_source: (a: number, b: number, c: number) => void;
|
|
31
42
|
readonly __wbg_set_voice_speed: (a: number, b: number) => void;
|
|
43
|
+
readonly __wbg_set_voice_tract: (a: number, b: number) => void;
|
|
44
|
+
readonly __wbg_set_voice_width: (a: number, b: number) => void;
|
|
32
45
|
readonly __wbg_voice_free: (a: number, b: number) => void;
|
|
33
46
|
readonly phonemes: (a: number, b: number) => [number, number];
|
|
34
47
|
readonly voice_cues: (a: number, b: number, c: number) => [number, number];
|
|
@@ -36,9 +49,9 @@ export interface InitOutput {
|
|
|
36
49
|
readonly voice_speak: (a: number, b: number, c: number) => [number, number];
|
|
37
50
|
readonly voice_wav: (a: number, b: number, c: number) => [number, number];
|
|
38
51
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
52
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
39
53
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
40
54
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
41
|
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
42
55
|
readonly __wbindgen_start: () => void;
|
|
43
56
|
}
|
|
44
57
|
|
package/samiam.js
CHANGED
|
@@ -11,6 +11,13 @@ export class Voice {
|
|
|
11
11
|
const ptr = this.__destroy_into_raw();
|
|
12
12
|
wasm.__wbg_voice_free(ptr, 0);
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* @returns {number}
|
|
16
|
+
*/
|
|
17
|
+
get cutoff() {
|
|
18
|
+
const ret = wasm.__wbg_get_voice_cutoff(this.__wbg_ptr);
|
|
19
|
+
return ret;
|
|
20
|
+
}
|
|
14
21
|
/**
|
|
15
22
|
* @returns {number}
|
|
16
23
|
*/
|
|
@@ -25,6 +32,15 @@ export class Voice {
|
|
|
25
32
|
const ret = wasm.__wbg_get_voice_sample_rate(this.__wbg_ptr);
|
|
26
33
|
return ret >>> 0;
|
|
27
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* @returns {Float32Array}
|
|
37
|
+
*/
|
|
38
|
+
get source() {
|
|
39
|
+
const ret = wasm.__wbg_get_voice_source(this.__wbg_ptr);
|
|
40
|
+
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
41
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
42
|
+
return v1;
|
|
43
|
+
}
|
|
28
44
|
/**
|
|
29
45
|
* @returns {number}
|
|
30
46
|
*/
|
|
@@ -32,6 +48,26 @@ export class Voice {
|
|
|
32
48
|
const ret = wasm.__wbg_get_voice_speed(this.__wbg_ptr);
|
|
33
49
|
return ret;
|
|
34
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* @returns {number}
|
|
53
|
+
*/
|
|
54
|
+
get tract() {
|
|
55
|
+
const ret = wasm.__wbg_get_voice_tract(this.__wbg_ptr);
|
|
56
|
+
return ret;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @returns {number}
|
|
60
|
+
*/
|
|
61
|
+
get width() {
|
|
62
|
+
const ret = wasm.__wbg_get_voice_width(this.__wbg_ptr);
|
|
63
|
+
return ret;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @param {number} arg0
|
|
67
|
+
*/
|
|
68
|
+
set cutoff(arg0) {
|
|
69
|
+
wasm.__wbg_set_voice_cutoff(this.__wbg_ptr, arg0);
|
|
70
|
+
}
|
|
35
71
|
/**
|
|
36
72
|
* @param {number} arg0
|
|
37
73
|
*/
|
|
@@ -44,12 +80,32 @@ export class Voice {
|
|
|
44
80
|
set sample_rate(arg0) {
|
|
45
81
|
wasm.__wbg_set_voice_sample_rate(this.__wbg_ptr, arg0);
|
|
46
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* @param {Float32Array | number[]} arg0
|
|
85
|
+
*/
|
|
86
|
+
set source(arg0) {
|
|
87
|
+
const ptr0 = passArrayF32ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
88
|
+
const len0 = WASM_VECTOR_LEN;
|
|
89
|
+
wasm.__wbg_set_voice_source(this.__wbg_ptr, ptr0, len0);
|
|
90
|
+
}
|
|
47
91
|
/**
|
|
48
92
|
* @param {number} arg0
|
|
49
93
|
*/
|
|
50
94
|
set speed(arg0) {
|
|
51
95
|
wasm.__wbg_set_voice_speed(this.__wbg_ptr, arg0);
|
|
52
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* @param {number} arg0
|
|
99
|
+
*/
|
|
100
|
+
set tract(arg0) {
|
|
101
|
+
wasm.__wbg_set_voice_tract(this.__wbg_ptr, arg0);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* @param {number} arg0
|
|
105
|
+
*/
|
|
106
|
+
set width(arg0) {
|
|
107
|
+
wasm.__wbg_set_voice_width(this.__wbg_ptr, arg0);
|
|
108
|
+
}
|
|
53
109
|
/**
|
|
54
110
|
* Start time in seconds of each token of `phonemes(text)`, `/` between words included and a
|
|
55
111
|
* `,` added when the text ends without a pause, then the total length.
|
|
@@ -118,17 +174,16 @@ export function phonemes(text) {
|
|
|
118
174
|
function __wbg_get_imports() {
|
|
119
175
|
const import0 = {
|
|
120
176
|
__proto__: null,
|
|
121
|
-
|
|
177
|
+
__wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
|
|
122
178
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
123
179
|
},
|
|
124
180
|
__wbindgen_init_externref_table: function() {
|
|
125
181
|
const table = wasm.__wbindgen_externrefs;
|
|
126
|
-
const offset = table.grow(4);
|
|
127
182
|
table.set(0, undefined);
|
|
128
|
-
table.set(
|
|
129
|
-
table.set(
|
|
130
|
-
table.set(
|
|
131
|
-
table.set(
|
|
183
|
+
table.set(1024, undefined);
|
|
184
|
+
table.set(1025, null);
|
|
185
|
+
table.set(1026, true);
|
|
186
|
+
table.set(1027, false);
|
|
132
187
|
},
|
|
133
188
|
};
|
|
134
189
|
return {
|
|
@@ -160,7 +215,8 @@ function getFloat32ArrayMemory0() {
|
|
|
160
215
|
}
|
|
161
216
|
|
|
162
217
|
function getStringFromWasm0(ptr, len) {
|
|
163
|
-
|
|
218
|
+
ptr = ptr >>> 0;
|
|
219
|
+
return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
164
220
|
}
|
|
165
221
|
|
|
166
222
|
let cachedUint8ArrayMemory0 = null;
|
|
@@ -171,6 +227,13 @@ function getUint8ArrayMemory0() {
|
|
|
171
227
|
return cachedUint8ArrayMemory0;
|
|
172
228
|
}
|
|
173
229
|
|
|
230
|
+
function passArrayF32ToWasm0(arg, malloc) {
|
|
231
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
232
|
+
getFloat32ArrayMemory0().set(arg, ptr / 4);
|
|
233
|
+
WASM_VECTOR_LEN = arg.length;
|
|
234
|
+
return ptr;
|
|
235
|
+
}
|
|
236
|
+
|
|
174
237
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
175
238
|
if (realloc === undefined) {
|
|
176
239
|
const buf = cachedTextEncoder.encode(arg);
|
|
@@ -208,18 +271,18 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
208
271
|
return ptr;
|
|
209
272
|
}
|
|
210
273
|
|
|
211
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true
|
|
274
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
212
275
|
cachedTextDecoder.decode();
|
|
213
276
|
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
214
277
|
let numBytesDecoded = 0;
|
|
215
|
-
function decodeText(
|
|
216
|
-
numBytesDecoded +=
|
|
278
|
+
function decodeText(bytes) {
|
|
279
|
+
numBytesDecoded += bytes.length;
|
|
217
280
|
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
218
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true
|
|
281
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
219
282
|
cachedTextDecoder.decode();
|
|
220
|
-
numBytesDecoded =
|
|
283
|
+
numBytesDecoded = bytes.length;
|
|
221
284
|
}
|
|
222
|
-
return cachedTextDecoder.decode(
|
|
285
|
+
return cachedTextDecoder.decode(bytes);
|
|
223
286
|
}
|
|
224
287
|
|
|
225
288
|
const cachedTextEncoder = new TextEncoder();
|
|
@@ -307,9 +370,17 @@ function initSync(module) {
|
|
|
307
370
|
return __wbg_finalize_init(instance, module);
|
|
308
371
|
}
|
|
309
372
|
|
|
373
|
+
let __wbg_init_promise;
|
|
310
374
|
async function __wbg_init(module_or_path) {
|
|
311
375
|
if (wasm !== undefined) return wasm;
|
|
376
|
+
if (__wbg_init_promise === undefined) {
|
|
377
|
+
__wbg_init_promise = __wbg_init_once(module_or_path);
|
|
378
|
+
__wbg_init_promise.catch(() => { __wbg_init_promise = undefined; });
|
|
379
|
+
}
|
|
380
|
+
return __wbg_init_promise;
|
|
381
|
+
}
|
|
312
382
|
|
|
383
|
+
async function __wbg_init_once(module_or_path) {
|
|
313
384
|
|
|
314
385
|
if (module_or_path !== undefined) {
|
|
315
386
|
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
package/samiam_bg.wasm
CHANGED
|
Binary file
|