decibri 5.3.0 → 5.4.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 +22 -0
- package/LICENSE +191 -0
- package/README.md +1 -1
- package/examples/decibri.browser.js +1 -1
- package/index.d.ts +34 -5
- package/index.js +52 -52
- package/package.json +5 -5
- package/src/browser/decibri-browser.js +1 -1
- package/src/decibri.d.ts +124 -8
- package/src/decibri.js +203 -10
- package/src/errors.js +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,28 @@ For other decibri packages, see:
|
|
|
9
9
|
- Rust core: [crates/decibri/CHANGELOG.md](../../crates/decibri/CHANGELOG.md)
|
|
10
10
|
- Python package: [bindings/python/CHANGELOG.md](../../bindings/python/CHANGELOG.md)
|
|
11
11
|
|
|
12
|
+
## [5.4.0] - 2026-08-04
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- `File.save(path, options)` writes the conditioned recording to disk as 16-bit PCM mono at `sampleRate`, in WAV, AIFF or FLAC, off the event loop. The container comes from the path's extension (`.wav`, `.aiff`, `.aif`, `.aifc` or `.flac`) or from `options.format`: decibri reads a file by its content and writes one by its name, and an extension it does not recognise rejects rather than defaulting. `options.compression` sets the FLAC compression level, 0 to 8 with 5 the default. Resolves to a `SaveReport`: `clippedSamples` counts finite samples outside full scale clamped to `[-1.0, 1.0]`, and `nonFiniteSamples` counts non-finite samples that never reach the file (NaN is written as silence, an infinity as full scale). Saving consumes the source and rejects with `FILE_ENGAGED` once the stream is engaged, exactly as `analyze()` does.
|
|
17
|
+
- `AudioWriter`, a Writable file sink for PCM audio. Pipe a `File`, or any stream of int16 or float32 PCM bytes, into it and the whole stream is written as one audio file when it finishes, with the same containers, encoding, clamp and non-finite handling as `File.save`, so the two spellings produce the same bytes. Takes `sampleRate` (required), `dtype`, and the `File.save` options; `report` carries the `SaveReport` after `'finish'`.
|
|
18
|
+
- Error code `FILE_WRITE_FAILED` on `DecibriError`, for an encoded file the filesystem refuses to write. The message names the path and the underlying I/O failure.
|
|
19
|
+
- `File` reads AIFF, AIFF-C and FLAC as well as WAV, and reads WAV in mu-law, A-law, 8-bit and 24-bit as well as the 16-bit PCM and 32-bit float it already read. The container is identified from the file's own bytes, so the path's extension does not decide how a file is read. No option changes: the same `new File(path)` and `File.open(path)` open more files.
|
|
20
|
+
- Error code `AUDIO_FORMAT_UNSUPPORTED` on `DecibriError`, for a file in a container or an encoding decibri cannot decode. The message names the container tag, codec or sample width in question.
|
|
21
|
+
- Error code `AUDIO_FILE_MALFORMED` on `DecibriError`, for a file whose bytes are not what its format requires where they sit. The message names the byte offset and what was expected there.
|
|
22
|
+
- Error code `AUDIO_FILE_TRUNCATED` on `DecibriError`, for a file that ends before the audio it declares. The message names what was needed against what was available.
|
|
23
|
+
- `LICENSE`, the full Apache 2.0 text, in the published package.
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- **BREAKING: a WAV whose declared data length is not a whole number of frames now fails to open**, throwing a `DecibriError` with code `AUDIO_FILE_TRUNCATED`. It previously opened and delivered audio a fraction of a frame short of its own declaration, with nothing to indicate it. A file shorter than its declared length, which is what an interrupted download leaves behind, already failed to open and is unaffected.
|
|
28
|
+
- A file declaring no channels carries `AUDIO_FORMAT_UNSUPPORTED` where it carried `WAV_INVALID`.
|
|
29
|
+
|
|
30
|
+
### Removed
|
|
31
|
+
|
|
32
|
+
- **BREAKING: the `WAV_INVALID` error code.** `AUDIO_FORMAT_UNSUPPORTED`, `AUDIO_FILE_MALFORMED` and `AUDIO_FILE_TRUNCATED` replace it, splitting what was one failure into the three the caller acts on differently. Code branching on `err.code === 'WAV_INVALID'` must be updated; `catch (e) { if (e instanceof DecibriError) ... }` catches all three unchanged.
|
|
33
|
+
|
|
12
34
|
## [5.3.0] - 2026-07-31
|
|
13
35
|
|
|
14
36
|
### Added
|
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 Decibri
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -341,7 +341,7 @@ VAD reads the signal before the chain, so `vadScore` and the `'speech'` / `'sile
|
|
|
341
341
|
|
|
342
342
|
Everything a `Microphone` does to live audio, `File` does to audio you already have: the same conditioning options, the same Readable stream of conditioned chunks (finite: it ends at EOF), and the same opt-in `vad`. Because a `File` is a complete recording, it can also analyze the whole recording for speech.
|
|
343
343
|
|
|
344
|
-
- `await File.open(path, options?)`: read a
|
|
344
|
+
- `await File.open(path, options?)`: read a file off the event loop (recommended, like `Microphone.open`). Reads WAV, AIFF, AIFF-C and FLAC, identified from the file's own bytes rather than its extension.
|
|
345
345
|
- `new File(path, options?)`: the same result, synchronous (blocks on disk I/O; fine for scripts).
|
|
346
346
|
- `File.buffer(samples, options)`: wrap a `Float32Array` of samples you already hold. `options.inputRate` is required (raw samples carry no header); a raw `Buffer` of bytes is rejected as ambiguous.
|
|
347
347
|
- `await file.analyze()` (also spelled `analyse()`): consume the source and resolve to a `VadReport` of per-window `scores` (`{ start, end, vadScore, isSpeech }`) and merged speech `segments` (`{ start, end }`), in seconds of file time. Requires `vad: 'silero'`; a `File` opened without `vad` rejects with `analysis requires VAD`.
|
|
@@ -70,7 +70,7 @@ var decibri = (function() {
|
|
|
70
70
|
var require_decibri_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
71
71
|
const { Emitter } = require_emitter();
|
|
72
72
|
const { WORKLET_SOURCE } = require_worklet_inline();
|
|
73
|
-
const VERSION = "5.
|
|
73
|
+
const VERSION = "5.4.0";
|
|
74
74
|
/**
|
|
75
75
|
* Browser microphone capture.
|
|
76
76
|
*
|
package/index.d.ts
CHANGED
|
@@ -115,13 +115,14 @@ export declare class DecibriOutputBridge {
|
|
|
115
115
|
*/
|
|
116
116
|
export declare class FileHandle {
|
|
117
117
|
/**
|
|
118
|
-
* Open
|
|
119
|
-
* I/O; the JS wrapper's async `File.open` uses `openAsync`
|
|
118
|
+
* Open an audio path as an offline source, synchronously (blocks on
|
|
119
|
+
* disk I/O; the JS wrapper's async `File.open` uses `openAsync`
|
|
120
|
+
* instead).
|
|
120
121
|
*/
|
|
121
122
|
static open(path: string, options?: FileOptions | undefined | null): FileHandle
|
|
122
123
|
/**
|
|
123
|
-
* Open
|
|
124
|
-
*
|
|
124
|
+
* Open an audio path without blocking the JS event loop: the disk read,
|
|
125
|
+
* decode, and chain construction run on the libuv thread pool.
|
|
125
126
|
*/
|
|
126
127
|
static openAsync(path: string, options?: FileOptions | undefined | null): Promise<unknown>
|
|
127
128
|
/**
|
|
@@ -147,6 +148,15 @@ export declare class FileHandle {
|
|
|
147
148
|
* the configuration and retry.
|
|
148
149
|
*/
|
|
149
150
|
analyze(): Promise<unknown>
|
|
151
|
+
/**
|
|
152
|
+
* Consume the source and write the conditioned recording to disk, off
|
|
153
|
+
* the JS event loop. Resolves to the `SaveReport`.
|
|
154
|
+
*
|
|
155
|
+
* Everything checkable is checked before the source is taken, so a
|
|
156
|
+
* rejected call leaves the File exactly as it was and the caller can fix
|
|
157
|
+
* the arguments and retry.
|
|
158
|
+
*/
|
|
159
|
+
save(path: string, options?: SaveOptions | undefined | null): Promise<unknown>
|
|
150
160
|
/** Release the source. Idempotent; a closed File reads as ended. */
|
|
151
161
|
close(): void
|
|
152
162
|
/**
|
|
@@ -157,7 +167,7 @@ export declare class FileHandle {
|
|
|
157
167
|
/** The target output rate every delivered chunk carries. */
|
|
158
168
|
get sampleRate(): number
|
|
159
169
|
/**
|
|
160
|
-
* The source's native rate, from the
|
|
170
|
+
* The source's native rate, from the file's header or the explicit
|
|
161
171
|
* `inputRate` of `buffer`.
|
|
162
172
|
*/
|
|
163
173
|
get inputRate(): number
|
|
@@ -373,6 +383,25 @@ export interface OutputDeviceInfoJs {
|
|
|
373
383
|
isDefault: boolean
|
|
374
384
|
}
|
|
375
385
|
|
|
386
|
+
/**
|
|
387
|
+
* Options passed from the JS `File.save` wrapper: the container format
|
|
388
|
+
* override and the FLAC compression level.
|
|
389
|
+
*/
|
|
390
|
+
export interface SaveOptions {
|
|
391
|
+
format?: string
|
|
392
|
+
compression?: number
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* What a save did to the samples on their way into the file: finite
|
|
397
|
+
* samples outside full scale clamped and counted, non-finite samples
|
|
398
|
+
* replaced (NaN with silence, an infinity with full scale) and counted.
|
|
399
|
+
*/
|
|
400
|
+
export interface SaveReport {
|
|
401
|
+
clippedSamples: number
|
|
402
|
+
nonFiniteSamples: number
|
|
403
|
+
}
|
|
404
|
+
|
|
376
405
|
/** One merged speech region of a recording, in seconds of file time. */
|
|
377
406
|
export interface Segment {
|
|
378
407
|
start: number
|
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 !== '5.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
80
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
96
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
117
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
133
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
150
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
166
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
185
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
201
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
217
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
237
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
253
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
274
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
290
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
308
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
324
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
342
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
358
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
376
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
392
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
410
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
426
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
443
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
459
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
479
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
495
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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 !== '5.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 5.
|
|
511
|
+
if (bindingPackageVersion !== '5.4.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 5.4.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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "decibri",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
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",
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
"MIGRATION.md"
|
|
73
73
|
],
|
|
74
74
|
"optionalDependencies": {
|
|
75
|
-
"@decibri/decibri-win32-x64-msvc": "5.
|
|
76
|
-
"@decibri/decibri-darwin-arm64": "5.
|
|
77
|
-
"@decibri/decibri-linux-x64-gnu": "5.
|
|
78
|
-
"@decibri/decibri-linux-arm64-gnu": "5.
|
|
75
|
+
"@decibri/decibri-win32-x64-msvc": "5.4.0",
|
|
76
|
+
"@decibri/decibri-darwin-arm64": "5.4.0",
|
|
77
|
+
"@decibri/decibri-linux-x64-gnu": "5.4.0",
|
|
78
|
+
"@decibri/decibri-linux-arm64-gnu": "5.4.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@napi-rs/cli": "^3.7.0"
|
|
@@ -6,7 +6,7 @@ const { WORKLET_SOURCE } = require('./worklet-inline.js');
|
|
|
6
6
|
// Browser build version. Keep in sync with package.json on each release; the
|
|
7
7
|
// browser bundle cannot read package.json at runtime the way the Node wrapper
|
|
8
8
|
// does, so this is a maintained constant.
|
|
9
|
-
const VERSION = '5.
|
|
9
|
+
const VERSION = '5.4.0';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Browser microphone capture.
|
package/src/decibri.d.ts
CHANGED
|
@@ -423,7 +423,7 @@ export declare class Microphone extends Readable {
|
|
|
423
423
|
export interface FileOptions extends ReadableOptions {
|
|
424
424
|
/**
|
|
425
425
|
* Target output rate in Hz: the rate every delivered chunk carries. The
|
|
426
|
-
* source's input rate (from the
|
|
426
|
+
* source's input rate (from the file's header, or `inputRate` for
|
|
427
427
|
* `File.buffer`) is resampled to this rate, so a 44.1 kHz recording comes
|
|
428
428
|
* out at 16 kHz unless you set `sampleRate`. The same meaning the option
|
|
429
429
|
* has on `Microphone`.
|
|
@@ -551,6 +551,46 @@ export interface VadReport {
|
|
|
551
551
|
segments: Segment[];
|
|
552
552
|
}
|
|
553
553
|
|
|
554
|
+
/** Options for `File.save` (also accepted by `AudioWriter`). */
|
|
555
|
+
export interface SaveOptions {
|
|
556
|
+
/**
|
|
557
|
+
* The container format to write. When not given it comes from the path's
|
|
558
|
+
* extension: `.wav`, `.aiff`, `.aif`, `.aifc` or `.flac`. decibri reads a
|
|
559
|
+
* file by its content and writes one by its name; an extension it does not
|
|
560
|
+
* recognise is an error, never a silent default.
|
|
561
|
+
*/
|
|
562
|
+
format?: 'wav' | 'aiff' | 'flac';
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* FLAC compression level. Higher levels search harder for a smaller file;
|
|
566
|
+
* every level decodes to identical audio. Applies only to FLAC; ignored
|
|
567
|
+
* for WAV and AIFF.
|
|
568
|
+
* @default 5
|
|
569
|
+
* @range 0 to 8
|
|
570
|
+
*/
|
|
571
|
+
compression?: number;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* What a save did to the samples on their way into the file, resolved by
|
|
576
|
+
* `File.save` and carried by `AudioWriter.report`.
|
|
577
|
+
*/
|
|
578
|
+
export interface SaveReport {
|
|
579
|
+
/**
|
|
580
|
+
* Finite samples outside full scale, clamped to [-1.0, 1.0]. Conditioned
|
|
581
|
+
* audio can exceed full scale (AGC or AEC without a limiter), and 16-bit
|
|
582
|
+
* PCM cannot hold that, so the overshoot clips and this count says how
|
|
583
|
+
* much. The count is a statement about integer encodings: a float encoding
|
|
584
|
+
* would preserve the overshoot instead, and would report zero.
|
|
585
|
+
*/
|
|
586
|
+
clippedSamples: number;
|
|
587
|
+
/**
|
|
588
|
+
* Non-finite samples replaced before writing: NaN with silence, an
|
|
589
|
+
* infinity with full scale. The same replacement on every format.
|
|
590
|
+
*/
|
|
591
|
+
nonFiniteSamples: number;
|
|
592
|
+
}
|
|
593
|
+
|
|
554
594
|
/**
|
|
555
595
|
* Offline audio source: conditions a recording or in-memory samples through
|
|
556
596
|
* the same chain as the live `Microphone`, delivered as a finite Readable
|
|
@@ -559,7 +599,7 @@ export interface VadReport {
|
|
|
559
599
|
* analyze the whole recording for speech with `analyze()` / `analyse()`,
|
|
560
600
|
* which a live stream cannot do.
|
|
561
601
|
*
|
|
562
|
-
* Construction: `new File(path)` reads the
|
|
602
|
+
* Construction: `new File(path)` reads the file synchronously (fine for a
|
|
563
603
|
* script; it blocks the event loop on disk I/O), `await File.open(path)` reads
|
|
564
604
|
* it off the event loop (the recommended form, mirroring `Microphone.open`),
|
|
565
605
|
* and `File.buffer(samples, { inputRate })` wraps a `Float32Array` of samples
|
|
@@ -586,15 +626,16 @@ export interface VadReport {
|
|
|
586
626
|
*/
|
|
587
627
|
export declare class File extends Readable {
|
|
588
628
|
/**
|
|
589
|
-
* Open
|
|
590
|
-
* in servers).
|
|
591
|
-
*
|
|
629
|
+
* Open an audio file synchronously (blocks on disk I/O; prefer `File.open`
|
|
630
|
+
* in servers). Reads WAV, AIFF, AIFF-C and FLAC, identified from the
|
|
631
|
+
* file's own bytes rather than its extension; the input rate and channel
|
|
632
|
+
* count come from the header.
|
|
592
633
|
*/
|
|
593
634
|
constructor(path: string, options?: FileOptions);
|
|
594
635
|
|
|
595
636
|
/**
|
|
596
|
-
* Open
|
|
597
|
-
*
|
|
637
|
+
* Open an audio file without blocking the event loop: the disk read,
|
|
638
|
+
* decode, and chain construction run on the native thread pool. The
|
|
598
639
|
* recommended form, mirroring `Microphone.open`.
|
|
599
640
|
*/
|
|
600
641
|
static open(path: string, options?: FileOptions): Promise<File>;
|
|
@@ -622,7 +663,7 @@ export declare class File extends Readable {
|
|
|
622
663
|
readonly sampleRate: number;
|
|
623
664
|
|
|
624
665
|
/**
|
|
625
|
-
* The source's own rate, taken from the
|
|
666
|
+
* The source's own rate, taken from the file's header or from the
|
|
626
667
|
* `inputRate` passed to `File.buffer`. Differs from `sampleRate` when the
|
|
627
668
|
* source was resampled.
|
|
628
669
|
*/
|
|
@@ -646,6 +687,26 @@ export declare class File extends Readable {
|
|
|
646
687
|
/** The same whole-recording analysis under the international spelling. */
|
|
647
688
|
analyse(): Promise<VadReport>;
|
|
648
689
|
|
|
690
|
+
/**
|
|
691
|
+
* Write the conditioned recording to disk, off the event loop. Runs the
|
|
692
|
+
* recording once through the same conditioning pass iteration delivers,
|
|
693
|
+
* whole, and writes it as 16-bit PCM mono at `sampleRate`. The container
|
|
694
|
+
* comes from the path's extension (`.wav`, `.aiff`, `.aif`, `.aifc` or
|
|
695
|
+
* `.flac`), or from `options.format`: decibri reads a file by its content
|
|
696
|
+
* and writes one by its name. Consumes the source (a `File` is a single
|
|
697
|
+
* pass).
|
|
698
|
+
*
|
|
699
|
+
* Resolves to a `SaveReport`: how many samples were clamped to full scale
|
|
700
|
+
* and how many non-finite samples were replaced (NaN as silence, an
|
|
701
|
+
* infinity as full scale).
|
|
702
|
+
*
|
|
703
|
+
* Requires a File that is not already being streamed: once the stream has
|
|
704
|
+
* been engaged this rejects with a `DecibriError` carrying the code
|
|
705
|
+
* `'FILE_ENGAGED'`. Every failure detected before the pass begins leaves
|
|
706
|
+
* the File usable; a failure during the pass consumes the source.
|
|
707
|
+
*/
|
|
708
|
+
save(path: string, options?: SaveOptions): Promise<SaveReport>;
|
|
709
|
+
|
|
649
710
|
/** Release the source. Idempotent; a closed File reads as ended. */
|
|
650
711
|
close(): void;
|
|
651
712
|
|
|
@@ -666,6 +727,61 @@ export declare class File extends Readable {
|
|
|
666
727
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
667
728
|
}
|
|
668
729
|
|
|
730
|
+
/** Constructor options for `AudioWriter`: the save options plus the stream's own description. */
|
|
731
|
+
export interface AudioWriterOptions extends SaveOptions, WritableOptions {
|
|
732
|
+
/**
|
|
733
|
+
* The rate of the incoming samples in Hz, written into the file's header.
|
|
734
|
+
* Required: raw audio carries no header to read a rate from.
|
|
735
|
+
* @range 1000 to 384000
|
|
736
|
+
*/
|
|
737
|
+
sampleRate: number;
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Number of channels. Audio is written mono; only `1` is accepted.
|
|
741
|
+
* @default 1
|
|
742
|
+
*/
|
|
743
|
+
channels?: 1;
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Sample encoding of the incoming bytes.
|
|
747
|
+
* - `'int16'`: 16-bit signed integer, little-endian, what a `File` or
|
|
748
|
+
* `Microphone` emits by default
|
|
749
|
+
* - `'float32'`: 32-bit IEEE 754 float, little-endian
|
|
750
|
+
* @default 'int16'
|
|
751
|
+
*/
|
|
752
|
+
dtype?: 'int16' | 'float32';
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* A file sink for PCM audio: the Writable to pair with decibri's Readable
|
|
757
|
+
* sources, and with any other stream of PCM bytes (a TTS engine, a decoded
|
|
758
|
+
* network stream). Collects the whole stream, then writes it as one audio
|
|
759
|
+
* file when the stream finishes, exactly as `File.save` writes: the same
|
|
760
|
+
* containers from the same extension rule, the same 16-bit PCM encoding, the
|
|
761
|
+
* same clamp and non-finite handling, the same bytes.
|
|
762
|
+
*
|
|
763
|
+
* `'finish'` fires after the file is on disk, and `report` then carries the
|
|
764
|
+
* `SaveReport` the write produced. A failure destroys the stream with the
|
|
765
|
+
* error.
|
|
766
|
+
*
|
|
767
|
+
* @example
|
|
768
|
+
* const { pipeline } = require('node:stream/promises');
|
|
769
|
+
* const { File, AudioWriter } = require('decibri');
|
|
770
|
+
* await pipeline(
|
|
771
|
+
* new File('noisy.wav', { denoise: 'fastenhancer-t' }),
|
|
772
|
+
* new AudioWriter('clean.flac', { sampleRate: 16000 }),
|
|
773
|
+
* );
|
|
774
|
+
*/
|
|
775
|
+
export declare class AudioWriter extends Writable {
|
|
776
|
+
constructor(path: string, options: AudioWriterOptions);
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* The `SaveReport` of the completed write, exactly as `File.save` resolves
|
|
780
|
+
* it. `null` until `'finish'` has fired.
|
|
781
|
+
*/
|
|
782
|
+
readonly report: SaveReport | null;
|
|
783
|
+
}
|
|
784
|
+
|
|
669
785
|
export interface SpeakerInfo {
|
|
670
786
|
/** Device index (pass to constructor as `device`). */
|
|
671
787
|
index: number;
|
package/src/decibri.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const { Readable } = require('stream');
|
|
3
|
+
const { Readable, Writable } = require('stream');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const { DecibriBridge, FileHandle } = require('../index.js');
|
|
@@ -714,19 +714,20 @@ function version() {
|
|
|
714
714
|
|
|
715
715
|
class File extends Readable {
|
|
716
716
|
/**
|
|
717
|
-
* Open
|
|
717
|
+
* Open an audio file as an offline source, synchronously. Everything a
|
|
718
718
|
* `Microphone` does to live audio, a `File` does to audio you already
|
|
719
719
|
* have: the same conditioning options, the same stream of conditioned
|
|
720
720
|
* chunks, and (with `vad` set) the same per-chunk speech events, plus the
|
|
721
721
|
* whole-file `analyze()` a live stream cannot offer.
|
|
722
722
|
*
|
|
723
|
-
* The bare constructor reads the
|
|
723
|
+
* The bare constructor reads the file inline, blocking the event loop on
|
|
724
724
|
* disk I/O; prefer `await File.open(path, options)` in servers and other
|
|
725
725
|
* latency-sensitive code, exactly as `Microphone.open` is preferred over
|
|
726
726
|
* `new Microphone`. Iteration and analysis are separate single passes:
|
|
727
727
|
* each consumes the source once, so use one `File` per operation.
|
|
728
728
|
*
|
|
729
|
-
* @param {string} filePath Path to a WAV
|
|
729
|
+
* @param {string} filePath Path to a WAV, AIFF, AIFF-C or FLAC file. The
|
|
730
|
+
* container is identified from the bytes, not from the extension.
|
|
730
731
|
* @param {import('./decibri').FileOptions} [options]
|
|
731
732
|
* @param {{ prepared: object, native: object }} [_internal] Internal: a
|
|
732
733
|
* pre-resolved options bundle and an already-constructed native handle,
|
|
@@ -932,8 +933,8 @@ class File extends Readable {
|
|
|
932
933
|
}
|
|
933
934
|
|
|
934
935
|
/**
|
|
935
|
-
* Open
|
|
936
|
-
*
|
|
936
|
+
* Open an audio file without blocking the event loop: the disk read,
|
|
937
|
+
* decode, and chain construction run on the native thread pool. The
|
|
937
938
|
* recommended form in Node, mirroring `Microphone.open`. The synchronous
|
|
938
939
|
* `new File(path)` remains available for scripts.
|
|
939
940
|
*
|
|
@@ -1132,10 +1133,10 @@ class File extends Readable {
|
|
|
1132
1133
|
}
|
|
1133
1134
|
|
|
1134
1135
|
/**
|
|
1135
|
-
* The source's own rate, taken from the
|
|
1136
|
-
* passed to `File.buffer`. Differs from `sampleRate` when the
|
|
1137
|
-
* resampled. Readable for the life of the File, including after
|
|
1138
|
-
* is consumed or closed.
|
|
1136
|
+
* The source's own rate, taken from the file's header or from the
|
|
1137
|
+
* `inputRate` passed to `File.buffer`. Differs from `sampleRate` when the
|
|
1138
|
+
* source was resampled. Readable for the life of the File, including after
|
|
1139
|
+
* the source is consumed or closed.
|
|
1139
1140
|
* @returns {number}
|
|
1140
1141
|
*/
|
|
1141
1142
|
get inputRate() {
|
|
@@ -1190,6 +1191,77 @@ class File extends Readable {
|
|
|
1190
1191
|
return this.analyze();
|
|
1191
1192
|
}
|
|
1192
1193
|
|
|
1194
|
+
/**
|
|
1195
|
+
* Validate the save options and resolve them into the native options
|
|
1196
|
+
* object. Shared by `File.save` and `AudioWriter`, so the two spellings of
|
|
1197
|
+
* a write accept and reject identically.
|
|
1198
|
+
* @internal
|
|
1199
|
+
* @param {import('./decibri').SaveOptions} options
|
|
1200
|
+
*/
|
|
1201
|
+
static _prepareSaveOptions(options) {
|
|
1202
|
+
const format = options.format;
|
|
1203
|
+
if (format !== undefined && format !== 'wav' && format !== 'aiff' && format !== 'flac') {
|
|
1204
|
+
throw new TypeError(
|
|
1205
|
+
`Invalid format value: ${JSON.stringify(format)}. Expected 'wav', 'aiff', or 'flac'.`
|
|
1206
|
+
);
|
|
1207
|
+
}
|
|
1208
|
+
const compression = options.compression;
|
|
1209
|
+
if (compression !== undefined) {
|
|
1210
|
+
if (typeof compression !== 'number' || Number.isNaN(compression)) {
|
|
1211
|
+
throw new TypeError('compression must be a number');
|
|
1212
|
+
}
|
|
1213
|
+
if (compression < 0 || compression > 8) {
|
|
1214
|
+
throw new RangeError('flac compression level must be between 0 and 8');
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
return { format, compression };
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* Write the conditioned recording to disk, off the event loop. Runs the
|
|
1222
|
+
* recording once through the same conditioning pass iteration delivers,
|
|
1223
|
+
* whole, and writes it as 16-bit PCM mono at `sampleRate`. Consumes the
|
|
1224
|
+
* source: a save is a single pass, separate from iteration and analysis.
|
|
1225
|
+
*
|
|
1226
|
+
* The container comes from the path's extension (`.wav`, `.aiff`, `.aif`,
|
|
1227
|
+
* `.aifc` or `.flac`), or from `options.format`: decibri reads a file by
|
|
1228
|
+
* its content and writes one by its name. An extension it does not
|
|
1229
|
+
* recognise rejects rather than defaulting. `options.compression` sets the
|
|
1230
|
+
* FLAC compression level (0-8, default 5); it applies only to FLAC.
|
|
1231
|
+
*
|
|
1232
|
+
* Resolves to a `SaveReport`: `clippedSamples` counts finite samples
|
|
1233
|
+
* outside full scale clamped to `[-1.0, 1.0]` (AGC or AEC without a
|
|
1234
|
+
* limiter can overshoot, and 16-bit PCM cannot hold it), and
|
|
1235
|
+
* `nonFiniteSamples` counts NaN samples written as silence and infinite
|
|
1236
|
+
* samples written as full scale.
|
|
1237
|
+
*
|
|
1238
|
+
* Requires a `File` that is not already being streamed: once the stream
|
|
1239
|
+
* has been engaged this rejects with a `DecibriError` carrying the code
|
|
1240
|
+
* `'FILE_ENGAGED'`. Every failure detected before the pass begins leaves
|
|
1241
|
+
* the `File` usable; a failure during the pass consumes the source.
|
|
1242
|
+
*
|
|
1243
|
+
* @param {string} filePath
|
|
1244
|
+
* @param {import('./decibri').SaveOptions} [options]
|
|
1245
|
+
* @returns {Promise<import('./decibri').SaveReport>}
|
|
1246
|
+
*/
|
|
1247
|
+
async save(filePath, options = {}) {
|
|
1248
|
+
// Checked before the native handle is touched: the rejection belongs to
|
|
1249
|
+
// this call, and the source is never taken from a File that keeps
|
|
1250
|
+
// streaming.
|
|
1251
|
+
if (this._engaged) {
|
|
1252
|
+
throw fileEngagedError();
|
|
1253
|
+
}
|
|
1254
|
+
if (typeof filePath !== 'string') {
|
|
1255
|
+
throw new TypeError('path must be a string');
|
|
1256
|
+
}
|
|
1257
|
+
const nativeOptions = File._prepareSaveOptions(options);
|
|
1258
|
+
try {
|
|
1259
|
+
return await this._native.save(filePath, nativeOptions);
|
|
1260
|
+
} catch (err) {
|
|
1261
|
+
throw wrapNativeError(err);
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1193
1265
|
/**
|
|
1194
1266
|
* Release the source. Idempotent; a closed File reads as ended.
|
|
1195
1267
|
*/
|
|
@@ -1198,10 +1270,131 @@ class File extends Readable {
|
|
|
1198
1270
|
}
|
|
1199
1271
|
}
|
|
1200
1272
|
|
|
1273
|
+
// ─── AudioWriter (Writable): file sink ───────────────────────────────────────
|
|
1274
|
+
|
|
1275
|
+
class AudioWriter extends Writable {
|
|
1276
|
+
/**
|
|
1277
|
+
* A file sink for PCM audio: the Writable to pair with decibri's Readable
|
|
1278
|
+
* sources, and with any other stream of PCM bytes (a TTS engine, a decoded
|
|
1279
|
+
* network stream). Collects the whole stream, then writes it as one audio
|
|
1280
|
+
* file when the stream finishes, exactly as `File.save` writes: the same
|
|
1281
|
+
* containers from the same extension rule, the same 16-bit PCM encoding,
|
|
1282
|
+
* the same clamp and non-finite handling, the same bytes.
|
|
1283
|
+
*
|
|
1284
|
+
* Chunks are raw PCM bytes in `dtype` ('int16' little-endian by default,
|
|
1285
|
+
* matching what a `File` or `Microphone` emits; 'float32' for raw f32
|
|
1286
|
+
* bytes). Audio is written mono: `channels` may only be 1. `sampleRate` is
|
|
1287
|
+
* required, because raw audio carries no header to read one from.
|
|
1288
|
+
*
|
|
1289
|
+
* The file is written when the stream finishes ('finish' fires after the
|
|
1290
|
+
* file is on disk), and `report` then carries the `SaveReport` the write
|
|
1291
|
+
* produced. A failure destroys the stream with the error.
|
|
1292
|
+
*
|
|
1293
|
+
* @param {string} filePath Path whose extension names the container,
|
|
1294
|
+
* unless `format` overrides it.
|
|
1295
|
+
* @param {import('./decibri').AudioWriterOptions} options
|
|
1296
|
+
*/
|
|
1297
|
+
constructor(filePath, options = {}) {
|
|
1298
|
+
super({ highWaterMark: options.highWaterMark });
|
|
1299
|
+
if (typeof filePath !== 'string') {
|
|
1300
|
+
throw new TypeError('path must be a string');
|
|
1301
|
+
}
|
|
1302
|
+
const sampleRate = options.sampleRate;
|
|
1303
|
+
if (typeof sampleRate !== 'number' || Number.isNaN(sampleRate)) {
|
|
1304
|
+
throw new TypeError('sampleRate is required for AudioWriter (raw audio carries no header)');
|
|
1305
|
+
}
|
|
1306
|
+
if (sampleRate < 1000 || sampleRate > 384000) {
|
|
1307
|
+
throw new RangeError('sample rate must be between 1000 and 384000');
|
|
1308
|
+
}
|
|
1309
|
+
const channels = options.channels;
|
|
1310
|
+
if (channels !== undefined && channels !== 1) {
|
|
1311
|
+
throw new RangeError('multichannel write is not supported; channels must be 1 (mono)');
|
|
1312
|
+
}
|
|
1313
|
+
const dtype = options.dtype ?? 'int16';
|
|
1314
|
+
if (dtype !== 'int16' && dtype !== 'float32') {
|
|
1315
|
+
throw new TypeError("dtype must be 'int16' or 'float32'");
|
|
1316
|
+
}
|
|
1317
|
+
// Validated now, so a bad option is a construction-time throw rather
|
|
1318
|
+
// than a deferred 'error' event after the audio has been streamed.
|
|
1319
|
+
this._saveOptions = File._prepareSaveOptions(options);
|
|
1320
|
+
this._filePath = filePath;
|
|
1321
|
+
this._sampleRate = sampleRate;
|
|
1322
|
+
this._dtype = dtype;
|
|
1323
|
+
this._chunks = [];
|
|
1324
|
+
this._report = null;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
/**
|
|
1328
|
+
* The `SaveReport` of the completed write: `clippedSamples` and
|
|
1329
|
+
* `nonFiniteSamples`, exactly as `File.save` resolves. `null` until
|
|
1330
|
+
* 'finish' has fired.
|
|
1331
|
+
* @returns {import('./decibri').SaveReport | null}
|
|
1332
|
+
*/
|
|
1333
|
+
get report() {
|
|
1334
|
+
return this._report;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
/** @internal */
|
|
1338
|
+
_write(chunk, encoding, callback) {
|
|
1339
|
+
this._chunks.push(chunk);
|
|
1340
|
+
callback();
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
/** @internal */
|
|
1344
|
+
_final(callback) {
|
|
1345
|
+
const bytes = Buffer.concat(this._chunks);
|
|
1346
|
+
this._chunks = [];
|
|
1347
|
+
const bytesPerSample = this._dtype === 'int16' ? 2 : 4;
|
|
1348
|
+
if (bytes.length % bytesPerSample !== 0) {
|
|
1349
|
+
callback(
|
|
1350
|
+
new RangeError(
|
|
1351
|
+
`audio bytes do not divide into whole ${this._dtype} samples; ` +
|
|
1352
|
+
`${bytes.length % bytesPerSample} byte(s) over`
|
|
1353
|
+
)
|
|
1354
|
+
);
|
|
1355
|
+
return;
|
|
1356
|
+
}
|
|
1357
|
+
const samples = new Float32Array(bytes.length / bytesPerSample);
|
|
1358
|
+
if (this._dtype === 'int16') {
|
|
1359
|
+
// The inverse of the int16 delivery encoding: value / 32768, so bytes
|
|
1360
|
+
// that came from a decibri source re-quantise to the identical file.
|
|
1361
|
+
for (let i = 0; i < samples.length; i++) {
|
|
1362
|
+
samples[i] = bytes.readInt16LE(i * 2) / 32768;
|
|
1363
|
+
}
|
|
1364
|
+
} else {
|
|
1365
|
+
for (let i = 0; i < samples.length; i++) {
|
|
1366
|
+
samples[i] = bytes.readFloatLE(i * 4);
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
// The write is File.save on a source at the writer's own rate: the same
|
|
1370
|
+
// encode path, so the two spellings produce the same bytes.
|
|
1371
|
+
let file;
|
|
1372
|
+
try {
|
|
1373
|
+
file = File.buffer(samples, {
|
|
1374
|
+
inputRate: this._sampleRate,
|
|
1375
|
+
sampleRate: this._sampleRate,
|
|
1376
|
+
});
|
|
1377
|
+
} catch (err) {
|
|
1378
|
+
callback(err);
|
|
1379
|
+
return;
|
|
1380
|
+
}
|
|
1381
|
+
file
|
|
1382
|
+
.save(this._filePath, this._saveOptions)
|
|
1383
|
+
.then((report) => {
|
|
1384
|
+
this._report = report;
|
|
1385
|
+
callback();
|
|
1386
|
+
})
|
|
1387
|
+
.catch((err) => {
|
|
1388
|
+
callback(err);
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1201
1393
|
module.exports = {
|
|
1202
1394
|
Microphone,
|
|
1203
1395
|
Speaker,
|
|
1204
1396
|
File,
|
|
1397
|
+
AudioWriter,
|
|
1205
1398
|
inputDevices,
|
|
1206
1399
|
outputDevices,
|
|
1207
1400
|
version,
|
package/src/errors.js
CHANGED
|
@@ -80,6 +80,7 @@ const RANGE_PREFIXES = [
|
|
|
80
80
|
'frames per buffer must be between',
|
|
81
81
|
'agc target level must be between',
|
|
82
82
|
'limiter ceiling must be between',
|
|
83
|
+
'flac compression level must be between',
|
|
83
84
|
'aec tailMs must be between',
|
|
84
85
|
'aec referenceSampleRate must be between',
|
|
85
86
|
'Silero VAD only supports',
|
|
@@ -93,6 +94,7 @@ const TYPE_PREFIXES = [
|
|
|
93
94
|
"dtype must be 'int16' or 'float32'",
|
|
94
95
|
"format must be 'int16' or 'float32'",
|
|
95
96
|
'aec suppression must be',
|
|
97
|
+
'Invalid format value:',
|
|
96
98
|
];
|
|
97
99
|
|
|
98
100
|
const DEVICE_CODES = [
|
|
@@ -132,7 +134,10 @@ const BASE_CODES = [
|
|
|
132
134
|
['resampler error:', 'RESAMPLE_FAILED'],
|
|
133
135
|
['echo canceller configuration error:', 'AEC_CONFIG_INVALID'],
|
|
134
136
|
['Failed to read audio file', 'FILE_READ_FAILED'],
|
|
135
|
-
['
|
|
137
|
+
['Failed to write audio file', 'FILE_WRITE_FAILED'],
|
|
138
|
+
['unsupported audio format:', 'AUDIO_FORMAT_UNSUPPORTED'],
|
|
139
|
+
['malformed audio file:', 'AUDIO_FILE_MALFORMED'],
|
|
140
|
+
['truncated audio file:', 'AUDIO_FILE_TRUNCATED'],
|
|
136
141
|
['ONNX Runtime was initialized in pid', 'FORK_AFTER_ORT_INIT'],
|
|
137
142
|
['ONNX backend error from', 'ONNX_BACKEND_FAILED'],
|
|
138
143
|
// Authored in the napi layer (bindings/node/src/lib.rs), not in
|