@akropolys/kiku 2.2.37 → 2.2.42
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/EMBED.md +106 -103
- package/README.md +107 -107
- package/dist/embed/embed.js +14 -47
- package/dist/embed/meta.json +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -37
- package/dist/index.mjs.map +1 -1
- package/dist/kiku.js +2 -1
- package/dist/voice-worklet.js +32 -0
- package/package.json +4 -3
package/dist/kiku.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
if (window.Kiku) return;
|
|
3
3
|
const script = document.currentScript;
|
|
4
4
|
const url = new URL('./embed/embed.js', script.src).href;
|
|
5
|
+
const workletUrl = new URL('./voice-worklet.js', script.src).href;
|
|
5
6
|
const styles = document.createElement('link');
|
|
6
7
|
styles.rel = 'stylesheet';
|
|
7
8
|
styles.href = new URL('./styles.css', script.src).href;
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
import(url),
|
|
20
21
|
styled,
|
|
21
22
|
document.body ? Promise.resolve() : new Promise(resolve => document.addEventListener('DOMContentLoaded', resolve, { once: true }))
|
|
22
|
-
]).then(([module]) => { instance = module.mount(options); return instance; })
|
|
23
|
+
]).then(([module]) => { instance = module.mount({ ...options, button: { ...options.button, voiceWorkletUrl: options.button?.voiceWorkletUrl || workletUrl } }); return instance; })
|
|
23
24
|
.catch(error => { pending = undefined; throw error; });
|
|
24
25
|
return pending;
|
|
25
26
|
},
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class KikuCapture extends AudioWorkletProcessor {
|
|
2
|
+
constructor() {
|
|
3
|
+
super();
|
|
4
|
+
this._ratio = sampleRate / 16000;
|
|
5
|
+
this._chunk = 640;
|
|
6
|
+
this._acc = new Int16Array(this._chunk);
|
|
7
|
+
this._n = 0;
|
|
8
|
+
this._pos = 0;
|
|
9
|
+
}
|
|
10
|
+
process(inputs) {
|
|
11
|
+
const ch = inputs[0] && inputs[0][0];
|
|
12
|
+
if (!ch) return true;
|
|
13
|
+
while (this._pos < ch.length) {
|
|
14
|
+
const i = this._pos | 0;
|
|
15
|
+
const frac = this._pos - i;
|
|
16
|
+
const a = ch[i];
|
|
17
|
+
const b = i + 1 < ch.length ? ch[i + 1] : a;
|
|
18
|
+
const s = a + (b - a) * frac;
|
|
19
|
+
const c = s < -1 ? -1 : s > 1 ? 1 : s;
|
|
20
|
+
this._acc[this._n++] = c < 0 ? c * 0x8000 : c * 0x7fff;
|
|
21
|
+
if (this._n === this._chunk) {
|
|
22
|
+
this.port.postMessage(this._acc.buffer, [this._acc.buffer]);
|
|
23
|
+
this._acc = new Int16Array(this._chunk);
|
|
24
|
+
this._n = 0;
|
|
25
|
+
}
|
|
26
|
+
this._pos += this._ratio;
|
|
27
|
+
}
|
|
28
|
+
this._pos -= ch.length;
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
registerProcessor('kiku-capture', KikuCapture);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akropolys/kiku",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.42",
|
|
4
4
|
"description": "The real-time conversational layer for the living web.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"require": "./dist/index.js"
|
|
32
32
|
},
|
|
33
33
|
"./styles.css": "./dist/styles.css",
|
|
34
|
-
"./kiku.js": "./dist/kiku.js"
|
|
34
|
+
"./kiku.js": "./dist/kiku.js",
|
|
35
|
+
"./voice-worklet.js": "./dist/voice-worklet.js"
|
|
35
36
|
},
|
|
36
37
|
"files": [
|
|
37
38
|
"dist",
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
"build:embed": "node scripts/build-embed.mjs"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
|
-
"@akropolys/sdk": "^2.0.
|
|
48
|
+
"@akropolys/sdk": "^2.0.7",
|
|
48
49
|
"react": ">=17",
|
|
49
50
|
"react-dom": ">=17"
|
|
50
51
|
},
|