@ai-coustics/aic-sdk 0.6.3 → 0.12.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.
@@ -3,8 +3,8 @@ Version 1.0 — 30 September 2025
3
3
  Copyright © 2025 ai-coustics GmbH. All rights reserved.
4
4
 
5
5
  0. Definitions
6
- “SDK”  means the files distributed inside the `sdk` folder
7
- sdk/lib/* (e.g. libaic.a, libaic.so, libaic.dylib, aic.dll)
6
+ “SDK”  means the binaries downloaded during the build process
7
+ (e.g. libaic.a, libaic.so, libaic.dylib, aic.dll)
8
8
  together with the public C header aic.h.
9
9
  “Wrapper”  means the source code in this repository that links to
10
10
  the SDK. The Wrapper is licensed separately under the
package/README.md CHANGED
@@ -1,107 +1,74 @@
1
1
  # ai-coustics Speech Enhancement SDK for Node.js
2
2
 
3
- Welcome to the ai-coustics SDK! This repository provides the native JavaScript/TypeScript bindings to run our powerful real-time speech enhancement in your Node.js applications.
3
+ Node.js bindings for the ai-coustics Speech Enhancement SDK.
4
4
 
5
- ## What is this SDK?
5
+ ## Prerequisites
6
6
 
7
- Our Speech Enhancement SDK delivers state-of-the-art speech-enhancement in real-time, enabling you to build applications that remove noise and reverb from speech signals.
7
+ - SDK license key from [ai-coustics Developer Portal](https://developers.ai-coustics.io)
8
8
 
9
- ## Quick Start
10
-
11
- ### Acquire an SDK License Key
12
-
13
- You need an **SDK license key**. This is distinct from the API license key used for our cloud API services. To obtain an SDK license key, please contact us at [info@ai-coustics.com](mailto:info@ai-coustics.com)
14
-
15
- ### Installation
9
+ ## Installation
16
10
 
17
11
  ```bash
18
12
  npm install @ai-coustics/aic-sdk
19
13
  ```
20
14
 
21
- The SDK binaries will be automatically downloaded during installation for your platform.
22
-
23
15
  ### Supported Platforms
24
16
 
25
- - macOS (x64, ARM64)
26
- - Linux (x64, ARM64)
27
- - Windows (x64)
17
+ - Linux: x64, ARM64 (GNU libc)
18
+ - macOS: x64, ARM64
19
+ - Windows: x64, ARM64 (MSVC)
28
20
 
29
- ### Example Code
21
+ ## Example
30
22
 
31
23
  ```javascript
32
- import { Model, ModelType, Parameter, AudioConfig } from '@ai-coustics/aic-sdk';
33
-
34
- const model = new Model(ModelType.QUAIL_L48, "YOUR_LICENSE_KEY");
24
+ const { Model, ModelType, EnhancementParameter } = require('@ai-coustics/aic-sdk');
35
25
 
36
- const config: AudioConfig = {
37
- sampleRate: model.getOptimalSampleRate(),
38
- numChannels: 2,
39
- numFrames: model.getOptimalNumFrames()
40
- };
26
+ const model = new Model(ModelType.QuailS48, process.env.AIC_SDK_LICENSE);
41
27
 
42
- model.initialize(config);
28
+ // Get optimal settings
29
+ const sampleRate = model.optimalSampleRate();
30
+ const numFrames = model.optimalNumFrames(sampleRate);
43
31
 
44
- // Adjust parameters
45
- model.setParameter(Parameter.ENHANCEMENT_LEVEL, 0.9);
46
- model.setParameter(Parameter.VOICE_GAIN, 1.2);
32
+ // Initialize for stereo audio
33
+ model.initialize(sampleRate, 2, numFrames, false);
47
34
 
48
- // Planar layout (separate buffers)
49
- const leftChannel = new Float32Array(480);
50
- const rightChannel = new Float32Array(480);
51
- model.processPlanar([leftChannel, rightChannel], 2, 480);
35
+ // Set enhancement parameters
36
+ model.setParameter(EnhancementParameter.EnhancementLevel, 0.7);
37
+ model.setParameter(EnhancementParameter.VoiceGain, 1.5);
52
38
 
53
- // Or interleaved layout
54
- const interleavedBuffer = new Float32Array(2 * 480);
55
- model.processInterleaved(interleavedBuffer, 2, 480);
39
+ // Process interleaved audio
40
+ const interleavedBuffer = new Float32Array(2 * numFrames);
41
+ model.processInterleaved(interleavedBuffer, 2, numFrames);
56
42
 
57
- model.destroy();
43
+ // Or process planar audio
44
+ const planarBuffers = [
45
+ new Float32Array(numFrames), // Left channel
46
+ new Float32Array(numFrames), // Right channel
47
+ ];
48
+ model.processPlanar(planarBuffers);
58
49
  ```
59
50
 
60
- ## Support & Resources
61
-
62
- ## Documentation
63
-
64
- - [JavaScript Example](examples/example.js)
65
- - [TypeScript Example](examples/example.ts)
66
- - [Function Reference](src/index.ts)
67
- - [C-SDK-Reference](https://github.com/ai-coustics/aic-sdk-c/blob/HEAD/sdk-reference.md)
68
-
69
- ### Looking for Other Languages?
70
-
71
- The ai-coustics Speech Enhancement SDK is available in multiple programming languages to fit your development needs:
51
+ ## Links
72
52
 
73
- | Platform | Repository | Description |
74
- |----------|------------|-------------|
75
- | **C** | [aic-sdk-c](https://github.com/ai-coustics/aic-sdk-c) | Core C interface and foundation library |
76
- | **C++** | [`aic-sdk-cpp`](https://github.com/ai-coustics/aic-sdk-cpp) | Modern C++ interface with RAII and type safety |
77
- | **Python** | [`aic-sdk-py`](https://github.com/ai-coustics/aic-sdk-py) | Idiomatic Python interface |
78
- | **Rust** | [`aic-sdk-rs`](https://github.com/ai-coustics/aic-sdk-rs) | Safe Rust bindings with zero-cost abstractions |
79
- | **Web (WASM)** | [`aic-sdk-wasm`](https://github.com/ai-coustics/aic-sdk-wasm) | WebAssembly build for browser applications |
53
+ - [Example Usage](examples/basic.js)
54
+ - [API Reference](index.js)
55
+ - [C SDK Reference](https://github.com/ai-coustics/aic-sdk-c/blob/HEAD/sdk-reference.md)
56
+ - [Documentation](https://docs.ai-coustics.com/)
57
+ - [Issues](https://github.com/ai-coustics/aic-sdk-node/issues)
80
58
 
59
+ ### Other SDKs
81
60
 
82
- ## Demo Plugin
83
-
84
- Experience our speech enhancement models firsthand with our Demo Plugin - a complete audio plugin that showcases all available models while serving as a comprehensive C++ integration example.
85
-
86
- | Platform | Repository | Description |
87
- |----------|------------|-------------|
88
- | **Demo Plugin** | [`aic-sdk-plugin`](https://github.com/ai-coustics/aic-sdk-plugin) | Audio plugin with real-time model comparison and C++ integration reference |
89
-
90
- ### Get Help
91
-
92
- - Documentation: [docs.ai-coustics.com](https://docs.ai-coustics.com/)
93
- - Issues: [GitHub Issues](https://github.com/ai-coustics/aic-sdk-node/issues)
94
- - Email: [info@ai-coustics.com](mailto:info@ai-coustics.com)
61
+ | Platform | Repository |
62
+ |----------|------------|
63
+ | **C** | [aic-sdk-c](https://github.com/ai-coustics/aic-sdk-c) |
64
+ | **C++** | [aic-sdk-cpp](https://github.com/ai-coustics/aic-sdk-cpp) |
65
+ | **Python** | [aic-sdk-py](https://github.com/ai-coustics/aic-sdk-py) |
66
+ | **Rust** | [aic-sdk-rs](https://github.com/ai-coustics/aic-sdk-rs) |
67
+ | **Web (WASM)** | [aic-sdk-wasm](https://github.com/ai-coustics/aic-sdk-wasm) |
68
+ | **Demo Plugin** | [aic-sdk-plugin](https://github.com/ai-coustics/aic-sdk-plugin) |
95
69
 
96
70
  ## License
97
71
 
98
- This project uses a dual-license structure:
99
-
100
- - **Node.js Wrapper Code** (source files in this repository): Licensed under the Apache License 2.0. See [LICENSE](LICENSE) for details.
101
- - **AIC SDK Binaries** (files in `sdk/lib/*` and `aic.h`): Licensed under the proprietary AIC-SDK Binary License Agreement. See [LICENSE.AIC-SDK](LICENSE.AIC-SDK) for details.
102
-
103
- When you use this package, both licenses apply to their respective components.
104
-
105
- ---
106
-
107
- Made with ❤️ by the ai-coustics team
72
+ Dual-licensed:
73
+ - Node.js wrapper code: Apache License 2.0
74
+ - AIC SDK binaries: Proprietary AIC-SDK Binary License Agreement
package/index.js ADDED
@@ -0,0 +1,240 @@
1
+ // Platform-specific binary loader
2
+ let native;
3
+ try {
4
+ // Try to load platform-specific binary from optional dependencies
5
+ const platform = process.platform;
6
+ const arch = process.arch;
7
+
8
+ const platformPackages = {
9
+ "linux-x64": "@ai-coustics/aic-sdk-linux-x64-gnu",
10
+ "linux-arm64": "@ai-coustics/aic-sdk-linux-arm64-gnu",
11
+ "darwin-x64": "@ai-coustics/aic-sdk-darwin-x64",
12
+ "darwin-arm64": "@ai-coustics/aic-sdk-darwin-arm64",
13
+ "win32-x64": "@ai-coustics/aic-sdk-win32-x64-msvc",
14
+ "win32-arm64": "@ai-coustics/aic-sdk-win32-arm64-msvc",
15
+ };
16
+
17
+ const platformKey = `${platform}-${arch}`;
18
+ const platformPackage = platformPackages[platformKey];
19
+
20
+ if (platformPackage) {
21
+ try {
22
+ native = require(platformPackage);
23
+ } catch (e) {
24
+ // Fall back to local binary
25
+ native = require("./index.node");
26
+ }
27
+ } else {
28
+ // Fall back to local binary
29
+ native = require("./index.node");
30
+ }
31
+ } catch (e) {
32
+ throw new Error(
33
+ `Failed to load native binary for platform ${process.platform}-${process.arch}. ` +
34
+ `Supported platforms: Linux (x64/ARM64, GNU libc), macOS (x64/ARM64), Windows (x64/ARM64, MSVC). ` +
35
+ `Error: ${e.message}`,
36
+ );
37
+ }
38
+
39
+ /**
40
+ * Model types available in the SDK
41
+ */
42
+ const ModelType = {
43
+ QuailL48: "QuailL48",
44
+ QuailL16: "QuailL16",
45
+ QuailL8: "QuailL8",
46
+ QuailS48: "QuailS48",
47
+ QuailS16: "QuailS16",
48
+ QuailS8: "QuailS8",
49
+ QuailXs: "QuailXs",
50
+ QuailXxs: "QuailXxs",
51
+ QuailSttL16: "QuailSttL16",
52
+ QuailSttL8: "QuailSttL8",
53
+ QuailSttS16: "QuailSttS16",
54
+ QuailSttS8: "QuailSttS8",
55
+ QuailVfSttL16: "QuailVfSttL16",
56
+ };
57
+
58
+ /**
59
+ * Enhancement parameters
60
+ */
61
+ const EnhancementParameter = {
62
+ Bypass: native.ENHANCEMENT_PARAM_BYPASS,
63
+ EnhancementLevel: native.ENHANCEMENT_PARAM_ENHANCEMENT_LEVEL,
64
+ VoiceGain: native.ENHANCEMENT_PARAM_VOICE_GAIN,
65
+ };
66
+
67
+ /**
68
+ * VAD (Voice Activity Detection) parameters
69
+ */
70
+ const VadParameter = {
71
+ SpeechHoldDuration: native.VAD_PARAM_SPEECH_HOLD_DURATION,
72
+ Sensitivity: native.VAD_PARAM_SENSITIVITY,
73
+ MinimumSpeechDuration: native.VAD_PARAM_MINIMUM_SPEECH_DURATION,
74
+ };
75
+
76
+ /**
77
+ * Voice Activity Detector
78
+ */
79
+ class Vad {
80
+ constructor(nativeVad) {
81
+ this._vad = nativeVad;
82
+ }
83
+
84
+ /**
85
+ * Check if speech is detected
86
+ * @returns {boolean}
87
+ */
88
+ isSpeechDetected() {
89
+ return native.vadIsSpeechDetected(this._vad);
90
+ }
91
+
92
+ /**
93
+ * Set a VAD parameter
94
+ * @param {number} parameter - Parameter constant from VadParameter
95
+ * @param {number} value - Parameter value
96
+ * @throws {Error} If parameter setting fails (invalid parameter, out of range, etc.)
97
+ */
98
+ setParameter(parameter, value) {
99
+ native.vadSetParameter(this._vad, parameter, value);
100
+ }
101
+
102
+ /**
103
+ * Get a VAD parameter value
104
+ * @param {number} parameter - Parameter constant from VadParameter
105
+ * @returns {number}
106
+ */
107
+ getParameter(parameter) {
108
+ return native.vadGetParameter(this._vad, parameter);
109
+ }
110
+ }
111
+
112
+ /**
113
+ * AI-Coustics audio enhancement model
114
+ */
115
+ class Model {
116
+ /**
117
+ * Create a new model instance
118
+ * @param {string} modelType - Model type from ModelType enum
119
+ * @param {string} licenseKey - SDK license key
120
+ * @throws {Error} If model creation fails (invalid license, unsupported model type, etc.)
121
+ */
122
+ constructor(modelType, licenseKey) {
123
+ this._model = native.modelNew(modelType, licenseKey);
124
+ }
125
+
126
+ /**
127
+ * Get the optimal sample rate for this model
128
+ * @returns {number} Sample rate in Hz
129
+ */
130
+ optimalSampleRate() {
131
+ return native.modelOptimalSampleRate(this._model);
132
+ }
133
+
134
+ /**
135
+ * Get the optimal number of frames for a given sample rate
136
+ * @param {number} sampleRate - Sample rate in Hz
137
+ * @returns {number} Number of frames
138
+ */
139
+ optimalNumFrames(sampleRate) {
140
+ return native.modelOptimalNumFrames(this._model, sampleRate);
141
+ }
142
+
143
+ /**
144
+ * Initialize the model with audio configuration
145
+ * @param {number} sampleRate - Sample rate in Hz
146
+ * @param {number} numChannels - Number of audio channels
147
+ * @param {number} numFrames - Number of frames per process call
148
+ * @param {boolean} allowVariableFrames - Allow variable frame counts
149
+ * @throws {Error} If initialization fails (invalid parameters)
150
+ */
151
+ initialize(sampleRate, numChannels, numFrames, allowVariableFrames = false) {
152
+ native.modelInitialize(
153
+ this._model,
154
+ sampleRate,
155
+ numChannels,
156
+ numFrames,
157
+ allowVariableFrames,
158
+ );
159
+ }
160
+
161
+ /**
162
+ * Get the output delay in samples
163
+ * @returns {number} Delay in samples
164
+ */
165
+ outputDelay() {
166
+ return native.modelOutputDelay(this._model);
167
+ }
168
+
169
+ /**
170
+ * Reset the model's internal state
171
+ */
172
+ reset() {
173
+ native.modelReset(this._model);
174
+ }
175
+
176
+ /**
177
+ * Set an enhancement parameter
178
+ * @param {number} parameter - Parameter constant from EnhancementParameter
179
+ * @param {number} value - Parameter value
180
+ * @throws {Error} If parameter setting fails (invalid parameter, out of range, etc)
181
+ */
182
+ setParameter(parameter, value) {
183
+ native.modelSetParameter(this._model, parameter, value);
184
+ }
185
+
186
+ /**
187
+ * Get an enhancement parameter value
188
+ * @param {number} parameter - Parameter constant from EnhancementParameter
189
+ * @returns {number}
190
+ */
191
+ getParameter(parameter) {
192
+ return native.modelGetParameter(this._model, parameter);
193
+ }
194
+
195
+ /**
196
+ * Process interleaved audio (all channels mixed in one buffer)
197
+ * @param {Float32Array} buffer - Interleaved audio buffer
198
+ * @param {number} numChannels - Number of channels
199
+ * @param {number} numFrames - Number of frames
200
+ * @throws {Error} If processing fails (model not initialized, invalid buffer size, etc.)
201
+ */
202
+ processInterleaved(buffer, numChannels, numFrames) {
203
+ native.modelProcessInterleaved(this._model, buffer, numChannels, numFrames);
204
+ }
205
+
206
+ /**
207
+ * Process planar audio (separate buffer for each channel)
208
+ * @param {Float32Array[]} buffers - Array of audio buffers, one per channel (max 16 channels)
209
+ * @throws {Error} If processing fails (model not initialized, too many channels, invalid buffer size, etc.)
210
+ */
211
+ processPlanar(buffers) {
212
+ native.modelProcessPlanar(this._model, buffers);
213
+ }
214
+
215
+ /**
216
+ * Create a Voice Activity Detector for this model
217
+ * @returns {Vad}
218
+ */
219
+ createVad() {
220
+ const nativeVad = native.modelCreateVad(this._model);
221
+ return new Vad(nativeVad);
222
+ }
223
+ }
224
+
225
+ /**
226
+ * Get the SDK version
227
+ * @returns {string}
228
+ */
229
+ function getVersion() {
230
+ return native.getVersion();
231
+ }
232
+
233
+ module.exports = {
234
+ Model,
235
+ Vad,
236
+ ModelType,
237
+ EnhancementParameter,
238
+ VadParameter,
239
+ getVersion,
240
+ };
package/package.json CHANGED
@@ -1,60 +1,47 @@
1
1
  {
2
2
  "name": "@ai-coustics/aic-sdk",
3
- "version": "0.6.3",
4
- "description": "Node.js bindings for ai-coustics speech enhancement SDK",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
3
+ "version": "0.12.0",
4
+ "description": "Node.js package of ai-coustics SDK",
5
+ "main": "index.js",
7
6
  "scripts": {
8
- "install": "node scripts/download-sdk.js && node-gyp rebuild",
9
- "build": "tsc",
10
- "prepare": "npm run build",
11
- "test": "node test-basic.js",
12
- "test:full": "node test-basic.js && npm run example:js && npm run example:ts",
13
- "example:js": "node examples/example.js",
14
- "example:ts": "npx ts-node examples/example.ts",
15
- "example:ts-compile": "tsc examples/example.ts --outDir examples && node examples/example.js",
16
- "clean": "rm -rf build dist sdk"
7
+ "test": "node examples/basic.js",
8
+ "build": "cargo build --release && cp target/release/libaic_sdk_node.so index.node 2>/dev/null || cp target/release/libaic_sdk_node.dylib index.node 2>/dev/null || cp target/release/aic_sdk_node.dll index.node 2>/dev/null || true",
9
+ "debug": "cargo build && cp target/debug/libaic_sdk_node.so index.node 2>/dev/null || cp target/debug/libaic_sdk_node.dylib index.node 2>/dev/null || cp target/debug/aic_sdk_node.dll index.node 2>/dev/null || true",
10
+ "version:update": "bash scripts/update-version.sh"
17
11
  },
12
+ "author": "ai-coustics GmbH",
13
+ "license": "Apache-2.0",
18
14
  "keywords": [
19
15
  "audio",
20
16
  "speech",
21
- "enhancement",
22
17
  "voice",
18
+ "agent",
23
19
  "ai-coustics"
24
20
  ],
25
- "author": "ai-coustics GmbH",
26
- "license": "SEE LICENSE IN LICENSE",
21
+ "homepage": "https://github.com/ai-coustics/aic-sdk-node#readme",
22
+ "bugs": {
23
+ "url": "https://github.com/ai-coustics/aic-sdk-node/issues"
24
+ },
27
25
  "repository": {
28
26
  "type": "git",
29
- "url": "https://github.com/ai-coustics/aic-sdk-node.git"
27
+ "url": "git+https://github.com/ai-coustics/aic-sdk-node.git"
30
28
  },
31
- "engines": {
32
- "node": ">=14.0.0"
33
- },
34
- "os": [
35
- "darwin",
36
- "linux",
37
- "win32"
38
- ],
39
- "cpu": [
40
- "x64",
41
- "arm64"
29
+ "type": "commonjs",
30
+ "files": [
31
+ "index.js",
32
+ "index.node",
33
+ "README.md",
34
+ "LICENSE"
42
35
  ],
43
- "dependencies": {
44
- "node-addon-api": "^7.0.0",
45
- "node-gyp": "^10.0.0",
46
- "tar": "^6.2.0"
36
+ "optionalDependencies": {
37
+ "@ai-coustics/aic-sdk-darwin-arm64": "0.12.0",
38
+ "@ai-coustics/aic-sdk-darwin-x64": "0.12.0",
39
+ "@ai-coustics/aic-sdk-linux-arm64-gnu": "0.12.0",
40
+ "@ai-coustics/aic-sdk-linux-x64-gnu": "0.12.0",
41
+ "@ai-coustics/aic-sdk-win32-arm64-msvc": "0.12.0",
42
+ "@ai-coustics/aic-sdk-win32-x64-msvc": "0.12.0"
47
43
  },
48
44
  "devDependencies": {
49
- "@types/node": "^20.0.0",
50
- "ts-node": "^10.9.2",
51
- "typescript": "^5.0.0"
52
- },
53
- "files": [
54
- "dist",
55
- "binding.gyp",
56
- "scripts",
57
- "src/binding.cc"
58
- ],
59
- "gypfile": true
45
+ "@neon-rs/cli": "0.1.82"
46
+ }
60
47
  }
package/binding.gyp DELETED
@@ -1,52 +0,0 @@
1
- {
2
- "targets": [
3
- {
4
- "target_name": "aic_binding",
5
- "sources": ["src/binding.cc"],
6
- "include_dirs": [
7
- "<!@(node -p \"require('node-addon-api').include\")",
8
- "sdk/include"
9
- ],
10
- "dependencies": [
11
- "<!(node -p \"require('node-addon-api').gyp\")"
12
- ],
13
- "defines": ["NAPI_DISABLE_CPP_EXCEPTIONS"],
14
- "conditions": [
15
- ["OS=='linux'", {
16
- "libraries": [
17
- "<(module_root_dir)/sdk/lib/libaic.so"
18
- ],
19
- "ldflags": [
20
- "-Wl,-rpath,<(module_root_dir)/sdk/lib"
21
- ]
22
- }],
23
- ["OS=='mac'", {
24
- "libraries": [
25
- "../sdk/lib/libaic.dylib"
26
- ],
27
- "xcode_settings": {
28
- "OTHER_LDFLAGS": [
29
- "-Wl,-rpath,@loader_path/../../sdk/lib"
30
- ]
31
- }
32
- }],
33
- ["OS=='win'", {
34
- "libraries": [
35
- "../sdk/lib/aic.lib",
36
- "ntdll.lib"
37
- ],
38
- "copies": [
39
- {
40
- "destination": "<(module_root_dir)/build/Release/",
41
- "files": ["<(module_root_dir)/sdk/lib/aic.dll"]
42
- }
43
- ]
44
- }]
45
- ],
46
- "cflags!": ["-fno-exceptions"],
47
- "cflags_cc!": ["-fno-exceptions"],
48
- "cflags": ["-fPIC"],
49
- "cflags_cc": ["-fPIC"]
50
- }
51
- ]
52
- }