@picovoice/eagle-web 0.1.2 → 0.2.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/.eslintrc.js +1 -1
- package/dist/esm/index.js +1810 -1439
- package/dist/esm/index.min.js +1 -1
- package/dist/iife/index.js +1810 -1438
- package/dist/iife/index.min.js +1 -1
- package/dist/types/eagle.d.ts +18 -1
- package/dist/types/eagle.d.ts.map +1 -1
- package/dist/types/eagle_errors.d.ts +48 -0
- package/dist/types/eagle_errors.d.ts.map +1 -0
- package/dist/types/eagle_profiler_worker.d.ts +2 -0
- package/dist/types/eagle_profiler_worker.d.ts.map +1 -1
- package/dist/types/eagle_worker.d.ts +3 -1
- package/dist/types/eagle_worker.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +22 -2
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/eagle.ts +261 -81
- package/src/eagle_errors.ts +252 -0
- package/src/eagle_profiler_worker.ts +17 -10
- package/src/eagle_profiler_worker_handler.ts +67 -20
- package/src/eagle_worker.ts +16 -9
- package/src/eagle_worker_handler.ts +51 -15
- package/src/index.ts +2 -0
- package/src/types.ts +23 -2
|
@@ -15,7 +15,9 @@ import {
|
|
|
15
15
|
EagleWorkerProcessRequest,
|
|
16
16
|
EagleWorkerInitRequest,
|
|
17
17
|
EagleWorkerRequest,
|
|
18
|
+
PvStatus,
|
|
18
19
|
} from './types';
|
|
20
|
+
import { EagleError } from "./eagle_errors";
|
|
19
21
|
|
|
20
22
|
let eagle: Eagle | null = null;
|
|
21
23
|
|
|
@@ -23,12 +25,14 @@ const initRequest = async (request: EagleWorkerInitRequest): Promise<any> => {
|
|
|
23
25
|
if (eagle !== null) {
|
|
24
26
|
return {
|
|
25
27
|
command: 'error',
|
|
26
|
-
|
|
28
|
+
status: PvStatus.INVALID_STATE,
|
|
29
|
+
shortMessage: 'Eagle has already been initialized',
|
|
27
30
|
};
|
|
28
31
|
}
|
|
29
32
|
try {
|
|
30
33
|
Eagle.setWasm(request.wasm);
|
|
31
34
|
Eagle.setWasmSimd(request.wasmSimd);
|
|
35
|
+
Eagle.setSdk(request.sdk);
|
|
32
36
|
eagle = await Eagle._init(
|
|
33
37
|
request.accessKey,
|
|
34
38
|
request.modelPath,
|
|
@@ -41,10 +45,20 @@ const initRequest = async (request: EagleWorkerInitRequest): Promise<any> => {
|
|
|
41
45
|
version: eagle.version,
|
|
42
46
|
};
|
|
43
47
|
} catch (e: any) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
if (e instanceof EagleError) {
|
|
49
|
+
return {
|
|
50
|
+
command: 'error',
|
|
51
|
+
status: e.status,
|
|
52
|
+
shortMessage: e.shortMessage,
|
|
53
|
+
messageStack: e.messageStack
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
return {
|
|
57
|
+
command: 'error',
|
|
58
|
+
status: PvStatus.RUNTIME_ERROR,
|
|
59
|
+
shortMessage: e.message
|
|
60
|
+
};
|
|
61
|
+
}
|
|
48
62
|
}
|
|
49
63
|
};
|
|
50
64
|
|
|
@@ -54,7 +68,8 @@ const processRequest = async (
|
|
|
54
68
|
if (eagle === null) {
|
|
55
69
|
return {
|
|
56
70
|
command: 'error',
|
|
57
|
-
|
|
71
|
+
status: PvStatus.INVALID_STATE,
|
|
72
|
+
shortMessage: 'Eagle has not been initialized',
|
|
58
73
|
};
|
|
59
74
|
}
|
|
60
75
|
try {
|
|
@@ -64,10 +79,20 @@ const processRequest = async (
|
|
|
64
79
|
scores,
|
|
65
80
|
};
|
|
66
81
|
} catch (e: any) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
82
|
+
if (e instanceof EagleError) {
|
|
83
|
+
return {
|
|
84
|
+
command: 'error',
|
|
85
|
+
status: e.status,
|
|
86
|
+
shortMessage: e.shortMessage,
|
|
87
|
+
messageStack: e.messageStack
|
|
88
|
+
};
|
|
89
|
+
} else {
|
|
90
|
+
return {
|
|
91
|
+
command: 'error',
|
|
92
|
+
status: PvStatus.RUNTIME_ERROR,
|
|
93
|
+
shortMessage: e.message
|
|
94
|
+
};
|
|
95
|
+
}
|
|
71
96
|
}
|
|
72
97
|
};
|
|
73
98
|
|
|
@@ -75,7 +100,8 @@ const resetRequest = async (): Promise<any> => {
|
|
|
75
100
|
if (eagle === null) {
|
|
76
101
|
return {
|
|
77
102
|
command: 'error',
|
|
78
|
-
|
|
103
|
+
status: PvStatus.INVALID_STATE,
|
|
104
|
+
shortMessage: 'Eagle has not been initialized',
|
|
79
105
|
};
|
|
80
106
|
}
|
|
81
107
|
try {
|
|
@@ -84,10 +110,20 @@ const resetRequest = async (): Promise<any> => {
|
|
|
84
110
|
command: 'ok',
|
|
85
111
|
};
|
|
86
112
|
} catch (e: any) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
113
|
+
if (e instanceof EagleError) {
|
|
114
|
+
return {
|
|
115
|
+
command: 'error',
|
|
116
|
+
status: e.status,
|
|
117
|
+
shortMessage: e.shortMessage,
|
|
118
|
+
messageStack: e.messageStack
|
|
119
|
+
};
|
|
120
|
+
} else {
|
|
121
|
+
return {
|
|
122
|
+
command: 'error',
|
|
123
|
+
status: PvStatus.RUNTIME_ERROR,
|
|
124
|
+
shortMessage: e.message
|
|
125
|
+
};
|
|
126
|
+
}
|
|
91
127
|
}
|
|
92
128
|
};
|
|
93
129
|
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Eagle, EagleProfiler } from './eagle';
|
|
2
2
|
import { EagleProfilerWorker } from './eagle_profiler_worker';
|
|
3
3
|
import { EagleWorker } from './eagle_worker';
|
|
4
|
+
import * as EagleErrors from './eagle_errors';
|
|
4
5
|
|
|
5
6
|
import {
|
|
6
7
|
EagleModel,
|
|
@@ -47,6 +48,7 @@ EagleProfilerWorker.setWasmSimd(eagleWasmSimd);
|
|
|
47
48
|
|
|
48
49
|
export {
|
|
49
50
|
Eagle,
|
|
51
|
+
EagleErrors,
|
|
50
52
|
EagleModel,
|
|
51
53
|
EagleProfile,
|
|
52
54
|
EagleProfiler,
|
package/src/types.ts
CHANGED
|
@@ -11,6 +11,21 @@
|
|
|
11
11
|
|
|
12
12
|
import { PvModel } from '@picovoice/web-utils';
|
|
13
13
|
|
|
14
|
+
export enum PvStatus {
|
|
15
|
+
SUCCESS = 10000,
|
|
16
|
+
OUT_OF_MEMORY,
|
|
17
|
+
IO_ERROR,
|
|
18
|
+
INVALID_ARGUMENT,
|
|
19
|
+
STOP_ITERATION,
|
|
20
|
+
KEY_ERROR,
|
|
21
|
+
INVALID_STATE,
|
|
22
|
+
RUNTIME_ERROR,
|
|
23
|
+
ACTIVATION_ERROR,
|
|
24
|
+
ACTIVATION_LIMIT_REACHED,
|
|
25
|
+
ACTIVATION_THROTTLED,
|
|
26
|
+
ACTIVATION_REFUSED,
|
|
27
|
+
}
|
|
28
|
+
|
|
14
29
|
/**
|
|
15
30
|
* EagleModel types
|
|
16
31
|
*/
|
|
@@ -40,6 +55,7 @@ export type EagleProfilerWorkerInitRequest = {
|
|
|
40
55
|
modelPath: string;
|
|
41
56
|
wasm: string;
|
|
42
57
|
wasmSimd: string;
|
|
58
|
+
sdk: string;
|
|
43
59
|
};
|
|
44
60
|
|
|
45
61
|
export type EagleProfilerWorkerEnrollRequest = {
|
|
@@ -68,7 +84,9 @@ export type EagleProfilerWorkerRequest =
|
|
|
68
84
|
|
|
69
85
|
export type EagleProfilerWorkerFailureResponse = {
|
|
70
86
|
command: 'failed' | 'error';
|
|
71
|
-
|
|
87
|
+
status: PvStatus;
|
|
88
|
+
shortMessage: string;
|
|
89
|
+
messageStack: string[];
|
|
72
90
|
};
|
|
73
91
|
|
|
74
92
|
export type EagleProfilerWorkerInitResponse =
|
|
@@ -120,6 +138,7 @@ export type EagleWorkerInitRequest = {
|
|
|
120
138
|
speakerProfiles: EagleProfile[];
|
|
121
139
|
wasm: string;
|
|
122
140
|
wasmSimd: string;
|
|
141
|
+
sdk: string;
|
|
123
142
|
};
|
|
124
143
|
|
|
125
144
|
export type EagleWorkerProcessRequest = {
|
|
@@ -143,7 +162,9 @@ export type EagleWorkerRequest =
|
|
|
143
162
|
|
|
144
163
|
export type EagleWorkerFailureResponse = {
|
|
145
164
|
command: 'failed' | 'error';
|
|
146
|
-
|
|
165
|
+
status: PvStatus;
|
|
166
|
+
shortMessage: string;
|
|
167
|
+
messageStack: string[];
|
|
147
168
|
};
|
|
148
169
|
|
|
149
170
|
export type EagleWorkerInitResponse =
|