@ai-coustics/aic-sdk 0.6.3 → 0.10.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,235 @@
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
+ QuailSTT: "QuailSTT",
52
+ };
53
+
54
+ /**
55
+ * Enhancement parameters
56
+ */
57
+ const EnhancementParameter = {
58
+ Bypass: native.ENHANCEMENT_PARAM_BYPASS,
59
+ EnhancementLevel: native.ENHANCEMENT_PARAM_ENHANCEMENT_LEVEL,
60
+ VoiceGain: native.ENHANCEMENT_PARAM_VOICE_GAIN,
61
+ };
62
+
63
+ /**
64
+ * VAD (Voice Activity Detection) parameters
65
+ */
66
+ const VadParameter = {
67
+ LookbackBufferSize: native.VAD_PARAM_LOOKBACK_BUFFER_SIZE,
68
+ Sensitivity: native.VAD_PARAM_SENSITIVITY,
69
+ };
70
+
71
+ /**
72
+ * Voice Activity Detector
73
+ */
74
+ class Vad {
75
+ constructor(nativeVad) {
76
+ this._vad = nativeVad;
77
+ }
78
+
79
+ /**
80
+ * Check if speech is detected
81
+ * @returns {boolean}
82
+ */
83
+ isSpeechDetected() {
84
+ return native.vadIsSpeechDetected(this._vad);
85
+ }
86
+
87
+ /**
88
+ * Set a VAD parameter
89
+ * @param {number} parameter - Parameter constant from VadParameter
90
+ * @param {number} value - Parameter value
91
+ * @throws {Error} If parameter setting fails (invalid parameter, out of range, etc.)
92
+ */
93
+ setParameter(parameter, value) {
94
+ native.vadSetParameter(this._vad, parameter, value);
95
+ }
96
+
97
+ /**
98
+ * Get a VAD parameter value
99
+ * @param {number} parameter - Parameter constant from VadParameter
100
+ * @returns {number}
101
+ */
102
+ getParameter(parameter) {
103
+ return native.vadGetParameter(this._vad, parameter);
104
+ }
105
+ }
106
+
107
+ /**
108
+ * AI-Coustics audio enhancement model
109
+ */
110
+ class Model {
111
+ /**
112
+ * Create a new model instance
113
+ * @param {string} modelType - Model type from ModelType enum
114
+ * @param {string} licenseKey - SDK license key
115
+ * @throws {Error} If model creation fails (invalid license, unsupported model type, etc.)
116
+ */
117
+ constructor(modelType, licenseKey) {
118
+ this._model = native.modelNew(modelType, licenseKey);
119
+ }
120
+
121
+ /**
122
+ * Get the optimal sample rate for this model
123
+ * @returns {number} Sample rate in Hz
124
+ */
125
+ optimalSampleRate() {
126
+ return native.modelOptimalSampleRate(this._model);
127
+ }
128
+
129
+ /**
130
+ * Get the optimal number of frames for a given sample rate
131
+ * @param {number} sampleRate - Sample rate in Hz
132
+ * @returns {number} Number of frames
133
+ */
134
+ optimalNumFrames(sampleRate) {
135
+ return native.modelOptimalNumFrames(this._model, sampleRate);
136
+ }
137
+
138
+ /**
139
+ * Initialize the model with audio configuration
140
+ * @param {number} sampleRate - Sample rate in Hz
141
+ * @param {number} numChannels - Number of audio channels
142
+ * @param {number} numFrames - Number of frames per process call
143
+ * @param {boolean} allowVariableFrames - Allow variable frame counts
144
+ * @throws {Error} If initialization fails (invalid parameters)
145
+ */
146
+ initialize(sampleRate, numChannels, numFrames, allowVariableFrames = false) {
147
+ native.modelInitialize(
148
+ this._model,
149
+ sampleRate,
150
+ numChannels,
151
+ numFrames,
152
+ allowVariableFrames,
153
+ );
154
+ }
155
+
156
+ /**
157
+ * Get the output delay in samples
158
+ * @returns {number} Delay in samples
159
+ */
160
+ outputDelay() {
161
+ return native.modelOutputDelay(this._model);
162
+ }
163
+
164
+ /**
165
+ * Reset the model's internal state
166
+ */
167
+ reset() {
168
+ native.modelReset(this._model);
169
+ }
170
+
171
+ /**
172
+ * Set an enhancement parameter
173
+ * @param {number} parameter - Parameter constant from EnhancementParameter
174
+ * @param {number} value - Parameter value
175
+ * @throws {Error} If parameter setting fails (invalid parameter, out of range, etc)
176
+ */
177
+ setParameter(parameter, value) {
178
+ native.modelSetParameter(this._model, parameter, value);
179
+ }
180
+
181
+ /**
182
+ * Get an enhancement parameter value
183
+ * @param {number} parameter - Parameter constant from EnhancementParameter
184
+ * @returns {number}
185
+ */
186
+ getParameter(parameter) {
187
+ return native.modelGetParameter(this._model, parameter);
188
+ }
189
+
190
+ /**
191
+ * Process interleaved audio (all channels mixed in one buffer)
192
+ * @param {Float32Array} buffer - Interleaved audio buffer
193
+ * @param {number} numChannels - Number of channels
194
+ * @param {number} numFrames - Number of frames
195
+ * @throws {Error} If processing fails (model not initialized, invalid buffer size, etc.)
196
+ */
197
+ processInterleaved(buffer, numChannels, numFrames) {
198
+ native.modelProcessInterleaved(this._model, buffer, numChannels, numFrames);
199
+ }
200
+
201
+ /**
202
+ * Process planar audio (separate buffer for each channel)
203
+ * @param {Float32Array[]} buffers - Array of audio buffers, one per channel (max 16 channels)
204
+ * @throws {Error} If processing fails (model not initialized, too many channels, invalid buffer size, etc.)
205
+ */
206
+ processPlanar(buffers) {
207
+ native.modelProcessPlanar(this._model, buffers);
208
+ }
209
+
210
+ /**
211
+ * Create a Voice Activity Detector for this model
212
+ * @returns {Vad}
213
+ */
214
+ createVad() {
215
+ const nativeVad = native.modelCreateVad(this._model);
216
+ return new Vad(nativeVad);
217
+ }
218
+ }
219
+
220
+ /**
221
+ * Get the SDK version
222
+ * @returns {string}
223
+ */
224
+ function getVersion() {
225
+ return native.getVersion();
226
+ }
227
+
228
+ module.exports = {
229
+ Model,
230
+ Vad,
231
+ ModelType,
232
+ EnhancementParameter,
233
+ VadParameter,
234
+ getVersion,
235
+ };
package/package.json CHANGED
@@ -1,60 +1,48 @@
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.10.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",
11
+ "prepublishOnly": "echo 'Use GitHub Actions to publish. See PUBLISHING.md for details.' && exit 1"
17
12
  },
