@openclaw/whatsapp 2026.5.31-beta.2 → 2026.5.31-beta.4
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/dist/api.js +8 -8
- package/dist/{channel-DA2BAIo5.js → channel-BbtRTgNk.js} +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.runtime-Q1LZDB5s.js → channel.runtime-Cf2UgrhZ.js} +3 -3
- package/dist/{channel.setup-DHXOo4h5.js → channel.setup-DaIyWos-.js} +1 -1
- package/dist/{connection-controller-Bnm4INld.js → connection-controller-B07CNCkw.js} +1 -1
- package/dist/{login-2fuBM7Je.js → login-CRtqboZq.js} +2 -2
- package/dist/{login-qr-B1o7GFy8.js → login-qr-B27eAPhh.js} +8 -4
- package/dist/login-qr-runtime.js +5 -5
- package/dist/{monitor-BVRq04Dt.js → monitor-CnioHf5V.js} +34 -28
- package/dist/runtime-api.js +3 -3
- package/dist/{session-DyGWNClj.js → session-mBuvPUCy.js} +27 -18
- package/dist/{setup-core-OvPMaAsx.js → setup-core-C3XZ2KBH.js} +5 -5
- package/dist/{setup-finalize-Dk23pfKc.js → setup-finalize-B7FVDzwJ.js} +2 -2
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-F-jVrH8u.js → setup-surface-CGTWO_-E.js} +1 -1
- package/node_modules/audio-buffer/.eslintrc.json +44 -0
- package/node_modules/audio-buffer/.github/workflows/node.js.yml +31 -0
- package/node_modules/audio-buffer/.travis.yml +7 -0
- package/node_modules/{@audio/decode-opus → audio-buffer}/LICENSE +2 -5
- package/node_modules/audio-buffer/index.js +76 -0
- package/node_modules/audio-buffer/package.json +37 -0
- package/node_modules/audio-buffer/readme.md +56 -0
- package/node_modules/audio-decode/.eslintrc.json +43 -0
- package/node_modules/audio-decode/.github/workflows/test.js.yml +20 -11
- package/node_modules/audio-decode/.travis.yml +13 -0
- package/node_modules/audio-decode/audio-decode.d.ts +10 -48
- package/node_modules/audio-decode/audio-decode.js +77 -193
- package/node_modules/audio-decode/package.json +21 -49
- package/node_modules/audio-decode/readme.md +29 -129
- package/node_modules/audio-decode/tea.yaml +6 -0
- package/node_modules/audio-decode/test-case.js +11 -0
- package/node_modules/audio-decode/test.html +10 -29
- package/node_modules/audio-decode/test.js +107 -0
- package/node_modules/node-wav/README.md +35 -0
- package/node_modules/node-wav/file.wav +0 -0
- package/node_modules/node-wav/index.js +291 -0
- package/node_modules/node-wav/package.json +29 -0
- package/node_modules/node-wav/tests/file1.wav +0 -0
- package/node_modules/node-wav/tests/test.js +66 -0
- package/node_modules/node-wav/x.js +12 -0
- package/node_modules/node-wav/x.json +86702 -0
- package/node_modules/node-wav/x.js~ +13 -0
- package/npm-shrinkwrap.json +32 -149
- package/package.json +5 -5
- package/node_modules/@audio/decode-aac/LICENSE +0 -9
- package/node_modules/@audio/decode-aac/README.md +0 -60
- package/node_modules/@audio/decode-aac/decode-aac.d.ts +0 -16
- package/node_modules/@audio/decode-aac/decode-aac.js +0 -391
- package/node_modules/@audio/decode-aac/package.json +0 -47
- package/node_modules/@audio/decode-aac/src/aac.wasm.cjs +0 -0
- package/node_modules/@audio/decode-aiff/LICENSE +0 -21
- package/node_modules/@audio/decode-aiff/README.md +0 -53
- package/node_modules/@audio/decode-aiff/decode-aiff.d.ts +0 -16
- package/node_modules/@audio/decode-aiff/decode-aiff.js +0 -583
- package/node_modules/@audio/decode-aiff/package.json +0 -42
- package/node_modules/@audio/decode-amr/LICENSE +0 -191
- package/node_modules/@audio/decode-amr/README.md +0 -65
- package/node_modules/@audio/decode-amr/decode-amr.d.ts +0 -16
- package/node_modules/@audio/decode-amr/decode-amr.js +0 -159
- package/node_modules/@audio/decode-amr/package.json +0 -48
- package/node_modules/@audio/decode-amr/src/amr.wasm.cjs +0 -0
- package/node_modules/@audio/decode-caf/LICENSE +0 -21
- package/node_modules/@audio/decode-caf/README.md +0 -55
- package/node_modules/@audio/decode-caf/decode-caf.d.ts +0 -16
- package/node_modules/@audio/decode-caf/decode-caf.js +0 -190
- package/node_modules/@audio/decode-caf/package.json +0 -43
- package/node_modules/@audio/decode-flac/LICENSE +0 -25
- package/node_modules/@audio/decode-flac/README.md +0 -23
- package/node_modules/@audio/decode-flac/decode-flac.d.ts +0 -16
- package/node_modules/@audio/decode-flac/decode-flac.js +0 -2994
- package/node_modules/@audio/decode-flac/meta.js +0 -115
- package/node_modules/@audio/decode-flac/package.json +0 -49
- package/node_modules/@audio/decode-mp3/LICENSE +0 -25
- package/node_modules/@audio/decode-mp3/README.md +0 -23
- package/node_modules/@audio/decode-mp3/decode-mp3.d.ts +0 -16
- package/node_modules/@audio/decode-mp3/decode-mp3.js +0 -868
- package/node_modules/@audio/decode-mp3/meta.js +0 -143
- package/node_modules/@audio/decode-mp3/package.json +0 -50
- package/node_modules/@audio/decode-opus/README.md +0 -23
- package/node_modules/@audio/decode-opus/decode-opus.d.ts +0 -16
- package/node_modules/@audio/decode-opus/decode-opus.js +0 -3179
- package/node_modules/@audio/decode-opus/package.json +0 -47
- package/node_modules/@audio/decode-qoa/LICENSE +0 -25
- package/node_modules/@audio/decode-qoa/README.md +0 -21
- package/node_modules/@audio/decode-qoa/decode-qoa.d.ts +0 -16
- package/node_modules/@audio/decode-qoa/decode-qoa.js +0 -278
- package/node_modules/@audio/decode-qoa/package.json +0 -46
- package/node_modules/@audio/decode-vorbis/LICENSE +0 -25
- package/node_modules/@audio/decode-vorbis/README.md +0 -23
- package/node_modules/@audio/decode-vorbis/decode-vorbis.d.ts +0 -16
- package/node_modules/@audio/decode-vorbis/decode-vorbis.js +0 -2984
- package/node_modules/@audio/decode-vorbis/package.json +0 -47
- package/node_modules/@audio/decode-wav/decode-wav.js +0 -104
- package/node_modules/@audio/decode-wav/meta.js +0 -114
- package/node_modules/@audio/decode-wav/package.json +0 -27
- package/node_modules/@audio/decode-webm/LICENSE +0 -21
- package/node_modules/@audio/decode-webm/README.md +0 -57
- package/node_modules/@audio/decode-webm/decode-webm.d.ts +0 -16
- package/node_modules/@audio/decode-webm/decode-webm.js +0 -3964
- package/node_modules/@audio/decode-webm/package.json +0 -51
- package/node_modules/@audio/decode-wma/LICENSE +0 -12
- package/node_modules/@audio/decode-wma/README.md +0 -76
- package/node_modules/@audio/decode-wma/decode-wma.d.ts +0 -33
- package/node_modules/@audio/decode-wma/decode-wma.js +0 -525
- package/node_modules/@audio/decode-wma/package.json +0 -47
- package/node_modules/@audio/decode-wma/src/wma.wasm.cjs +0 -0
- package/node_modules/audio-decode/.claude/settings.json +0 -204
- package/node_modules/audio-decode/.gitmodules +0 -9
- package/node_modules/audio-decode/meta.js +0 -11
- package/node_modules/audio-decode/stream.d.ts +0 -15
- package/node_modules/audio-decode/stream.js +0 -1
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
2
|
+
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
|
3
|
+
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
const data_decoders = {
|
|
7
|
+
pcm8: (buffer, offset, output, channels, samples) => {
|
|
8
|
+
let input = new Uint8Array(buffer, offset);
|
|
9
|
+
let pos = 0;
|
|
10
|
+
for (let i = 0; i < samples; ++i) {
|
|
11
|
+
for (let ch = 0; ch < channels; ++ch) {
|
|
12
|
+
let data = input[pos++] - 128;
|
|
13
|
+
output[ch][i] = data < 0 ? data / 128 : data / 127;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
pcm16: (buffer, offset, output, channels, samples) => {
|
|
18
|
+
let input = new Int16Array(buffer, offset);
|
|
19
|
+
let pos = 0;
|
|
20
|
+
for (let i = 0; i < samples; ++i) {
|
|
21
|
+
for (let ch = 0; ch < channels; ++ch) {
|
|
22
|
+
let data = input[pos++];
|
|
23
|
+
output[ch][i] = data < 0 ? data / 32768 : data / 32767;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
pcm24: (buffer, offset, output, channels, samples) => {
|
|
28
|
+
let input = new Uint8Array(buffer, offset);
|
|
29
|
+
let pos = 0;
|
|
30
|
+
for (let i = 0; i < samples; ++i) {
|
|
31
|
+
for (let ch = 0; ch < channels; ++ch) {
|
|
32
|
+
let x0 = input[pos++];
|
|
33
|
+
let x1 = input[pos++];
|
|
34
|
+
let x2 = input[pos++];
|
|
35
|
+
let xx = (x0 + (x1 << 8) + (x2 << 16));
|
|
36
|
+
let data = xx > 0x800000 ? xx - 0x1000000 : xx;
|
|
37
|
+
output[ch][i] = data < 0 ? data / 8388608 : data / 8388607;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
pcm32: (buffer, offset, output, channels, samples) => {
|
|
42
|
+
let input = new Int32Array(buffer, offset);
|
|
43
|
+
let pos = 0;
|
|
44
|
+
for (let i = 0; i < samples; ++i) {
|
|
45
|
+
for (let ch = 0; ch < channels; ++ch) {
|
|
46
|
+
let data = input[pos++];
|
|
47
|
+
output[ch][i] = data < 0 ? data / 2147483648 : data / 2147483647;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
pcm32f: (buffer, offset, output, channels, samples) => {
|
|
52
|
+
let input = new Float32Array(buffer, offset);
|
|
53
|
+
let pos = 0;
|
|
54
|
+
for (let i = 0; i < samples; ++i) {
|
|
55
|
+
for (let ch = 0; ch < channels; ++ch)
|
|
56
|
+
output[ch][i] = input[pos++];
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
pcm64f: (buffer, offset, output, channels, samples) => {
|
|
60
|
+
let input = new Float64Array(buffer, offset);
|
|
61
|
+
let pos = 0;
|
|
62
|
+
for (let i = 0; i < samples; ++i) {
|
|
63
|
+
for (let ch = 0; ch < channels; ++ch)
|
|
64
|
+
output[ch][i] = input[pos++];
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const data_encoders = {
|
|
70
|
+
pcm8: (buffer, offset, input, channels, samples) => {
|
|
71
|
+
let output = new Uint8Array(buffer, offset);
|
|
72
|
+
let pos = 0;
|
|
73
|
+
for (let i = 0; i < samples; ++i) {
|
|
74
|
+
for (let ch = 0; ch < channels; ++ch) {
|
|
75
|
+
let v = Math.max(-1, Math.min(input[ch][i], 1));
|
|
76
|
+
v = ((v * 0.5 + 0.5) * 255) | 0;
|
|
77
|
+
output[pos++] = v;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
pcm16: (buffer, offset, input, channels, samples) => {
|
|
82
|
+
let output = new Int16Array(buffer, offset);
|
|
83
|
+
let pos = 0;
|
|
84
|
+
for (let i = 0; i < samples; ++i) {
|
|
85
|
+
for (let ch = 0; ch < channels; ++ch) {
|
|
86
|
+
let v = Math.max(-1, Math.min(input[ch][i], 1));
|
|
87
|
+
v = ((v < 0) ? v * 32768 : v * 32767) | 0;
|
|
88
|
+
output[pos++] = v;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
pcm24: (buffer, offset, input, channels, samples) => {
|
|
93
|
+
let output = new Uint8Array(buffer, offset);
|
|
94
|
+
let pos = 0;
|
|
95
|
+
for (let i = 0; i < samples; ++i) {
|
|
96
|
+
for (let ch = 0; ch < channels; ++ch) {
|
|
97
|
+
let v = Math.max(-1, Math.min(input[ch][i], 1));
|
|
98
|
+
v = ((v < 0) ? 0x1000000 + v * 8388608 : v * 8388607) | 0;
|
|
99
|
+
output[pos++] = (v >> 0) & 0xff;
|
|
100
|
+
output[pos++] = (v >> 8) & 0xff;
|
|
101
|
+
output[pos++] = (v >> 16) & 0xff;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
pcm32: (buffer, offset, input, channels, samples) => {
|
|
106
|
+
let output = new Int32Array(buffer, offset);
|
|
107
|
+
let pos = 0;
|
|
108
|
+
for (let i = 0; i < samples; ++i) {
|
|
109
|
+
for (let ch = 0; ch < channels; ++ch) {
|
|
110
|
+
let v = Math.max(-1, Math.min(input[ch][i], 1));
|
|
111
|
+
v = ((v < 0) ? v * 2147483648 : v * 2147483647) | 0;
|
|
112
|
+
output[pos++] = v;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
pcm32f: (buffer, offset, input, channels, samples) => {
|
|
117
|
+
let output = new Float32Array(buffer, offset);
|
|
118
|
+
let pos = 0;
|
|
119
|
+
for (let i = 0; i < samples; ++i) {
|
|
120
|
+
for (let ch = 0; ch < channels; ++ch) {
|
|
121
|
+
let v = Math.max(-1, Math.min(input[ch][i], 1));
|
|
122
|
+
output[pos++] = v;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
pcm64f: (buffer, offset, input, channels, samples) => {
|
|
127
|
+
let output = new Float64Array(buffer, offset);
|
|
128
|
+
let pos = 0;
|
|
129
|
+
for (let i = 0; i < samples; ++i) {
|
|
130
|
+
for (let ch = 0; ch < channels; ++ch) {
|
|
131
|
+
let v = Math.max(-1, Math.min(input[ch][i], 1));
|
|
132
|
+
output[pos++] = v;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
function lookup(table, bitDepth, floatingPoint) {
|
|
139
|
+
let name = 'pcm' + bitDepth + (floatingPoint ? 'f' : '');
|
|
140
|
+
let fn = table[name];
|
|
141
|
+
if (!fn)
|
|
142
|
+
throw new TypeError('Unsupported data format: ' + name);
|
|
143
|
+
return fn;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function decode(buffer) {
|
|
147
|
+
let pos = 0, end = 0;
|
|
148
|
+
if (buffer.buffer) {
|
|
149
|
+
// If we are handed a typed array or a buffer, then we have to consider the
|
|
150
|
+
// offset and length into the underlying array buffer.
|
|
151
|
+
pos = buffer.byteOffset;
|
|
152
|
+
end = buffer.length;
|
|
153
|
+
buffer = buffer.buffer;
|
|
154
|
+
} else {
|
|
155
|
+
// If we are handed a straight up array buffer, start at offset 0 and use
|
|
156
|
+
// the full length of the buffer.
|
|
157
|
+
pos = 0;
|
|
158
|
+
end = buffer.byteLength;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
let v = new DataView(buffer);
|
|
162
|
+
|
|
163
|
+
function u8() {
|
|
164
|
+
let x = v.getUint8(pos);
|
|
165
|
+
pos++;
|
|
166
|
+
return x;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function u16() {
|
|
170
|
+
let x = v.getUint16(pos, true);
|
|
171
|
+
pos += 2;
|
|
172
|
+
return x;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function u32() {
|
|
176
|
+
let x = v.getUint32(pos, true);
|
|
177
|
+
pos += 4;
|
|
178
|
+
return x;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function string(len) {
|
|
182
|
+
let str = '';
|
|
183
|
+
for (let i = 0; i < len; ++i)
|
|
184
|
+
str += String.fromCharCode(u8());
|
|
185
|
+
return str;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (string(4) !== 'RIFF')
|
|
189
|
+
throw new TypeError('Invalid WAV file');
|
|
190
|
+
u32();
|
|
191
|
+
if (string(4) !== 'WAVE')
|
|
192
|
+
throw new TypeError('Invalid WAV file');
|
|
193
|
+
|
|
194
|
+
let fmt;
|
|
195
|
+
|
|
196
|
+
while (pos < end) {
|
|
197
|
+
let type = string(4);
|
|
198
|
+
let size = u32();
|
|
199
|
+
let next = pos + size;
|
|
200
|
+
switch (type) {
|
|
201
|
+
case 'fmt ':
|
|
202
|
+
let formatId = u16();
|
|
203
|
+
if (formatId !== 0x0001 && formatId !== 0x0003)
|
|
204
|
+
throw new TypeError('Unsupported format in WAV file: ' + formatId.toString(16));
|
|
205
|
+
fmt = {
|
|
206
|
+
format: 'lpcm',
|
|
207
|
+
floatingPoint: formatId === 0x0003,
|
|
208
|
+
channels: u16(),
|
|
209
|
+
sampleRate: u32(),
|
|
210
|
+
byteRate: u32(),
|
|
211
|
+
blockSize: u16(),
|
|
212
|
+
bitDepth: u16(),
|
|
213
|
+
};
|
|
214
|
+
break;
|
|
215
|
+
case 'data':
|
|
216
|
+
if (!fmt)
|
|
217
|
+
throw new TypeError('Missing "fmt " chunk.');
|
|
218
|
+
let samples = Math.floor(size / fmt.blockSize);
|
|
219
|
+
let channels = fmt.channels;
|
|
220
|
+
let sampleRate = fmt.sampleRate;
|
|
221
|
+
let channelData = [];
|
|
222
|
+
for (let ch = 0; ch < channels; ++ch)
|
|
223
|
+
channelData[ch] = new Float32Array(samples);
|
|
224
|
+
lookup(data_decoders, fmt.bitDepth, fmt.floatingPoint)(buffer, pos, channelData, channels, samples);
|
|
225
|
+
return {
|
|
226
|
+
sampleRate: sampleRate,
|
|
227
|
+
channelData: channelData
|
|
228
|
+
};
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
pos = next;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function encode(channelData, opts) {
|
|
236
|
+
let sampleRate = opts.sampleRate || 16000;
|
|
237
|
+
let floatingPoint = !!(opts.float || opts.floatingPoint);
|
|
238
|
+
let bitDepth = floatingPoint ? 32 : ((opts.bitDepth | 0) || 16);
|
|
239
|
+
let channels = channelData.length;
|
|
240
|
+
let samples = channelData[0].length;
|
|
241
|
+
let buffer = new ArrayBuffer(44 + (samples * channels * (bitDepth >> 3)));
|
|
242
|
+
|
|
243
|
+
let v = new DataView(buffer);
|
|
244
|
+
let pos = 0;
|
|
245
|
+
|
|
246
|
+
function u8(x) {
|
|
247
|
+
v.setUint8(pos++, x);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function u16(x) {
|
|
251
|
+
v.setUint16(pos, x, true);
|
|
252
|
+
pos += 2;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function u32(x) {
|
|
256
|
+
v.setUint32(pos, x, true);
|
|
257
|
+
pos += 4;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function string(s) {
|
|
261
|
+
for (var i = 0; i < s.length; ++i)
|
|
262
|
+
u8(s.charCodeAt(i));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// write header
|
|
266
|
+
string('RIFF');
|
|
267
|
+
u32(buffer.byteLength - 8);
|
|
268
|
+
string('WAVE');
|
|
269
|
+
|
|
270
|
+
// write 'fmt ' chunk
|
|
271
|
+
string('fmt ');
|
|
272
|
+
u32(16);
|
|
273
|
+
u16(floatingPoint ? 0x0003 : 0x0001);
|
|
274
|
+
u16(channels);
|
|
275
|
+
u32(sampleRate);
|
|
276
|
+
u32(sampleRate * channels * (bitDepth >> 3));
|
|
277
|
+
u16(channels * (bitDepth >> 3));
|
|
278
|
+
u16(bitDepth);
|
|
279
|
+
|
|
280
|
+
// write 'data' chunk
|
|
281
|
+
string('data');
|
|
282
|
+
u32(buffer.byteLength - 44);
|
|
283
|
+
lookup(data_encoders, bitDepth, floatingPoint)(buffer, pos, channelData, channels, samples);
|
|
284
|
+
|
|
285
|
+
return Buffer(buffer);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
module.exports = {
|
|
289
|
+
decode: decode,
|
|
290
|
+
encode: encode,
|
|
291
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "node-wav",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "High performance WAV file decoder and encoder",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "./node_modules/nodeunit/bin/nodeunit ./tests/test.js"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/andreasgal/node-wav.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"wav",
|
|
15
|
+
"decode"
|
|
16
|
+
],
|
|
17
|
+
"author": "Andreas Gal",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"homepage": "https://github.com/andreasgal/node-wav",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=4.4.0"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"nodeunit": "^0.9.1",
|
|
26
|
+
"wav-decoder": "^1.1.0",
|
|
27
|
+
"wav-encoder": "^1.1.0"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
2
|
+
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
|
3
|
+
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const encoder = require('wav-encoder');
|
|
8
|
+
const decoder = require('wav-decoder');
|
|
9
|
+
const wav = require('../index');
|
|
10
|
+
|
|
11
|
+
function make_test_data(channels, samples) {
|
|
12
|
+
let data = [];
|
|
13
|
+
for (let ch = 0; ch < channels; ++ch) {
|
|
14
|
+
data[ch] = new Float32Array(samples);
|
|
15
|
+
for (let n = 0; n < samples; ++n)
|
|
16
|
+
data[ch][n] = Math.random();
|
|
17
|
+
}
|
|
18
|
+
return data;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.test_wav = test => {
|
|
22
|
+
test.expect(25);
|
|
23
|
+
let samples = 10;
|
|
24
|
+
let channels = 2;
|
|
25
|
+
let data = make_test_data(channels, samples);
|
|
26
|
+
Promise.all([8, 16, 24, 32, '32f'].map(bitDepth => new Promise((resolve, reject) => {
|
|
27
|
+
let floatingPoint = false;
|
|
28
|
+
if (bitDepth == '32f') {
|
|
29
|
+
bitDepth = 32;
|
|
30
|
+
floatingPoint = true;
|
|
31
|
+
}
|
|
32
|
+
let audioData = {
|
|
33
|
+
length: samples,
|
|
34
|
+
numberOfChannels: channels,
|
|
35
|
+
sampleRate: 16000,
|
|
36
|
+
channelData: data
|
|
37
|
+
};
|
|
38
|
+
let opts = {
|
|
39
|
+
floatingPoint: floatingPoint,
|
|
40
|
+
bitDepth: bitDepth,
|
|
41
|
+
};
|
|
42
|
+
encoder.encode(audioData, opts).then(buffer => {
|
|
43
|
+
let encoded = wav.encode(audioData.channelData, opts);
|
|
44
|
+
test.equal(new Buffer(buffer).toString('hex'), encoded.toString('hex'), 'our encoder should match wav-encoder');
|
|
45
|
+
let decoded = wav.decode(buffer);
|
|
46
|
+
decoder.decode(buffer).then(reference => {
|
|
47
|
+
test.equal(reference.length, decoded.channelData[0].length, 'number of samples should match');
|
|
48
|
+
test.equal(reference.numberOfChannels, decoded.channelData.length, 'number of channels should match');
|
|
49
|
+
test.equal(reference.sampleRate, decoded.sampleRate, 'sample rate should match');
|
|
50
|
+
test.deepEqual(reference.channelData, decoded.channelData, 'data should match');
|
|
51
|
+
resolve();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}))).then(() => test.done());
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
exports.test_buffer_offset = test => {
|
|
58
|
+
test.expect(1);
|
|
59
|
+
let files = ["./tests/file1.wav"];
|
|
60
|
+
files.forEach(file => {
|
|
61
|
+
let buffer = fs.readFileSync(file);
|
|
62
|
+
let decoded = wav.decode(buffer);
|
|
63
|
+
test.equal(decoded.sampleRate, 16000);
|
|
64
|
+
test.done();
|
|
65
|
+
});
|
|
66
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
let fs = require('fs');
|
|
2
|
+
let wav = require('./index');
|
|
3
|
+
|
|
4
|
+
//let files = JSON.parse(fs.readFileSync('x.json'));
|
|
5
|
+
|
|
6
|
+
let files = ["../train/data//other/0005932e-db17-4a21-b99f-5e10f84a9e74.wav"];
|
|
7
|
+
|
|
8
|
+
files.forEach(file => {
|
|
9
|
+
console.log(file);
|
|
10
|
+
let buffer = fs.readFileSync(file);
|
|
11
|
+
let w = wav.decode(buffer);
|
|
12
|
+
});
|