@picovoice/eagle-web 0.1.1 → 0.1.2
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/dist/esm/index.js +63 -61
- package/dist/esm/index.min.js +1 -1
- package/dist/iife/index.js +63 -61
- package/dist/iife/index.min.js +1 -1
- package/dist/types/eagle.d.ts +0 -3
- package/dist/types/eagle.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/eagle.ts +26 -20
package/dist/types/eagle.d.ts
CHANGED
|
@@ -17,9 +17,6 @@ declare class EagleBase {
|
|
|
17
17
|
protected _wasmMemory: WebAssembly.Memory | undefined;
|
|
18
18
|
protected readonly _alignedAlloc: CallableFunction;
|
|
19
19
|
protected readonly _pvFree: pv_free_type;
|
|
20
|
-
protected readonly _memoryBuffer: Int16Array;
|
|
21
|
-
protected readonly _memoryBufferUint8: Uint8Array;
|
|
22
|
-
protected readonly _memoryBufferView: DataView;
|
|
23
20
|
protected readonly _functionMutex: Mutex;
|
|
24
21
|
protected static _sampleRate: number;
|
|
25
22
|
protected static _version: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eagle.d.ts","sourceRoot":"","sources":["../../src/eagle.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EACL,kBAAkB,EAClB,YAAY,EAKZ,OAAO,EACR,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAgD9E,KAAK,wBAAwB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAEpE,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;IAC3B,YAAY,EAAE,kBAAkB,CAAC;IACjC,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IAEjB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jB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,YAAY,EAAE,GAC9B,OAAO,CAAC,KAAK,CAAC;IA8BjB;;;;;;;;;OASG;IACU,OAAO,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAiExD;;;;OAIG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA4BnC;;OAEG;IACU,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;mBAOhB,SAAS;CA2H/B"}
|
package/package.json
CHANGED
package/src/eagle.ts
CHANGED
|
@@ -120,9 +120,6 @@ class EagleBase {
|
|
|
120
120
|
protected _wasmMemory: WebAssembly.Memory | undefined;
|
|
121
121
|
protected readonly _alignedAlloc: CallableFunction;
|
|
122
122
|
protected readonly _pvFree: pv_free_type;
|
|
123
|
-
protected readonly _memoryBuffer: Int16Array;
|
|
124
|
-
protected readonly _memoryBufferUint8: Uint8Array;
|
|
125
|
-
protected readonly _memoryBufferView: DataView;
|
|
126
123
|
protected readonly _functionMutex: Mutex;
|
|
127
124
|
|
|
128
125
|
protected static _sampleRate: number;
|
|
@@ -146,10 +143,6 @@ class EagleBase {
|
|
|
146
143
|
this._pvFree = handleWasm.pvFree;
|
|
147
144
|
this._pvError = handleWasm.pvError;
|
|
148
145
|
|
|
149
|
-
this._memoryBuffer = new Int16Array(handleWasm.memory.buffer);
|
|
150
|
-
this._memoryBufferUint8 = new Uint8Array(handleWasm.memory.buffer);
|
|
151
|
-
this._memoryBufferView = new DataView(handleWasm.memory.buffer);
|
|
152
|
-
|
|
153
146
|
this._functionMutex = new Mutex();
|
|
154
147
|
}
|
|
155
148
|
|
|
@@ -367,9 +360,6 @@ export class EagleProfiler extends EagleBase {
|
|
|
367
360
|
pcm.length * Int16Array.BYTES_PER_ELEMENT
|
|
368
361
|
);
|
|
369
362
|
|
|
370
|
-
const memoryBufferInt16 = new Int16Array(this._wasmMemory.buffer);
|
|
371
|
-
memoryBufferInt16.set(pcm, pcmAddress / Int16Array.BYTES_PER_ELEMENT);
|
|
372
|
-
|
|
373
363
|
const feedbackAddress = await this._alignedAlloc(
|
|
374
364
|
Int32Array.BYTES_PER_ELEMENT,
|
|
375
365
|
Int32Array.BYTES_PER_ELEMENT
|
|
@@ -385,6 +375,9 @@ export class EagleProfiler extends EagleBase {
|
|
|
385
375
|
throw new Error('malloc failed: Cannot allocate memory');
|
|
386
376
|
}
|
|
387
377
|
|
|
378
|
+
const memoryBufferInt16 = new Int16Array(this._wasmMemory.buffer);
|
|
379
|
+
memoryBufferInt16.set(pcm, pcmAddress / Int16Array.BYTES_PER_ELEMENT);
|
|
380
|
+
|
|
388
381
|
const status = await this._pvEagleProfilerEnroll(
|
|
389
382
|
this._objectAddress,
|
|
390
383
|
pcmAddress,
|
|
@@ -397,24 +390,29 @@ export class EagleProfiler extends EagleBase {
|
|
|
397
390
|
await this._pvFree(feedbackAddress);
|
|
398
391
|
await this._pvFree(percentageAddress);
|
|
399
392
|
|
|
393
|
+
const memoryBufferUint8 = new Uint8Array(this._wasmMemory.buffer);
|
|
394
|
+
|
|
400
395
|
throw new Error(
|
|
401
396
|
`enroll failed with status ${arrayBufferToStringAtIndex(
|
|
402
|
-
|
|
397
|
+
memoryBufferUint8,
|
|
403
398
|
await this._pvStatusToString(status)
|
|
404
399
|
)}`
|
|
405
400
|
);
|
|
406
401
|
}
|
|
407
402
|
|
|
408
|
-
const
|
|
403
|
+
const memoryBufferView = new DataView(this._wasmMemory.buffer);
|
|
404
|
+
|
|
405
|
+
const feedback = memoryBufferView.getInt32(
|
|
409
406
|
feedbackAddress,
|
|
410
407
|
true
|
|
411
408
|
);
|
|
412
|
-
await this._pvFree(feedbackAddress);
|
|
413
409
|
|
|
414
|
-
const percentage =
|
|
410
|
+
const percentage = memoryBufferView.getFloat32(
|
|
415
411
|
percentageAddress,
|
|
416
412
|
true
|
|
417
413
|
);
|
|
414
|
+
|
|
415
|
+
await this._pvFree(feedbackAddress);
|
|
418
416
|
await this._pvFree(percentageAddress);
|
|
419
417
|
|
|
420
418
|
return { feedback, percentage };
|
|
@@ -453,15 +451,18 @@ export class EagleProfiler extends EagleBase {
|
|
|
453
451
|
);
|
|
454
452
|
if (status !== PV_STATUS_SUCCESS) {
|
|
455
453
|
await this._pvFree(profileAddress);
|
|
454
|
+
const memoryBufferUint8 = new Uint8Array(this._wasmMemory.buffer);
|
|
456
455
|
throw new Error(
|
|
457
456
|
`export failed with status ${arrayBufferToStringAtIndex(
|
|
458
|
-
|
|
457
|
+
memoryBufferUint8,
|
|
459
458
|
await this._pvStatusToString(status)
|
|
460
459
|
)}`
|
|
461
460
|
);
|
|
462
461
|
}
|
|
463
462
|
|
|
464
|
-
const
|
|
463
|
+
const memoryBufferUint8 = new Uint8Array(this._wasmMemory.buffer);
|
|
464
|
+
|
|
465
|
+
const profile = memoryBufferUint8.slice(
|
|
465
466
|
profileAddress / Uint8Array.BYTES_PER_ELEMENT,
|
|
466
467
|
profileAddress / Uint8Array.BYTES_PER_ELEMENT +
|
|
467
468
|
EagleProfiler._profileSize
|
|
@@ -493,9 +494,10 @@ export class EagleProfiler extends EagleBase {
|
|
|
493
494
|
|
|
494
495
|
const status = await this._pvEagleProfilerReset(this._objectAddress);
|
|
495
496
|
if (status !== PV_STATUS_SUCCESS) {
|
|
497
|
+
const memoryBufferUint8 = new Uint8Array(this._wasmMemory.buffer);
|
|
496
498
|
throw new Error(
|
|
497
499
|
`reset failed with status ${arrayBufferToStringAtIndex(
|
|
498
|
-
|
|
500
|
+
memoryBufferUint8,
|
|
499
501
|
await this._pvStatusToString(status)
|
|
500
502
|
)}`
|
|
501
503
|
);
|
|
@@ -808,18 +810,21 @@ export class Eagle extends EagleBase {
|
|
|
808
810
|
);
|
|
809
811
|
await this._pvFree(pcmAddress);
|
|
810
812
|
if (status !== PV_STATUS_SUCCESS) {
|
|
813
|
+
const memoryBufferUint8 = new Uint8Array(this._wasmMemory.buffer);
|
|
811
814
|
throw new Error(
|
|
812
815
|
`process failed with status ${arrayBufferToStringAtIndex(
|
|
813
|
-
|
|
816
|
+
memoryBufferUint8,
|
|
814
817
|
await this._pvStatusToString(status)
|
|
815
818
|
)}`
|
|
816
819
|
);
|
|
817
820
|
}
|
|
821
|
+
|
|
822
|
+
const memoryBufferView = new DataView(this._wasmMemory.buffer);
|
|
818
823
|
|
|
819
824
|
const scores: number[] = [];
|
|
820
825
|
for (let i = 0; i < this._numSpeakers; i++) {
|
|
821
826
|
scores.push(
|
|
822
|
-
|
|
827
|
+
memoryBufferView.getFloat32(
|
|
823
828
|
this._scoresAddress + i * Float32Array.BYTES_PER_ELEMENT,
|
|
824
829
|
true
|
|
825
830
|
)
|
|
@@ -852,9 +857,10 @@ export class Eagle extends EagleBase {
|
|
|
852
857
|
|
|
853
858
|
const status = await this._pvEagleReset(this._objectAddress);
|
|
854
859
|
if (status !== PV_STATUS_SUCCESS) {
|
|
860
|
+
const memoryBufferUint8 = new Uint8Array(this._wasmMemory.buffer);
|
|
855
861
|
throw new Error(
|
|
856
862
|
`reset failed with status ${arrayBufferToStringAtIndex(
|
|
857
|
-
|
|
863
|
+
memoryBufferUint8,
|
|
858
864
|
await this._pvStatusToString(status)
|
|
859
865
|
)}`
|
|
860
866
|
);
|