decibri 3.4.1 → 4.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/CHANGELOG.md +386 -0
- package/MIGRATION.md +151 -0
- package/README.md +206 -112
- package/examples/wav-capture.js +2 -2
- package/examples/websocket-stream.js +2 -2
- package/index.d.ts +1 -1
- package/index.js +52 -52
- package/package.json +9 -7
- package/src/browser/decibri-browser.js +37 -11
- package/src/browser/index.d.ts +28 -15
- package/src/browser/index.js +2 -2
- package/src/decibri-output.js +24 -29
- package/src/decibri.d.ts +81 -47
- package/src/decibri.js +106 -41
- package/src/errors.js +126 -23
package/index.js
CHANGED
|
@@ -77,8 +77,8 @@ function requireNative() {
|
|
|
77
77
|
try {
|
|
78
78
|
const binding = require('@decibri/decibri-android-arm64')
|
|
79
79
|
const bindingPackageVersion = require('@decibri/decibri-android-arm64/package.json').version
|
|
80
|
-
if (bindingPackageVersion !== '
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
80
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
81
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
82
|
}
|
|
83
83
|
return binding
|
|
84
84
|
} catch (e) {
|
|
@@ -93,8 +93,8 @@ function requireNative() {
|
|
|
93
93
|
try {
|
|
94
94
|
const binding = require('@decibri/decibri-android-arm-eabi')
|
|
95
95
|
const bindingPackageVersion = require('@decibri/decibri-android-arm-eabi/package.json').version
|
|
96
|
-
if (bindingPackageVersion !== '
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
96
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
97
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
98
|
}
|
|
99
99
|
return binding
|
|
100
100
|
} catch (e) {
|
|
@@ -114,8 +114,8 @@ function requireNative() {
|
|
|
114
114
|
try {
|
|
115
115
|
const binding = require('@decibri/decibri-win32-x64-gnu')
|
|
116
116
|
const bindingPackageVersion = require('@decibri/decibri-win32-x64-gnu/package.json').version
|
|
117
|
-
if (bindingPackageVersion !== '
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
117
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
118
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
119
119
|
}
|
|
120
120
|
return binding
|
|
121
121
|
} catch (e) {
|
|
@@ -130,8 +130,8 @@ function requireNative() {
|
|
|
130
130
|
try {
|
|
131
131
|
const binding = require('@decibri/decibri-win32-x64-msvc')
|
|
132
132
|
const bindingPackageVersion = require('@decibri/decibri-win32-x64-msvc/package.json').version
|
|
133
|
-
if (bindingPackageVersion !== '
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
133
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
134
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
135
135
|
}
|
|
136
136
|
return binding
|
|
137
137
|
} catch (e) {
|
|
@@ -147,8 +147,8 @@ function requireNative() {
|
|
|
147
147
|
try {
|
|
148
148
|
const binding = require('@decibri/decibri-win32-ia32-msvc')
|
|
149
149
|
const bindingPackageVersion = require('@decibri/decibri-win32-ia32-msvc/package.json').version
|
|
150
|
-
if (bindingPackageVersion !== '
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
150
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
151
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
152
|
}
|
|
153
153
|
return binding
|
|
154
154
|
} catch (e) {
|
|
@@ -163,8 +163,8 @@ function requireNative() {
|
|
|
163
163
|
try {
|
|
164
164
|
const binding = require('@decibri/decibri-win32-arm64-msvc')
|
|
165
165
|
const bindingPackageVersion = require('@decibri/decibri-win32-arm64-msvc/package.json').version
|
|
166
|
-
if (bindingPackageVersion !== '
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
166
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
167
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
168
|
}
|
|
169
169
|
return binding
|
|
170
170
|
} catch (e) {
|
|
@@ -182,8 +182,8 @@ function requireNative() {
|
|
|
182
182
|
try {
|
|
183
183
|
const binding = require('@decibri/decibri-darwin-universal')
|
|
184
184
|
const bindingPackageVersion = require('@decibri/decibri-darwin-universal/package.json').version
|
|
185
|
-
if (bindingPackageVersion !== '
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
185
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
186
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
187
|
}
|
|
188
188
|
return binding
|
|
189
189
|
} catch (e) {
|
|
@@ -198,8 +198,8 @@ function requireNative() {
|
|
|
198
198
|
try {
|
|
199
199
|
const binding = require('@decibri/decibri-darwin-x64')
|
|
200
200
|
const bindingPackageVersion = require('@decibri/decibri-darwin-x64/package.json').version
|
|
201
|
-
if (bindingPackageVersion !== '
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
201
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
202
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
203
|
}
|
|
204
204
|
return binding
|
|
205
205
|
} catch (e) {
|
|
@@ -214,8 +214,8 @@ function requireNative() {
|
|
|
214
214
|
try {
|
|
215
215
|
const binding = require('@decibri/decibri-darwin-arm64')
|
|
216
216
|
const bindingPackageVersion = require('@decibri/decibri-darwin-arm64/package.json').version
|
|
217
|
-
if (bindingPackageVersion !== '
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
217
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
218
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
219
|
}
|
|
220
220
|
return binding
|
|
221
221
|
} catch (e) {
|
|
@@ -234,8 +234,8 @@ function requireNative() {
|
|
|
234
234
|
try {
|
|
235
235
|
const binding = require('@decibri/decibri-freebsd-x64')
|
|
236
236
|
const bindingPackageVersion = require('@decibri/decibri-freebsd-x64/package.json').version
|
|
237
|
-
if (bindingPackageVersion !== '
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
237
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
238
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
239
|
}
|
|
240
240
|
return binding
|
|
241
241
|
} catch (e) {
|
|
@@ -250,8 +250,8 @@ function requireNative() {
|
|
|
250
250
|
try {
|
|
251
251
|
const binding = require('@decibri/decibri-freebsd-arm64')
|
|
252
252
|
const bindingPackageVersion = require('@decibri/decibri-freebsd-arm64/package.json').version
|
|
253
|
-
if (bindingPackageVersion !== '
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
253
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
254
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
255
|
}
|
|
256
256
|
return binding
|
|
257
257
|
} catch (e) {
|
|
@@ -271,8 +271,8 @@ function requireNative() {
|
|
|
271
271
|
try {
|
|
272
272
|
const binding = require('@decibri/decibri-linux-x64-musl')
|
|
273
273
|
const bindingPackageVersion = require('@decibri/decibri-linux-x64-musl/package.json').version
|
|
274
|
-
if (bindingPackageVersion !== '
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
274
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
275
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
276
276
|
}
|
|
277
277
|
return binding
|
|
278
278
|
} catch (e) {
|
|
@@ -287,8 +287,8 @@ function requireNative() {
|
|
|
287
287
|
try {
|
|
288
288
|
const binding = require('@decibri/decibri-linux-x64-gnu')
|
|
289
289
|
const bindingPackageVersion = require('@decibri/decibri-linux-x64-gnu/package.json').version
|
|
290
|
-
if (bindingPackageVersion !== '
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
290
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
291
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
292
292
|
}
|
|
293
293
|
return binding
|
|
294
294
|
} catch (e) {
|
|
@@ -305,8 +305,8 @@ function requireNative() {
|
|
|
305
305
|
try {
|
|
306
306
|
const binding = require('@decibri/decibri-linux-arm64-musl')
|
|
307
307
|
const bindingPackageVersion = require('@decibri/decibri-linux-arm64-musl/package.json').version
|
|
308
|
-
if (bindingPackageVersion !== '
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
308
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
309
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
310
310
|
}
|
|
311
311
|
return binding
|
|
312
312
|
} catch (e) {
|
|
@@ -321,8 +321,8 @@ function requireNative() {
|
|
|
321
321
|
try {
|
|
322
322
|
const binding = require('@decibri/decibri-linux-arm64-gnu')
|
|
323
323
|
const bindingPackageVersion = require('@decibri/decibri-linux-arm64-gnu/package.json').version
|
|
324
|
-
if (bindingPackageVersion !== '
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
324
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
325
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
326
326
|
}
|
|
327
327
|
return binding
|
|
328
328
|
} catch (e) {
|
|
@@ -339,8 +339,8 @@ function requireNative() {
|
|
|
339
339
|
try {
|
|
340
340
|
const binding = require('@decibri/decibri-linux-arm-musleabihf')
|
|
341
341
|
const bindingPackageVersion = require('@decibri/decibri-linux-arm-musleabihf/package.json').version
|
|
342
|
-
if (bindingPackageVersion !== '
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
342
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
343
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
344
344
|
}
|
|
345
345
|
return binding
|
|
346
346
|
} catch (e) {
|
|
@@ -355,8 +355,8 @@ function requireNative() {
|
|
|
355
355
|
try {
|
|
356
356
|
const binding = require('@decibri/decibri-linux-arm-gnueabihf')
|
|
357
357
|
const bindingPackageVersion = require('@decibri/decibri-linux-arm-gnueabihf/package.json').version
|
|
358
|
-
if (bindingPackageVersion !== '
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
358
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
359
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
360
360
|
}
|
|
361
361
|
return binding
|
|
362
362
|
} catch (e) {
|
|
@@ -373,8 +373,8 @@ function requireNative() {
|
|
|
373
373
|
try {
|
|
374
374
|
const binding = require('@decibri/decibri-linux-loong64-musl')
|
|
375
375
|
const bindingPackageVersion = require('@decibri/decibri-linux-loong64-musl/package.json').version
|
|
376
|
-
if (bindingPackageVersion !== '
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
376
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
377
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
378
378
|
}
|
|
379
379
|
return binding
|
|
380
380
|
} catch (e) {
|
|
@@ -389,8 +389,8 @@ function requireNative() {
|
|
|
389
389
|
try {
|
|
390
390
|
const binding = require('@decibri/decibri-linux-loong64-gnu')
|
|
391
391
|
const bindingPackageVersion = require('@decibri/decibri-linux-loong64-gnu/package.json').version
|
|
392
|
-
if (bindingPackageVersion !== '
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
392
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
393
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
394
394
|
}
|
|
395
395
|
return binding
|
|
396
396
|
} catch (e) {
|
|
@@ -407,8 +407,8 @@ function requireNative() {
|
|
|
407
407
|
try {
|
|
408
408
|
const binding = require('@decibri/decibri-linux-riscv64-musl')
|
|
409
409
|
const bindingPackageVersion = require('@decibri/decibri-linux-riscv64-musl/package.json').version
|
|
410
|
-
if (bindingPackageVersion !== '
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
410
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
411
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
412
|
}
|
|
413
413
|
return binding
|
|
414
414
|
} catch (e) {
|
|
@@ -423,8 +423,8 @@ function requireNative() {
|
|
|
423
423
|
try {
|
|
424
424
|
const binding = require('@decibri/decibri-linux-riscv64-gnu')
|
|
425
425
|
const bindingPackageVersion = require('@decibri/decibri-linux-riscv64-gnu/package.json').version
|
|
426
|
-
if (bindingPackageVersion !== '
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
426
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
427
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
428
428
|
}
|
|
429
429
|
return binding
|
|
430
430
|
} catch (e) {
|
|
@@ -440,8 +440,8 @@ function requireNative() {
|
|
|
440
440
|
try {
|
|
441
441
|
const binding = require('@decibri/decibri-linux-ppc64-gnu')
|
|
442
442
|
const bindingPackageVersion = require('@decibri/decibri-linux-ppc64-gnu/package.json').version
|
|
443
|
-
if (bindingPackageVersion !== '
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
443
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
444
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
445
|
}
|
|
446
446
|
return binding
|
|
447
447
|
} catch (e) {
|
|
@@ -456,8 +456,8 @@ function requireNative() {
|
|
|
456
456
|
try {
|
|
457
457
|
const binding = require('@decibri/decibri-linux-s390x-gnu')
|
|
458
458
|
const bindingPackageVersion = require('@decibri/decibri-linux-s390x-gnu/package.json').version
|
|
459
|
-
if (bindingPackageVersion !== '
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
459
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
460
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
461
|
}
|
|
462
462
|
return binding
|
|
463
463
|
} catch (e) {
|
|
@@ -476,8 +476,8 @@ function requireNative() {
|
|
|
476
476
|
try {
|
|
477
477
|
const binding = require('@decibri/decibri-openharmony-arm64')
|
|
478
478
|
const bindingPackageVersion = require('@decibri/decibri-openharmony-arm64/package.json').version
|
|
479
|
-
if (bindingPackageVersion !== '
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
479
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
480
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
481
|
}
|
|
482
482
|
return binding
|
|
483
483
|
} catch (e) {
|
|
@@ -492,8 +492,8 @@ function requireNative() {
|
|
|
492
492
|
try {
|
|
493
493
|
const binding = require('@decibri/decibri-openharmony-x64')
|
|
494
494
|
const bindingPackageVersion = require('@decibri/decibri-openharmony-x64/package.json').version
|
|
495
|
-
if (bindingPackageVersion !== '
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
495
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
496
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
497
|
}
|
|
498
498
|
return binding
|
|
499
499
|
} catch (e) {
|
|
@@ -508,8 +508,8 @@ function requireNative() {
|
|
|
508
508
|
try {
|
|
509
509
|
const binding = require('@decibri/decibri-openharmony-arm')
|
|
510
510
|
const bindingPackageVersion = require('@decibri/decibri-openharmony-arm/package.json').version
|
|
511
|
-
if (bindingPackageVersion !== '
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
511
|
+
if (bindingPackageVersion !== '4.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
512
|
+
throw new Error(`Native binding package version mismatch, expected 4.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "decibri",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Cross-platform audio capture,
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "Cross-platform audio capture, playback, and processing for Node.js and browsers",
|
|
5
5
|
"main": "src/decibri.js",
|
|
6
6
|
"types": "src/decibri.d.ts",
|
|
7
7
|
"browser": "./src/browser/index.js",
|
|
@@ -67,13 +67,15 @@
|
|
|
67
67
|
"examples/",
|
|
68
68
|
"index.js",
|
|
69
69
|
"index.d.ts",
|
|
70
|
-
"README.md"
|
|
70
|
+
"README.md",
|
|
71
|
+
"CHANGELOG.md",
|
|
72
|
+
"MIGRATION.md"
|
|
71
73
|
],
|
|
72
74
|
"optionalDependencies": {
|
|
73
|
-
"@decibri/decibri-win32-x64-msvc": "
|
|
74
|
-
"@decibri/decibri-darwin-arm64": "
|
|
75
|
-
"@decibri/decibri-linux-x64-gnu": "
|
|
76
|
-
"@decibri/decibri-linux-arm64-gnu": "
|
|
75
|
+
"@decibri/decibri-win32-x64-msvc": "4.0.0",
|
|
76
|
+
"@decibri/decibri-darwin-arm64": "4.0.0",
|
|
77
|
+
"@decibri/decibri-linux-x64-gnu": "4.0.0",
|
|
78
|
+
"@decibri/decibri-linux-arm64-gnu": "4.0.0"
|
|
77
79
|
},
|
|
78
80
|
"devDependencies": {
|
|
79
81
|
"@napi-rs/cli": "^3.0.0"
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
const { Emitter } = require('./emitter.js');
|
|
4
4
|
const { WORKLET_SOURCE } = require('./worklet-inline.js');
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// Browser build version. Keep in sync with package.json on each release; the
|
|
7
|
+
// browser bundle cannot read package.json at runtime the way the Node wrapper
|
|
8
|
+
// does, so this is a maintained constant.
|
|
9
|
+
const VERSION = '4.0.0';
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* Browser microphone capture.
|
|
@@ -14,14 +17,14 @@ const VERSION = '3.0.0';
|
|
|
14
17
|
* Ported from decibri-web decibri.ts. Logic identical, types removed.
|
|
15
18
|
*
|
|
16
19
|
* @example
|
|
17
|
-
* const {
|
|
18
|
-
* const mic = new
|
|
20
|
+
* const { Microphone } = require('decibri'); // browser entry via conditional export
|
|
21
|
+
* const mic = new Microphone({ sampleRate: 16000 });
|
|
19
22
|
* mic.on('data', (chunk) => { // chunk is Int16Array });
|
|
20
23
|
* await mic.start();
|
|
21
24
|
* // later...
|
|
22
25
|
* mic.stop();
|
|
23
26
|
*/
|
|
24
|
-
class
|
|
27
|
+
class Microphone extends Emitter {
|
|
25
28
|
constructor(options = {}) {
|
|
26
29
|
super();
|
|
27
30
|
|
|
@@ -35,9 +38,22 @@ class Decibri extends Emitter {
|
|
|
35
38
|
this._stopRequested = false;
|
|
36
39
|
|
|
37
40
|
// ── VAD state ─────────────────────────────────────────────────────────
|
|
38
|
-
|
|
41
|
+
// Single vad union: false (disabled, default) or 'energy'. The browser
|
|
42
|
+
// runs energy VAD only; Silero needs ONNX Runtime, which is Node-only. The
|
|
43
|
+
// legacy vad: true form is rejected with a migration error.
|
|
44
|
+
const vad = options.vad ?? false;
|
|
45
|
+
if (vad === false) {
|
|
46
|
+
this._vad = false;
|
|
47
|
+
} else if (vad === true) {
|
|
48
|
+
throw new TypeError("vad: true is no longer supported. Specify the mode explicitly: vad: 'energy'.");
|
|
49
|
+
} else if (vad === 'energy') {
|
|
50
|
+
this._vad = true;
|
|
51
|
+
} else {
|
|
52
|
+
throw new TypeError(`Invalid vad value: ${JSON.stringify(vad)}. Expected false or 'energy'.`);
|
|
53
|
+
}
|
|
39
54
|
this._vadThreshold = options.vadThreshold ?? 0.01;
|
|
40
55
|
this._vadHoldoff = options.vadHoldoff ?? 300;
|
|
56
|
+
this._vadScore = 0;
|
|
41
57
|
this._isSpeaking = false;
|
|
42
58
|
this._silenceTimer = null;
|
|
43
59
|
|
|
@@ -46,7 +62,7 @@ class Decibri extends Emitter {
|
|
|
46
62
|
this._channels = options.channels ?? 1;
|
|
47
63
|
this._framesPerBuffer = options.framesPerBuffer ?? 1600;
|
|
48
64
|
this._device = options.device;
|
|
49
|
-
this.
|
|
65
|
+
this._dtype = options.dtype ?? 'int16';
|
|
50
66
|
this._echoCancellation = options.echoCancellation ?? true;
|
|
51
67
|
this._noiseSuppression = options.noiseSuppression ?? true;
|
|
52
68
|
this._workletUrl = options.workletUrl;
|
|
@@ -61,8 +77,8 @@ class Decibri extends Emitter {
|
|
|
61
77
|
if (this._framesPerBuffer < 64 || this._framesPerBuffer > 65536) {
|
|
62
78
|
throw new TypeError(`frames per buffer must be between 64 and 65536, got ${this._framesPerBuffer}`);
|
|
63
79
|
}
|
|
64
|
-
if (this.
|
|
65
|
-
throw new TypeError("
|
|
80
|
+
if (this._dtype !== 'int16' && this._dtype !== 'float32') {
|
|
81
|
+
throw new TypeError("dtype must be 'int16' or 'float32'");
|
|
66
82
|
}
|
|
67
83
|
if (this._vadThreshold < 0 || this._vadThreshold > 1) {
|
|
68
84
|
throw new TypeError(`vadThreshold must be between 0 and 1, got ${this._vadThreshold}`);
|
|
@@ -143,6 +159,15 @@ class Decibri extends Emitter {
|
|
|
143
159
|
return this._started;
|
|
144
160
|
}
|
|
145
161
|
|
|
162
|
+
/**
|
|
163
|
+
* Most recent VAD score: the normalized RMS of the last chunk in `'energy'`
|
|
164
|
+
* mode, or 0 when VAD is disabled or before the first chunk is processed.
|
|
165
|
+
* @returns {number}
|
|
166
|
+
*/
|
|
167
|
+
get vadScore() {
|
|
168
|
+
return this._vadScore;
|
|
169
|
+
}
|
|
170
|
+
|
|
146
171
|
/**
|
|
147
172
|
* List available audio input devices.
|
|
148
173
|
* Device labels may be empty until microphone permission is granted.
|
|
@@ -217,7 +242,7 @@ class Decibri extends Emitter {
|
|
|
217
242
|
this._workletNode = new AudioWorkletNode(this._audioContext, 'decibri-processor', {
|
|
218
243
|
processorOptions: {
|
|
219
244
|
framesPerBuffer: this._framesPerBuffer,
|
|
220
|
-
format: this.
|
|
245
|
+
format: this._dtype,
|
|
221
246
|
nativeSampleRate,
|
|
222
247
|
targetSampleRate: this._sampleRate,
|
|
223
248
|
},
|
|
@@ -226,7 +251,7 @@ class Decibri extends Emitter {
|
|
|
226
251
|
// 5. Wire up data from worklet
|
|
227
252
|
this._workletNode.port.onmessage = (event) => {
|
|
228
253
|
const buffer = event.data;
|
|
229
|
-
const chunk = this.
|
|
254
|
+
const chunk = this._dtype === 'int16'
|
|
230
255
|
? new Int16Array(buffer)
|
|
231
256
|
: new Float32Array(buffer);
|
|
232
257
|
|
|
@@ -272,6 +297,7 @@ class Decibri extends Emitter {
|
|
|
272
297
|
|
|
273
298
|
_processVad(chunk) {
|
|
274
299
|
const rms = this._computeRms(chunk);
|
|
300
|
+
this._vadScore = rms;
|
|
275
301
|
|
|
276
302
|
if (rms >= this._vadThreshold) {
|
|
277
303
|
if (this._silenceTimer !== null) {
|
|
@@ -309,4 +335,4 @@ class Decibri extends Emitter {
|
|
|
309
335
|
}
|
|
310
336
|
}
|
|
311
337
|
|
|
312
|
-
module.exports = {
|
|
338
|
+
module.exports = { Microphone };
|
package/src/browser/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Information about an available audio input device (browser). */
|
|
2
|
-
export interface
|
|
2
|
+
export interface MicrophoneInfo {
|
|
3
3
|
/** Opaque device identifier (pass to constructor as `device`). */
|
|
4
4
|
deviceId: string;
|
|
5
5
|
/** Human-readable device name. May be empty until permission is granted. */
|
|
@@ -8,14 +8,15 @@ export interface DeviceInfo {
|
|
|
8
8
|
groupId: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
/** Version information.
|
|
11
|
+
/** Version information (browser). The browser surface has no native audio
|
|
12
|
+
* backend, so it reports only the decibri version. */
|
|
12
13
|
export interface VersionInfo {
|
|
13
|
-
/** decibri
|
|
14
|
+
/** decibri version. */
|
|
14
15
|
decibri: string;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
/** Constructor options for the browser `
|
|
18
|
-
export interface
|
|
18
|
+
/** Constructor options for the browser `Microphone` class. */
|
|
19
|
+
export interface MicrophoneOptions {
|
|
19
20
|
/**
|
|
20
21
|
* Target sample rate in Hz. Browser captures at native rate and resamples.
|
|
21
22
|
* @default 16000
|
|
@@ -38,24 +39,30 @@ export interface DecibriOptions {
|
|
|
38
39
|
framesPerBuffer?: number;
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
|
-
* Audio input device. Pass a deviceId string from `
|
|
42
|
+
* Audio input device. Pass a deviceId string from `Microphone.devices()`.
|
|
42
43
|
* Omit to use the system default input device.
|
|
43
44
|
*/
|
|
44
45
|
device?: string;
|
|
45
46
|
|
|
46
47
|
/**
|
|
47
|
-
* Sample encoding
|
|
48
|
+
* Sample encoding data type.
|
|
48
49
|
* - `'int16'`: Int16Array of PCM samples
|
|
49
50
|
* - `'float32'`: Float32Array of samples in [-1, 1]
|
|
50
51
|
* @default 'int16'
|
|
51
52
|
*/
|
|
52
|
-
|
|
53
|
+
dtype?: 'int16' | 'float32';
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
|
-
*
|
|
56
|
+
* Voice activity detection mode. One of:
|
|
57
|
+
* - `false`: disabled (default)
|
|
58
|
+
* - `'energy'`: RMS energy threshold
|
|
59
|
+
*
|
|
60
|
+
* The browser runs energy VAD only; Silero is Node-only. When enabled, emits
|
|
61
|
+
* `'speech'` and `'silence'` events and updates `vadScore`. The legacy
|
|
62
|
+
* `vad: true` form is rejected; specify the mode explicitly.
|
|
56
63
|
* @default false
|
|
57
64
|
*/
|
|
58
|
-
vad?:
|
|
65
|
+
vad?: false | 'energy';
|
|
59
66
|
|
|
60
67
|
/**
|
|
61
68
|
* RMS energy threshold for speech detection (VAD mode only).
|
|
@@ -95,9 +102,9 @@ export interface DecibriOptions {
|
|
|
95
102
|
*
|
|
96
103
|
* @example
|
|
97
104
|
* ```js
|
|
98
|
-
* import {
|
|
105
|
+
* import { Microphone } from 'decibri'; // browser entry via conditional export
|
|
99
106
|
*
|
|
100
|
-
* const mic = new
|
|
107
|
+
* const mic = new Microphone({ sampleRate: 16000 });
|
|
101
108
|
* mic.on('data', (chunk) => {
|
|
102
109
|
* // chunk is an Int16Array of PCM samples
|
|
103
110
|
* });
|
|
@@ -105,8 +112,8 @@ export interface DecibriOptions {
|
|
|
105
112
|
* mic.stop();
|
|
106
113
|
* ```
|
|
107
114
|
*/
|
|
108
|
-
export declare class
|
|
109
|
-
constructor(options?:
|
|
115
|
+
export declare class Microphone {
|
|
116
|
+
constructor(options?: MicrophoneOptions);
|
|
110
117
|
|
|
111
118
|
/**
|
|
112
119
|
* Start microphone capture.
|
|
@@ -121,11 +128,17 @@ export declare class Decibri {
|
|
|
121
128
|
/** Whether the microphone is currently capturing. */
|
|
122
129
|
readonly isOpen: boolean;
|
|
123
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Most recent VAD score: the normalized RMS of the last chunk in `'energy'`
|
|
133
|
+
* mode, or 0 when VAD is disabled or before the first chunk is processed.
|
|
134
|
+
*/
|
|
135
|
+
readonly vadScore: number;
|
|
136
|
+
|
|
124
137
|
/**
|
|
125
138
|
* List available audio input devices.
|
|
126
139
|
* Labels may be empty until microphone permission is granted.
|
|
127
140
|
*/
|
|
128
|
-
static devices(): Promise<
|
|
141
|
+
static devices(): Promise<MicrophoneInfo[]>;
|
|
129
142
|
|
|
130
143
|
/** Version information. */
|
|
131
144
|
static version(): VersionInfo;
|
package/src/browser/index.js
CHANGED