audio-ml 1.0.0 → 1.0.1
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 +84 -39
- package/package.json +4 -8
package/README.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
A comprehensive JavaScript/TypeScript library for real-time audio feature extraction, designed for machine learning applications, particularly voice AI systems.
|
|
4
4
|
|
|
5
|
+
## 📦 Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install audio-ml
|
|
9
|
+
# or
|
|
10
|
+
yarn add audio-ml
|
|
11
|
+
# or
|
|
12
|
+
pnpm add audio-ml
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Works in both Web and Node.js environments!** This package is designed to be universal - use it in your browser-based applications or in Node.js server-side applications.
|
|
16
|
+
|
|
17
|
+
## 🎬 Demo
|
|
18
|
+
|
|
19
|
+
https://github.com/user-attachments/assets/aae5ff8c-120b-4c6c-a4d4-7348dacc3ca0
|
|
20
|
+
|
|
21
|
+
|
|
5
22
|
## Overview
|
|
6
23
|
|
|
7
24
|
This project provides a complete toolkit for analyzing audio signals in real-time, extracting various features that are essential for machine learning models in speech recognition, speaker identification, music information retrieval, and voice AI applications.
|
|
@@ -47,12 +64,54 @@ This project provides a complete toolkit for analyzing audio signals in real-tim
|
|
|
47
64
|
|
|
48
65
|
## Getting Started
|
|
49
66
|
|
|
50
|
-
###
|
|
67
|
+
### Using the Package
|
|
51
68
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
69
|
+
The `audio-ml` package can be used in both **web browsers** and **Node.js** environments:
|
|
70
|
+
|
|
71
|
+
#### Web Browser Usage
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { FFTAnalyzer, MFCCAnalyzer } from 'audio-ml';
|
|
75
|
+
|
|
76
|
+
// Create analyzers
|
|
77
|
+
const fftAnalyzer = new FFTAnalyzer({
|
|
78
|
+
sampleRate: 44100,
|
|
79
|
+
fftSize: 1024
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Use with Web Audio API
|
|
83
|
+
const audioContext = new AudioContext();
|
|
84
|
+
const processor = audioContext.createScriptProcessor(1024, 1, 1);
|
|
85
|
+
|
|
86
|
+
processor.onaudioprocess = (event) => {
|
|
87
|
+
const pcm = event.inputBuffer.getChannelData(0);
|
|
88
|
+
const spectrum = fftAnalyzer.analyzeFrame(pcm);
|
|
89
|
+
// Process your features...
|
|
90
|
+
};
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
#### Node.js Usage
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { FFTAnalyzer, MFCCAnalyzer } from 'audio-ml';
|
|
97
|
+
import { readFileSync } from 'fs';
|
|
98
|
+
import { decode } from 'audio-decode'; // or similar audio decoder
|
|
99
|
+
|
|
100
|
+
// Load and decode audio file
|
|
101
|
+
const audioBuffer = await decode(readFileSync('audio.wav'));
|
|
102
|
+
|
|
103
|
+
// Create analyzer
|
|
104
|
+
const mfccAnalyzer = new MFCCAnalyzer({
|
|
105
|
+
sampleRate: audioBuffer.sampleRate
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Process audio frames
|
|
109
|
+
const frameSize = 1024;
|
|
110
|
+
for (let i = 0; i < audioBuffer.length; i += frameSize) {
|
|
111
|
+
const frame = audioBuffer.getChannelData(0).subarray(i, i + frameSize);
|
|
112
|
+
const features = mfccAnalyzer.analyzeFrame(frame);
|
|
113
|
+
// Use features for ML models...
|
|
114
|
+
}
|
|
56
115
|
```
|
|
57
116
|
|
|
58
117
|
### Development
|
|
@@ -97,48 +156,26 @@ Each analyzer is a self-contained class that:
|
|
|
97
156
|
### Basic Usage
|
|
98
157
|
|
|
99
158
|
```typescript
|
|
100
|
-
import { FFTAnalyzer } from '
|
|
101
|
-
import { MFCCAnalyzer } from './analysis/MFCCAnalyzer';
|
|
102
|
-
import { visualizeFFT } from './visualizations/analyzerVisualizers';
|
|
159
|
+
import { FFTAnalyzer, MFCCAnalyzer } from 'audio-ml';
|
|
103
160
|
|
|
104
|
-
// Create
|
|
161
|
+
// Create analyzers
|
|
105
162
|
const fftAnalyzer = new FFTAnalyzer({
|
|
106
163
|
sampleRate: 44100,
|
|
107
164
|
fftSize: 1024
|
|
108
165
|
});
|
|
109
166
|
|
|
167
|
+
const mfccAnalyzer = new MFCCAnalyzer({
|
|
168
|
+
sampleRate: 44100
|
|
169
|
+
});
|
|
170
|
+
|
|
110
171
|
// Analyze a frame
|
|
111
172
|
const pcmFrame = new Float32Array(1024); // Your audio data
|
|
112
173
|
const spectrum = fftAnalyzer.analyzeFrame(pcmFrame);
|
|
174
|
+
const mfccFeatures = mfccAnalyzer.analyzeFrame(pcmFrame);
|
|
113
175
|
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Using VisualizationManager
|
|
120
|
-
|
|
121
|
-
```typescript
|
|
122
|
-
import { VisualizationManager } from './visualizations';
|
|
123
|
-
import { FFTAnalyzer } from './analysis/FFTAnalyzer';
|
|
124
|
-
|
|
125
|
-
const container = document.getElementById('app')!;
|
|
126
|
-
const manager = new VisualizationManager(container);
|
|
127
|
-
|
|
128
|
-
const analyzer = new FFTAnalyzer({ sampleRate: 44100 });
|
|
129
|
-
const canvas = document.createElement('canvas');
|
|
130
|
-
canvas.width = 400;
|
|
131
|
-
canvas.height = 200;
|
|
132
|
-
|
|
133
|
-
manager.addVisualization(analyzer, canvas, 'FFT', {
|
|
134
|
-
color: '#00ff00'
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// Update with audio data
|
|
138
|
-
processor.onaudioprocess = (event) => {
|
|
139
|
-
const pcm = event.inputBuffer.getChannelData(0);
|
|
140
|
-
manager.update(pcm);
|
|
141
|
-
};
|
|
176
|
+
// Use the features for your ML model or further processing
|
|
177
|
+
console.log('FFT Spectrum:', spectrum);
|
|
178
|
+
console.log('MFCC Features:', mfccFeatures);
|
|
142
179
|
```
|
|
143
180
|
|
|
144
181
|
## Analyzers Reference
|
|
@@ -187,11 +224,19 @@ processor.onaudioprocess = (event) => {
|
|
|
187
224
|
- **TypeScript** - Type-safe JavaScript
|
|
188
225
|
- **Vite** - Build tool and dev server
|
|
189
226
|
|
|
190
|
-
##
|
|
227
|
+
## Platform Support
|
|
191
228
|
|
|
229
|
+
### Web Browser
|
|
192
230
|
- Modern browsers with Web Audio API support
|
|
193
231
|
- Microphone access required for real-time analysis
|
|
194
232
|
- Canvas API for visualizations
|
|
233
|
+
- Works with ES modules and bundlers (Vite, Webpack, Rollup, etc.)
|
|
234
|
+
|
|
235
|
+
### Node.js
|
|
236
|
+
- Node.js 18.0.0 or higher
|
|
237
|
+
- Works with CommonJS and ES modules
|
|
238
|
+
- Compatible with audio decoding libraries (node-wav, audio-decode, etc.)
|
|
239
|
+
- Perfect for server-side audio processing and ML pipelines
|
|
195
240
|
|
|
196
241
|
## Contributing
|
|
197
242
|
|
|
@@ -205,7 +250,7 @@ This project is designed to be extensible. To add a new analyzer:
|
|
|
205
250
|
|
|
206
251
|
## License
|
|
207
252
|
|
|
208
|
-
MIT
|
|
253
|
+
MIT - See [LICENSE](LICENSE) file for details
|
|
209
254
|
|
|
210
255
|
## Resources
|
|
211
256
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "audio-ml",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A comprehensive JavaScript/TypeScript library for audio feature extraction, designed for machine learning applications and voice AI systems",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/analysis/index.js",
|
|
@@ -18,11 +18,8 @@
|
|
|
18
18
|
"LICENSE"
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"build:app": "tsc && vite build",
|
|
24
|
-
"preview": "vite preview",
|
|
25
|
-
"prepublishOnly": "yarn build"
|
|
21
|
+
"build:package": "tsc",
|
|
22
|
+
"prepublishOnly": "yarn build:package"
|
|
26
23
|
},
|
|
27
24
|
"keywords": [
|
|
28
25
|
"audio",
|
|
@@ -45,8 +42,7 @@
|
|
|
45
42
|
"url": "git+https://github.com/AbijahKaj/audio-ml.git"
|
|
46
43
|
},
|
|
47
44
|
"devDependencies": {
|
|
48
|
-
"typescript": "~5.9.3"
|
|
49
|
-
"vite": "^7.2.4"
|
|
45
|
+
"typescript": "~5.9.3"
|
|
50
46
|
},
|
|
51
47
|
"dependencies": {
|
|
52
48
|
"fft.js": "^4.0.4"
|