@nextpa/chat-core 0.1.1 → 0.1.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.
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const CAPTURE_BUFFER_SIZE = 2048;
|
|
2
|
+
|
|
3
|
+
class AudioCaptureProcessor extends AudioWorkletProcessor {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
this.buffer = new Int16Array(CAPTURE_BUFFER_SIZE);
|
|
7
|
+
this.index = 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
process(inputs) {
|
|
11
|
+
const channel = inputs[0]?.[0];
|
|
12
|
+
if (!channel) return true;
|
|
13
|
+
for (const sample of channel) {
|
|
14
|
+
this.buffer[this.index++] = sample * 32768;
|
|
15
|
+
if (this.index >= this.buffer.length) {
|
|
16
|
+
this.port.postMessage(
|
|
17
|
+
{ buffer: this.buffer.slice(0).buffer },
|
|
18
|
+
[this.buffer.slice(0).buffer]
|
|
19
|
+
);
|
|
20
|
+
this.buffer = new Int16Array(CAPTURE_BUFFER_SIZE);
|
|
21
|
+
this.index = 0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
registerProcessor('audio-capture-processor', AudioCaptureProcessor);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextpa/chat-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Framework-neutral voice & text chat engine for the NextPA platform.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"./package.json": "./package.json"
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
|
-
"dist"
|
|
41
|
+
"dist",
|
|
42
|
+
"assets"
|
|
42
43
|
],
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"@google/genai": "^2.8.0",
|