decibri 3.4.0 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -145
- package/examples/wav-capture.js +48 -0
- package/examples/websocket-server.js +29 -0
- package/examples/websocket-stream.js +44 -0
- package/index.js +52 -52
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -1,53 +1,6 @@
|
|
|
1
|
-
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
-
<div align="center">
|
|
3
|
-
<img width="100" height="100" alt="decibri" src="https://github.com/user-attachments/assets/a1a7aa23-6954-4cac-9490-76354f0865ee" />
|
|
4
|
-
|
|
5
1
|
# decibri
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<!-- badges: start -->
|
|
10
|
-
<table>
|
|
11
|
-
<tr>
|
|
12
|
-
<td><strong>Meta</strong></td>
|
|
13
|
-
<td>
|
|
14
|
-
<a href="https://pypi.org/project/decibri/"><img src="https://img.shields.io/pypi/v/decibri" alt="PyPI version"></a>
|
|
15
|
-
<a href="https://www.npmjs.com/package/decibri"><img src="https://img.shields.io/npm/v/decibri" alt="npm version"></a>
|
|
16
|
-
<a href="https://crates.io/crates/decibri"><img src="https://img.shields.io/crates/v/decibri" alt="crates.io version"></a>
|
|
17
|
-
<a href="https://github.com/decibri/decibri/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg" alt="Apache 2.0 License"></a>
|
|
18
|
-
<a href="https://decibri.com"><img src="https://img.shields.io/badge/Website-decibri.com-blue" alt="decibri.com"></a>
|
|
19
|
-
<a href="https://decibri.com/docs/"><img src="https://img.shields.io/badge/docs-passing-brightgreen" alt="Docs"></a>
|
|
20
|
-
</td>
|
|
21
|
-
</tr>
|
|
22
|
-
<tr>
|
|
23
|
-
<td><strong>Binaries</strong></td>
|
|
24
|
-
<td>
|
|
25
|
-
<a href="https://github.com/decibri/decibri/actions/workflows/release.yml"><img src="https://img.shields.io/github/actions/workflow/status/decibri/decibri/release.yml?job=Build%20x86_64-pc-windows-msvc&label=Windows%20x64&logo=microsoft&logoColor=white" alt="Windows x64"></a>
|
|
26
|
-
<a href="https://github.com/decibri/decibri/actions/workflows/release.yml"><img src="https://img.shields.io/github/actions/workflow/status/decibri/decibri/release.yml?job=Build%20aarch64-apple-darwin&label=macOS%20ARM64&logo=apple" alt="macOS ARM64"></a>
|
|
27
|
-
<a href="https://github.com/decibri/decibri/actions/workflows/release.yml"><img src="https://img.shields.io/github/actions/workflow/status/decibri/decibri/release.yml?job=Build%20x86_64-unknown-linux-gnu&label=Linux%20x64&logo=linux&logoColor=white" alt="Linux x64"></a>
|
|
28
|
-
<a href="https://github.com/decibri/decibri/actions/workflows/release.yml"><img src="https://img.shields.io/github/actions/workflow/status/decibri/decibri/release.yml?job=Build%20aarch64-unknown-linux-gnu&label=Linux%20ARM64&logo=linux&logoColor=white" alt="Linux ARM64"></a>
|
|
29
|
-
</td>
|
|
30
|
-
</tr>
|
|
31
|
-
<tr>
|
|
32
|
-
<tr>
|
|
33
|
-
<td><strong>Integrations</strong></td>
|
|
34
|
-
<td>
|
|
35
|
-
<a href="https://decibri.com/docs/node/integrations/openai-realtime"><img src="https://img.shields.io/badge/OpenAI-cloud-blue" alt="OpenAI"></a>
|
|
36
|
-
<a href="https://decibri.com/docs/node/integrations/deepgram"><img src="https://img.shields.io/badge/Deepgram-cloud-blue" alt="Deepgram"></a>
|
|
37
|
-
<a href="https://decibri.com/docs/node/integrations/assemblyai"><img src="https://img.shields.io/badge/AssemblyAI-cloud-blue" alt="AssemblyAI"></a>
|
|
38
|
-
<a href="https://decibri.com/docs/node/integrations/mistral-voxtral"><img src="https://img.shields.io/badge/Mistral-cloud-blue" alt="Mistral"></a>
|
|
39
|
-
<a href="https://decibri.com/docs/node/integrations/aws-transcribe"><img src="https://img.shields.io/badge/AWS_Transcribe-cloud-blue" alt="AWS Transcribe"></a>
|
|
40
|
-
<a href="https://decibri.com/docs/node/integrations/google-speech"><img src="https://img.shields.io/badge/Google_Speech-cloud-blue" alt="Google Speech-to-Text"></a>
|
|
41
|
-
<a href="https://decibri.com/docs/node/integrations/azure-speech"><img src="https://img.shields.io/badge/Azure_Speech-cloud-blue" alt="Azure Speech-to-Text"></a>
|
|
42
|
-
<a href="https://decibri.com/docs/node/integrations/sherpa-onnx-stt"><img src="https://img.shields.io/badge/Sherpa--ONNX-local-brightgreen" alt="Sherpa-ONNX"></a>
|
|
43
|
-
<a href="https://decibri.com/docs/node/integrations/whisper-cpp"><img src="https://img.shields.io/badge/Whisper.cpp-local-brightgreen" alt="Whisper.cpp"></a>
|
|
44
|
-
</td>
|
|
45
|
-
</tr>
|
|
46
|
-
</table>
|
|
47
|
-
<!-- badges: end -->
|
|
48
|
-
</div>
|
|
49
|
-
|
|
50
|
-
---
|
|
3
|
+
Cross-platform audio capture, output, and voice activity detection for Node.js and browsers.
|
|
51
4
|
|
|
52
5
|
## Installation
|
|
53
6
|
|
|
@@ -59,51 +12,6 @@ One package for Node.js and browsers. Node.js gets a native addon (Rust via napi
|
|
|
59
12
|
|
|
60
13
|
Requires Node.js >= 18. TypeScript definitions are bundled.
|
|
61
14
|
|
|
62
|
-
---
|
|
63
|
-
|
|
64
|
-
## Using from Rust
|
|
65
|
-
|
|
66
|
-
Most users want the npm package above. If you're building a Rust
|
|
67
|
-
application directly against the [`decibri`](https://crates.io/crates/decibri) crate on crates.io:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
cargo add decibri
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
The `vad` feature (enabled by default) uses ONNX Runtime via the
|
|
74
|
-
[`ort`](https://crates.io/crates/ort) crate. From 3.1.0 onwards, `ort` is
|
|
75
|
-
configured with `load-dynamic` by default, meaning ONNX Runtime is loaded
|
|
76
|
-
from a shared library at runtime. Choose one of:
|
|
77
|
-
|
|
78
|
-
- **Zero-config builds.** Opt into the download-binaries mode:
|
|
79
|
-
|
|
80
|
-
```toml
|
|
81
|
-
decibri = { version = "3.1", features = ["ort-download-binaries"], default-features = false }
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Add back any other features you need (`capture`, `output`, `vad`,
|
|
85
|
-
`denoise`, `gain`). ORT is downloaded during `cargo build` and embedded
|
|
86
|
-
in your binary (the 3.0.x behaviour).
|
|
87
|
-
|
|
88
|
-
- **Production deployments with bundled ORT.** Take default features,
|
|
89
|
-
then either set `ORT_DYLIB_PATH=/path/to/libonnxruntime.{so,dylib,dll}`
|
|
90
|
-
before first use, or call `ort::init_from(path).commit()` at startup.
|
|
91
|
-
ONNX Runtime is initialized once per process. If your app creates
|
|
92
|
-
multiple `SileroVad` instances with different paths, the first one
|
|
93
|
-
wins and later paths are silently ignored. Pick one path and reuse it.
|
|
94
|
-
|
|
95
|
-
If you only need capture, output, or DSP (no Silero VAD), you won't pull
|
|
96
|
-
in `ort` at all:
|
|
97
|
-
|
|
98
|
-
```toml
|
|
99
|
-
decibri = { version = "3.1", features = ["capture", "output"], default-features = false }
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
See the [`ort` crate linking docs](https://ort.pyke.io/setup/linking)
|
|
103
|
-
for runtime-loading details.
|
|
104
|
-
|
|
105
|
-
---
|
|
106
|
-
|
|
107
15
|
## Quick Start
|
|
108
16
|
|
|
109
17
|
### Capture audio
|
|
@@ -144,25 +52,23 @@ const speaker = new DecibriOutput({ sampleRate: 16000, channels: 1 });
|
|
|
144
52
|
mic.pipe(speaker);
|
|
145
53
|
```
|
|
146
54
|
|
|
147
|
-
---
|
|
148
|
-
|
|
149
55
|
## API: Decibri (Capture)
|
|
150
56
|
|
|
151
57
|
### `new Decibri(options?)`
|
|
152
58
|
|
|
153
|
-
Creates a
|
|
59
|
+
Creates a Readable stream that captures from the microphone.
|
|
154
60
|
|
|
155
61
|
| Option | Type | Default | Description |
|
|
156
62
|
| --- | --- | --- | --- |
|
|
157
|
-
| `sampleRate` | number |
|
|
158
|
-
| `channels` | number |
|
|
159
|
-
| `framesPerBuffer` | number |
|
|
160
|
-
| `device` | number
|
|
63
|
+
| `sampleRate` | number | 16000 | Samples per second (1000 to 384000) |
|
|
64
|
+
| `channels` | number | 1 | Input channels (1 to 32) |
|
|
65
|
+
| `framesPerBuffer` | number | 1600 | Frames per chunk (64 to 65536). At 16kHz mono, 1600 = 100ms = 3200 bytes |
|
|
66
|
+
| `device` | number, string, or `{ id: string }` | system default | Device index, case-insensitive name substring, or stable per-host ID |
|
|
161
67
|
| `format` | `'int16'` \| `'float32'` | `'int16'` | Sample encoding |
|
|
162
|
-
| `vad` | boolean |
|
|
68
|
+
| `vad` | boolean | false | Enable voice activity detection |
|
|
163
69
|
| `vadMode` | `'energy'` \| `'silero'` | `'energy'` | VAD engine: RMS threshold or Silero ML model |
|
|
164
|
-
| `vadThreshold` | number |
|
|
165
|
-
| `vadHoldoff` | number |
|
|
70
|
+
| `vadThreshold` | number | 0.01 / 0.5 | Speech threshold. Default depends on `vadMode` |
|
|
71
|
+
| `vadHoldoff` | number | 300 | Silence holdoff in ms |
|
|
166
72
|
|
|
167
73
|
Standard `ReadableOptions` (e.g. `highWaterMark`) are also accepted.
|
|
168
74
|
|
|
@@ -172,7 +78,7 @@ Standard `ReadableOptions` (e.g. `highWaterMark`) are also accepted.
|
|
|
172
78
|
| --- | --- |
|
|
173
79
|
| `mic.stop()` | Stop capture and end stream. Safe to call multiple times |
|
|
174
80
|
| `Decibri.devices()` | List available input devices |
|
|
175
|
-
| `Decibri.version()` | Version info
|
|
81
|
+
| `Decibri.version()` | Version info |
|
|
176
82
|
|
|
177
83
|
### Properties
|
|
178
84
|
|
|
@@ -184,27 +90,25 @@ Standard `ReadableOptions` (e.g. `highWaterMark`) are also accepted.
|
|
|
184
90
|
|
|
185
91
|
| Event | Payload | Description |
|
|
186
92
|
| --- | --- | --- |
|
|
187
|
-
| `'data'` |
|
|
93
|
+
| `'data'` | Buffer | Audio chunk (Int16 LE or Float32 LE) |
|
|
188
94
|
| `'backpressure'` | - | Internal buffer full, consumer too slow |
|
|
189
95
|
| `'speech'` | - | VAD: audio crosses threshold |
|
|
190
96
|
| `'silence'` | - | VAD: audio below threshold for `vadHoldoff` ms |
|
|
191
97
|
| `'end'` | - | Stream ended |
|
|
192
|
-
| `'error'` |
|
|
193
|
-
|
|
194
|
-
---
|
|
98
|
+
| `'error'` | Error | An error occurred |
|
|
195
99
|
|
|
196
100
|
## API: DecibriOutput (Playback)
|
|
197
101
|
|
|
198
102
|
### `new DecibriOutput(options?)`
|
|
199
103
|
|
|
200
|
-
Creates a
|
|
104
|
+
Creates a Writable stream for speaker playback.
|
|
201
105
|
|
|
202
106
|
| Option | Type | Default | Description |
|
|
203
107
|
| --- | --- | --- | --- |
|
|
204
|
-
| `sampleRate` | number |
|
|
205
|
-
| `channels` | number |
|
|
108
|
+
| `sampleRate` | number | 16000 | Playback sample rate (1000 to 384000) |
|
|
109
|
+
| `channels` | number | 1 | Output channels (1 to 32) |
|
|
206
110
|
| `format` | `'int16'` \| `'float32'` | `'int16'` | Sample encoding of incoming data |
|
|
207
|
-
| `device` | number
|
|
111
|
+
| `device` | number, string, or `{ id: string }` | system default | Output device index, case-insensitive name substring, or stable per-host ID |
|
|
208
112
|
|
|
209
113
|
Standard `WritableOptions` (e.g. `highWaterMark`) are also accepted.
|
|
210
114
|
|
|
@@ -217,21 +121,19 @@ Standard `WritableOptions` (e.g. `highWaterMark`) are also accepted.
|
|
|
217
121
|
| `DecibriOutput.devices()` | List available output devices |
|
|
218
122
|
| `DecibriOutput.version()` | Same as `Decibri.version()` |
|
|
219
123
|
|
|
220
|
-
---
|
|
221
|
-
|
|
222
124
|
## API: Browser
|
|
223
125
|
|
|
224
126
|
The browser API uses `getUserMedia` and `AudioWorklet`. It differs from the Node.js API because browser audio is fundamentally async.
|
|
225
127
|
|
|
226
|
-
### `new Decibri(options?)`
|
|
128
|
+
### `new Decibri(options?)` (browser)
|
|
227
129
|
|
|
228
130
|
Same options as Node.js, plus:
|
|
229
131
|
|
|
230
132
|
| Option | Type | Default | Description |
|
|
231
133
|
| --- | --- | --- | --- |
|
|
232
134
|
| `device` | string | system default | Device ID from `Decibri.devices()` (not index) |
|
|
233
|
-
| `echoCancellation` | boolean |
|
|
234
|
-
| `noiseSuppression` | boolean |
|
|
135
|
+
| `echoCancellation` | boolean | true | Browser echo cancellation |
|
|
136
|
+
| `noiseSuppression` | boolean | true | Browser noise suppression |
|
|
235
137
|
| `workletUrl` | string | inline blob | Custom worklet URL for strict CSP |
|
|
236
138
|
|
|
237
139
|
### Key differences from Node.js
|
|
@@ -239,13 +141,11 @@ Same options as Node.js, plus:
|
|
|
239
141
|
| Aspect | Node.js | Browser |
|
|
240
142
|
| --- | --- | --- |
|
|
241
143
|
| Start | Automatic on first read | `await mic.start()` |
|
|
242
|
-
| Base class |
|
|
243
|
-
| Data type |
|
|
244
|
-
| `devices()` | Sync, returns array | Async, returns
|
|
144
|
+
| Base class | Readable stream | Custom Emitter |
|
|
145
|
+
| Data type | Buffer | Int16Array / Float32Array |
|
|
146
|
+
| `devices()` | Sync, returns array | Async, returns Promise |
|
|
245
147
|
| Sample rate | Direct via cpal | Resampled from native rate |
|
|
246
148
|
|
|
247
|
-
---
|
|
248
|
-
|
|
249
149
|
## Voice Activity Detection
|
|
250
150
|
|
|
251
151
|
### Energy mode (default)
|
|
@@ -270,8 +170,6 @@ mic.on('silence', () => console.log('silent'));
|
|
|
270
170
|
|
|
271
171
|
The Silero model (~2MB) ships inside the npm package. No downloads or API keys required.
|
|
272
172
|
|
|
273
|
-
---
|
|
274
|
-
|
|
275
173
|
## Device Selection
|
|
276
174
|
|
|
277
175
|
```javascript
|
|
@@ -284,35 +182,30 @@ const mic = new Decibri({ device: 'USB' });
|
|
|
284
182
|
// By index
|
|
285
183
|
const devices = Decibri.devices();
|
|
286
184
|
const mic = new Decibri({ device: devices[1].index });
|
|
287
|
-
```
|
|
288
185
|
|
|
289
|
-
|
|
186
|
+
// By stable per-host ID (survives across enumerations)
|
|
187
|
+
const mic = new Decibri({ device: { id: devices[1].id } });
|
|
188
|
+
|
|
290
189
|
Decibri.devices();
|
|
291
190
|
// [
|
|
292
|
-
// { index: 0, name: 'Microphone', maxInputChannels: 2, defaultSampleRate: 48000, isDefault: true },
|
|
293
|
-
// { index: 1, name: 'USB Headset', maxInputChannels: 1, defaultSampleRate: 44100, isDefault: false }
|
|
191
|
+
// { index: 0, name: 'Microphone', id: '{0.0.1.00000000}.{...}', maxInputChannels: 2, defaultSampleRate: 48000, isDefault: true },
|
|
192
|
+
// { index: 1, name: 'USB Headset', id: '{0.0.1.00000000}.{...}', maxInputChannels: 1, defaultSampleRate: 44100, isDefault: false }
|
|
294
193
|
// ]
|
|
295
194
|
```
|
|
296
195
|
|
|
297
|
-
---
|
|
298
|
-
|
|
299
196
|
## Examples
|
|
300
197
|
|
|
301
|
-
Runnable examples
|
|
198
|
+
Runnable examples ship with the package. After `npm install decibri`, find them under `node_modules/decibri/examples/`. From a clone of the repo they live at `npm/decibri/examples/`.
|
|
302
199
|
|
|
303
200
|
```bash
|
|
304
|
-
# Capture to WAV file (no dependencies)
|
|
305
|
-
node examples/wav-capture.js
|
|
201
|
+
# Capture to WAV file (no extra dependencies)
|
|
202
|
+
node node_modules/decibri/examples/wav-capture.js
|
|
306
203
|
|
|
307
204
|
# Stream to WebSocket (requires: npm install ws)
|
|
308
|
-
node examples/websocket-server.js # terminal 1
|
|
309
|
-
node examples/websocket-stream.js # terminal 2
|
|
205
|
+
node node_modules/decibri/examples/websocket-server.js # terminal 1
|
|
206
|
+
node node_modules/decibri/examples/websocket-stream.js # terminal 2
|
|
310
207
|
```
|
|
311
208
|
|
|
312
|
-
Integration guides for OpenAI, Deepgram, AssemblyAI, and other providers are at [decibri.com/docs](https://decibri.com/docs/).
|
|
313
|
-
|
|
314
|
-
---
|
|
315
|
-
|
|
316
209
|
## Platform Support
|
|
317
210
|
|
|
318
211
|
| Platform | Architecture | Audio Backend |
|
|
@@ -323,16 +216,19 @@ Integration guides for OpenAI, Deepgram, AssemblyAI, and other providers are at
|
|
|
323
216
|
| Linux | arm64 | ALSA |
|
|
324
217
|
| Browser | - | Web Audio API (AudioWorklet) |
|
|
325
218
|
|
|
326
|
-
---
|
|
327
|
-
|
|
328
219
|
## How It Works
|
|
329
220
|
|
|
330
|
-
decibri is a Rust library using
|
|
221
|
+
decibri is a Rust library using cpal for cross-platform audio I/O. The Rust core compiles to a Node.js native addon via napi-rs and ships pre-built binaries for each platform. Browser support uses a JavaScript AudioWorklet implementation with the same event-driven API.
|
|
331
222
|
|
|
332
|
-
Audio flows from the OS audio device through cpal's callback, into a crossbeam channel, through frame-exact buffering (guarantees consistent chunk sizes), and into Node.js via a threadsafe function. The JavaScript layer wraps this in a standard
|
|
223
|
+
Audio flows from the OS audio device through cpal's callback, into a crossbeam channel, through frame-exact buffering (guarantees consistent chunk sizes), and into Node.js via a threadsafe function. The JavaScript layer wraps this in a standard Readable stream.
|
|
333
224
|
|
|
334
|
-
|
|
225
|
+
## Documentation
|
|
226
|
+
|
|
227
|
+
- **Source code & issues**: [github.com/decibri/decibri](https://github.com/decibri/decibri)
|
|
228
|
+
- **Provider integrations** (OpenAI, Deepgram, AssemblyAI): [decibri.com/docs](https://decibri.com/docs)
|
|
335
229
|
|
|
336
230
|
## License
|
|
337
231
|
|
|
338
|
-
Apache-2.0
|
|
232
|
+
Apache-2.0. See [LICENSE](https://github.com/decibri/decibri/blob/main/LICENSE) for details.
|
|
233
|
+
|
|
234
|
+
Copyright (c) 2026 Decibri.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Captures audio for DURATION_MS and writes a valid WAV file.
|
|
3
|
+
// No external dependencies. Uses Node.js built-ins only.
|
|
4
|
+
// Usage (after npm install decibri): node node_modules/decibri/examples/wav-capture.js
|
|
5
|
+
// Usage (from repo clone): node npm/decibri/examples/wav-capture.js
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const Decibri = require('decibri');
|
|
9
|
+
|
|
10
|
+
const SAMPLE_RATE = 16000;
|
|
11
|
+
const CHANNELS = 1;
|
|
12
|
+
const BITS_PER_SAMPLE = 16;
|
|
13
|
+
const DURATION_MS = 5000;
|
|
14
|
+
|
|
15
|
+
const mic = new Decibri({ sampleRate: SAMPLE_RATE, channels: CHANNELS });
|
|
16
|
+
const chunks = [];
|
|
17
|
+
|
|
18
|
+
mic.on('data', (chunk) => chunks.push(chunk));
|
|
19
|
+
mic.on('error', (err) => { console.error('Mic error:', err.message); process.exit(1); });
|
|
20
|
+
|
|
21
|
+
console.log(`Recording for ${DURATION_MS / 1000} seconds...`);
|
|
22
|
+
|
|
23
|
+
setTimeout(() => {
|
|
24
|
+
mic.stop();
|
|
25
|
+
|
|
26
|
+
const pcm = Buffer.concat(chunks);
|
|
27
|
+
const header = buildWavHeader(pcm.length, SAMPLE_RATE, CHANNELS, BITS_PER_SAMPLE);
|
|
28
|
+
const out = fs.createWriteStream('capture.wav');
|
|
29
|
+
out.write(header);
|
|
30
|
+
out.end(pcm);
|
|
31
|
+
out.on('finish', () =>
|
|
32
|
+
console.log(`Wrote capture.wav (${(pcm.length / 1024).toFixed(1)} KB PCM, ${DURATION_MS / 1000}s)`)
|
|
33
|
+
);
|
|
34
|
+
}, DURATION_MS);
|
|
35
|
+
|
|
36
|
+
function buildWavHeader(dataBytes, sampleRate, channels, bitsPerSample) {
|
|
37
|
+
const byteRate = sampleRate * channels * bitsPerSample / 8;
|
|
38
|
+
const blockAlign = channels * bitsPerSample / 8;
|
|
39
|
+
const buf = Buffer.alloc(44);
|
|
40
|
+
buf.write('RIFF', 0); buf.writeUInt32LE(36 + dataBytes, 4);
|
|
41
|
+
buf.write('WAVE', 8); buf.write('fmt ', 12);
|
|
42
|
+
buf.writeUInt32LE(16, 16); buf.writeUInt16LE(1, 20); // PCM
|
|
43
|
+
buf.writeUInt16LE(channels, 22); buf.writeUInt32LE(sampleRate, 24);
|
|
44
|
+
buf.writeUInt32LE(byteRate, 28); buf.writeUInt16LE(blockAlign, 32);
|
|
45
|
+
buf.writeUInt16LE(bitsPerSample,34);
|
|
46
|
+
buf.write('data', 36); buf.writeUInt32LE(dataBytes, 40);
|
|
47
|
+
return buf;
|
|
48
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Minimal WebSocket server that receives raw PCM chunks and logs byte counts.
|
|
3
|
+
// Use this to test examples/websocket-stream.js.
|
|
4
|
+
// Requires: npm install ws
|
|
5
|
+
// Usage (after npm install decibri): node node_modules/decibri/examples/websocket-server.js
|
|
6
|
+
// Usage (from repo clone): node npm/decibri/examples/websocket-server.js
|
|
7
|
+
|
|
8
|
+
const { WebSocketServer } = require('ws');
|
|
9
|
+
|
|
10
|
+
const wss = new WebSocketServer({ port: 8080 });
|
|
11
|
+
console.log('Listening on ws://localhost:8080');
|
|
12
|
+
|
|
13
|
+
wss.on('connection', (ws) => {
|
|
14
|
+
console.log('Client connected');
|
|
15
|
+
let total = 0;
|
|
16
|
+
|
|
17
|
+
ws.on('message', (data) => {
|
|
18
|
+
total += data.length;
|
|
19
|
+
process.stdout.write(`\rReceived ${(total / 1024).toFixed(1)} KB`);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
ws.on('close', () => {
|
|
23
|
+
console.log(`\nClient disconnected. Total received: ${(total / 1024).toFixed(1)} KB`);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
ws.on('error', (err) => {
|
|
27
|
+
console.error('\nWebSocket error:', err.message);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Streams raw PCM audio to a WebSocket server.
|
|
3
|
+
// Requires: npm install ws
|
|
4
|
+
// Usage (after npm install decibri): node node_modules/decibri/examples/websocket-stream.js [ws://localhost:8080]
|
|
5
|
+
// Usage (from repo clone): node npm/decibri/examples/websocket-stream.js [ws://localhost:8080]
|
|
6
|
+
|
|
7
|
+
const { WebSocket } = require('ws');
|
|
8
|
+
const Decibri = require('decibri');
|
|
9
|
+
|
|
10
|
+
const url = process.argv[2] || 'ws://localhost:8080';
|
|
11
|
+
const ws = new WebSocket(url);
|
|
12
|
+
const mic = new Decibri({ sampleRate: 16000, channels: 1 });
|
|
13
|
+
|
|
14
|
+
ws.on('open', () => {
|
|
15
|
+
console.log(`Connected to ${url}, streaming audio. Ctrl+C to stop.`);
|
|
16
|
+
|
|
17
|
+
mic.on('data', (chunk) => {
|
|
18
|
+
if (ws.readyState === WebSocket.OPEN) ws.send(chunk);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
mic.on('error', (err) => {
|
|
22
|
+
console.error('Mic error:', err.message);
|
|
23
|
+
ws.close();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
mic.on('backpressure', () => {
|
|
27
|
+
console.warn('Backpressure: consumer too slow');
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
ws.on('close', () => {
|
|
32
|
+
mic.stop();
|
|
33
|
+
console.log('WebSocket closed.');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
ws.on('error', (err) => {
|
|
37
|
+
console.error('WebSocket error:', err.message);
|
|
38
|
+
mic.stop();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
process.on('SIGINT', () => {
|
|
42
|
+
mic.stop();
|
|
43
|
+
ws.close();
|
|
44
|
+
});
|
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 !== '3.4.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
80
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
96
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
117
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
133
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
150
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
166
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
185
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
201
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
217
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
237
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
253
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
274
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
290
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
308
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
324
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
342
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
358
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
376
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
392
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
410
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
426
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
443
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
459
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
479
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
495
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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 !== '3.4.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 3.4.
|
|
511
|
+
if (bindingPackageVersion !== '3.4.2' && 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 3.4.2 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": "3.4.
|
|
3
|
+
"version": "3.4.2",
|
|
4
4
|
"description": "Cross-platform audio capture, output, and processing for Node.js and browsers",
|
|
5
5
|
"main": "src/decibri.js",
|
|
6
6
|
"types": "src/decibri.d.ts",
|
|
@@ -64,15 +64,16 @@
|
|
|
64
64
|
"files": [
|
|
65
65
|
"src/",
|
|
66
66
|
"models/",
|
|
67
|
+
"examples/",
|
|
67
68
|
"index.js",
|
|
68
69
|
"index.d.ts",
|
|
69
70
|
"README.md"
|
|
70
71
|
],
|
|
71
72
|
"optionalDependencies": {
|
|
72
|
-
"@decibri/decibri-win32-x64-msvc": "3.4.
|
|
73
|
-
"@decibri/decibri-darwin-arm64": "3.4.
|
|
74
|
-
"@decibri/decibri-linux-x64-gnu": "3.4.
|
|
75
|
-
"@decibri/decibri-linux-arm64-gnu": "3.4.
|
|
73
|
+
"@decibri/decibri-win32-x64-msvc": "3.4.2",
|
|
74
|
+
"@decibri/decibri-darwin-arm64": "3.4.2",
|
|
75
|
+
"@decibri/decibri-linux-x64-gnu": "3.4.2",
|
|
76
|
+
"@decibri/decibri-linux-arm64-gnu": "3.4.2"
|
|
76
77
|
},
|
|
77
78
|
"devDependencies": {
|
|
78
79
|
"@napi-rs/cli": "^3.0.0"
|