@picovoice/eagle-web 2.0.0 → 3.0.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/.babelrc +4 -4
- package/.eslintrc.js +469 -469
- package/.prettierignore +1 -1
- package/.prettierrc +8 -8
- package/README.md +234 -236
- package/dist/esm/index.js +3656 -11290
- package/dist/esm/index.min.js +1 -1
- package/dist/iife/index.js +3655 -11289
- package/dist/iife/index.min.js +1 -1
- package/dist/types/eagle.d.ts +237 -245
- package/dist/types/eagle.d.ts.map +1 -1
- package/dist/types/eagle_errors.d.ts +47 -47
- package/dist/types/eagle_profiler_worker.d.ts +112 -113
- package/dist/types/eagle_profiler_worker.d.ts.map +1 -1
- package/dist/types/eagle_profiler_worker_handler.d.ts +3 -3
- package/dist/types/eagle_worker.d.ts +88 -93
- package/dist/types/eagle_worker.d.ts.map +1 -1
- package/dist/types/eagle_worker_handler.d.ts +3 -3
- package/dist/types/index.d.ts +6 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +142 -140
- package/dist/types/types.d.ts.map +1 -1
- package/module.d.ts +16 -16
- package/package.json +73 -73
- package/rollup.config.js +75 -75
- package/src/eagle.ts +1546 -1508
- package/src/eagle_errors.ts +252 -252
- package/src/eagle_profiler_worker.ts +443 -405
- package/src/eagle_profiler_worker_handler.ts +246 -208
- package/src/eagle_worker.ts +307 -346
- package/src/eagle_worker_handler.ts +138 -170
- package/src/index.ts +94 -98
- package/src/types.ts +224 -218
- package/tsconfig.json +22 -22
package/src/types.ts
CHANGED
|
@@ -1,218 +1,224 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2023-
|
|
3
|
-
|
|
4
|
-
You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
|
|
5
|
-
file accompanying this source.
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
|
8
|
-
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
9
|
-
specific language governing permissions and limitations under the License.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { PvModel } from '@picovoice/web-utils';
|
|
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
|
-
|
|
29
|
-
/**
|
|
30
|
-
* EagleModel types
|
|
31
|
-
*/
|
|
32
|
-
export type EagleModel = PvModel;
|
|
33
|
-
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
export type
|
|
166
|
-
command: '
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
export type
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
export type
|
|
209
|
-
| EagleWorkerFailureResponse
|
|
210
|
-
| {
|
|
211
|
-
command: 'ok';
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
export type
|
|
215
|
-
|
|
|
216
|
-
|
|
|
217
|
-
|
|
218
|
-
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023-2026 Picovoice Inc.
|
|
3
|
+
|
|
4
|
+
You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
|
|
5
|
+
file accompanying this source.
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
|
8
|
+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
9
|
+
specific language governing permissions and limitations under the License.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { PvModel } from '@picovoice/web-utils';
|
|
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
|
+
|
|
29
|
+
/**
|
|
30
|
+
* EagleModel types
|
|
31
|
+
*/
|
|
32
|
+
export type EagleModel = PvModel;
|
|
33
|
+
|
|
34
|
+
export type EagleProfile = {
|
|
35
|
+
/** Buffer containing the speaker profile. */
|
|
36
|
+
bytes: Uint8Array;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type EagleOptions = {
|
|
40
|
+
/** @defaultValue `best` */
|
|
41
|
+
device?: string;
|
|
42
|
+
/** @defaultValue `0.3` */
|
|
43
|
+
voiceThreshold?: number;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type EagleProfilerOptions = {
|
|
47
|
+
/** @defaultValue `best` */
|
|
48
|
+
device?: string;
|
|
49
|
+
/** @defaultValue `1` */
|
|
50
|
+
minEnrollmentChunks?: number;
|
|
51
|
+
/** @defaultValue `0.3` */
|
|
52
|
+
voiceThreshold?: number;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type EagleProfilerWorkerInitRequest = {
|
|
56
|
+
command: 'init';
|
|
57
|
+
accessKey: string;
|
|
58
|
+
modelPath: string;
|
|
59
|
+
options: EagleProfilerOptions;
|
|
60
|
+
wasmSimd: string;
|
|
61
|
+
wasmSimdLib: string;
|
|
62
|
+
wasmPThread: string;
|
|
63
|
+
wasmPThreadLib: string;
|
|
64
|
+
sdk: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type EagleProfilerWorkerEnrollRequest = {
|
|
68
|
+
command: 'enroll';
|
|
69
|
+
inputFrame: Int16Array;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type EagleProfilerWorkerFlushRequest = {
|
|
73
|
+
command: 'flush';
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type EagleProfilerWorkerExportRequest = {
|
|
77
|
+
command: 'export';
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type EagleProfilerWorkerResetRequest = {
|
|
81
|
+
command: 'reset';
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type EagleProfilerWorkerReleaseRequest = {
|
|
85
|
+
command: 'release';
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export type EagleProfilerWorkerRequest =
|
|
89
|
+
| EagleProfilerWorkerInitRequest
|
|
90
|
+
| EagleProfilerWorkerEnrollRequest
|
|
91
|
+
| EagleProfilerWorkerFlushRequest
|
|
92
|
+
| EagleProfilerWorkerExportRequest
|
|
93
|
+
| EagleProfilerWorkerResetRequest
|
|
94
|
+
| EagleProfilerWorkerReleaseRequest;
|
|
95
|
+
|
|
96
|
+
export type EagleProfilerWorkerFailureResponse = {
|
|
97
|
+
command: 'failed' | 'error';
|
|
98
|
+
status: PvStatus;
|
|
99
|
+
shortMessage: string;
|
|
100
|
+
messageStack: string[];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export type EagleProfilerWorkerInitResponse =
|
|
104
|
+
| EagleProfilerWorkerFailureResponse
|
|
105
|
+
| {
|
|
106
|
+
command: 'ok';
|
|
107
|
+
frameLength: number;
|
|
108
|
+
sampleRate: number;
|
|
109
|
+
version: string;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export type EagleProfilerWorkerEnrollResponse =
|
|
113
|
+
| EagleProfilerWorkerFailureResponse
|
|
114
|
+
| {
|
|
115
|
+
command: 'ok';
|
|
116
|
+
result: number;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export type EagleProfilerWorkerFlushResponse =
|
|
120
|
+
| EagleProfilerWorkerFailureResponse
|
|
121
|
+
| {
|
|
122
|
+
command: 'ok';
|
|
123
|
+
result: number;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export type EagleProfilerWorkerExportResponse =
|
|
127
|
+
| EagleProfilerWorkerFailureResponse
|
|
128
|
+
| {
|
|
129
|
+
command: 'ok';
|
|
130
|
+
profile: EagleProfile;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export type EagleProfilerWorkerResetResponse =
|
|
134
|
+
| EagleProfilerWorkerFailureResponse
|
|
135
|
+
| {
|
|
136
|
+
command: 'ok';
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export type EagleProfilerWorkerReleaseResponse =
|
|
140
|
+
| EagleProfilerWorkerFailureResponse
|
|
141
|
+
| {
|
|
142
|
+
command: 'ok';
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export type EagleProfilerWorkerResponse =
|
|
146
|
+
| EagleProfilerWorkerInitResponse
|
|
147
|
+
| EagleProfilerWorkerEnrollResponse
|
|
148
|
+
| EagleProfilerWorkerFlushResponse
|
|
149
|
+
| EagleProfilerWorkerExportResponse
|
|
150
|
+
| EagleProfilerWorkerResetResponse
|
|
151
|
+
| EagleProfilerWorkerReleaseResponse;
|
|
152
|
+
|
|
153
|
+
export type EagleWorkerInitRequest = {
|
|
154
|
+
command: 'init';
|
|
155
|
+
accessKey: string;
|
|
156
|
+
modelPath: string;
|
|
157
|
+
options: EagleOptions;
|
|
158
|
+
wasmSimd: string;
|
|
159
|
+
wasmSimdLib: string;
|
|
160
|
+
wasmPThread: string;
|
|
161
|
+
wasmPThreadLib: string;
|
|
162
|
+
sdk: string;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export type EagleWorkerProcessRequest = {
|
|
166
|
+
command: 'process';
|
|
167
|
+
inputFrame: Int16Array;
|
|
168
|
+
speakerProfiles: EagleProfile[];
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export type EagleWorkerResetRequest = {
|
|
172
|
+
command: 'reset';
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export type EagleWorkerReleaseRequest = {
|
|
176
|
+
command: 'release';
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export type EagleWorkerRequest =
|
|
180
|
+
| EagleWorkerInitRequest
|
|
181
|
+
| EagleWorkerProcessRequest
|
|
182
|
+
| EagleWorkerResetRequest
|
|
183
|
+
| EagleWorkerReleaseRequest;
|
|
184
|
+
|
|
185
|
+
export type EagleWorkerFailureResponse = {
|
|
186
|
+
command: 'failed' | 'error';
|
|
187
|
+
status: PvStatus;
|
|
188
|
+
shortMessage: string;
|
|
189
|
+
messageStack: string[];
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export type EagleWorkerInitResponse =
|
|
193
|
+
| EagleWorkerFailureResponse
|
|
194
|
+
| {
|
|
195
|
+
command: 'ok';
|
|
196
|
+
minProcessSamples: number;
|
|
197
|
+
sampleRate: number;
|
|
198
|
+
version: string;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export type EagleWorkerProcessResponse =
|
|
202
|
+
| EagleWorkerFailureResponse
|
|
203
|
+
| {
|
|
204
|
+
command: 'ok';
|
|
205
|
+
scores: number[];
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export type EagleWorkerResetResponse =
|
|
209
|
+
| EagleWorkerFailureResponse
|
|
210
|
+
| {
|
|
211
|
+
command: 'ok';
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export type EagleWorkerReleaseResponse =
|
|
215
|
+
| EagleWorkerFailureResponse
|
|
216
|
+
| {
|
|
217
|
+
command: 'ok';
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
export type EagleWorkerResponse =
|
|
221
|
+
| EagleWorkerInitResponse
|
|
222
|
+
| EagleWorkerProcessResponse
|
|
223
|
+
| EagleWorkerResetResponse
|
|
224
|
+
| EagleWorkerReleaseResponse;
|
package/tsconfig.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"allowJs": true,
|
|
4
|
-
"allowSyntheticDefaultImports": true,
|
|
5
|
-
"downlevelIteration": true,
|
|
6
|
-
"isolatedModules": false,
|
|
7
|
-
"noImplicitAny": false,
|
|
8
|
-
"lib": ["es2015", "esnext", "dom"],
|
|
9
|
-
"module": "esnext",
|
|
10
|
-
"moduleResolution": "node",
|
|
11
|
-
"noEmit": false,
|
|
12
|
-
"outDir": "./dist",
|
|
13
|
-
"removeComments": false,
|
|
14
|
-
"resolveJsonModule": true,
|
|
15
|
-
"sourceMap": true,
|
|
16
|
-
"strict": true,
|
|
17
|
-
"target": "esnext",
|
|
18
|
-
"types": ["node", "emscripten"]
|
|
19
|
-
},
|
|
20
|
-
"include": ["src", "module.d.ts"],
|
|
21
|
-
"exclude": ["node_modules", "src/lib"]
|
|
22
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": true,
|
|
4
|
+
"allowSyntheticDefaultImports": true,
|
|
5
|
+
"downlevelIteration": true,
|
|
6
|
+
"isolatedModules": false,
|
|
7
|
+
"noImplicitAny": false,
|
|
8
|
+
"lib": ["es2015", "esnext", "dom"],
|
|
9
|
+
"module": "esnext",
|
|
10
|
+
"moduleResolution": "node",
|
|
11
|
+
"noEmit": false,
|
|
12
|
+
"outDir": "./dist",
|
|
13
|
+
"removeComments": false,
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"strict": true,
|
|
17
|
+
"target": "esnext",
|
|
18
|
+
"types": ["node", "emscripten"]
|
|
19
|
+
},
|
|
20
|
+
"include": ["src", "module.d.ts"],
|
|
21
|
+
"exclude": ["node_modules", "src/lib"]
|
|
22
|
+
}
|