13
+ "author": "ai-coustics GmbH",
14
+ "license": "Apache-2.0",
18
15
  "keywords": [
19
16
  "audio",
20
17
  "speech",
21
- "enhancement",
22
18
  "voice",
19
+ "agent",
23
20
  "ai-coustics"
24
21
  ],
25
- "author": "ai-coustics GmbH",
26
- "license": "SEE LICENSE IN LICENSE",
22
+ "homepage": "https://github.com/ai-coustics/aic-sdk-node#readme",
23
+ "bugs": {
24
+ "url": "https://github.com/ai-coustics/aic-sdk-node/issues"
25
+ },
27
26
  "repository": {
28
27
  "type": "git",
29
- "url": "https://github.com/ai-coustics/aic-sdk-node.git"
28
+ "url": "git+https://github.com/ai-coustics/aic-sdk-node.git"
30
29
  },
31
- "engines": {
32
- "node": ">=14.0.0"
33
- },
34
- "os": [
35
- "darwin",
36
- "linux",
37
- "win32"
38
- ],
39
- "cpu": [
40
- "x64",
41
- "arm64"
30
+ "type": "commonjs",
31
+ "files": [
32
+ "index.js",
33
+ "index.node",
34
+ "README.md",
35
+ "LICENSE"
42
36
  ],
43
- "dependencies": {
44
- "node-addon-api": "^7.0.0",
45
- "node-gyp": "^10.0.0",
46
- "tar": "^6.2.0"
37
+ "optionalDependencies": {
38
+ "@ai-coustics/aic-sdk-linux-x64-gnu": "0.10.0",
39
+ "@ai-coustics/aic-sdk-linux-arm64-gnu": "0.10.0",
40
+ "@ai-coustics/aic-sdk-darwin-x64": "0.10.0",
41
+ "@ai-coustics/aic-sdk-darwin-arm64": "0.10.0",
42
+ "@ai-coustics/aic-sdk-win32-x64-msvc": "0.10.0",
43
+ "@ai-coustics/aic-sdk-win32-arm64-msvc": "0.10.0"
47
44
  },
48
45
  "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
46
+ "@neon-rs/cli": "0.1.82"
47
+ }
60
48
  }
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
- }