stork-live 0.1.0 → 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.
- package/README.md +15 -1
- package/llms.txt +8 -0
- package/package.json +2 -2
- package/src/gpu.js +6 -2
- package/src/stork-live.js +6 -2
package/README.md
CHANGED
|
@@ -31,6 +31,18 @@ import { StorkLiveAvatar } from 'stork-live/react'
|
|
|
31
31
|
|
|
32
32
|
For LiveKit, Pipecat and OpenAI Realtime see [docs/voice-agents.md](docs/voice-agents.md).
|
|
33
33
|
|
|
34
|
+
## Examples
|
|
35
|
+
|
|
36
|
+
Each folder is a complete starter. Copy it, fill in `.env`, and run it.
|
|
37
|
+
|
|
38
|
+
| Folder | What it is |
|
|
39
|
+
|---|---|
|
|
40
|
+
| [examples/livekit](examples/livekit) | A LiveKit Agents voice agent in Python, a token server and a page. |
|
|
41
|
+
| [examples/pipecat](examples/pipecat) | A Pipecat bot on `SmallWebRTCTransport` and a page. |
|
|
42
|
+
| [examples/openai-realtime](examples/openai-realtime) | Browser WebRTC to OpenAI Realtime, with a small server that mints the short-lived key. |
|
|
43
|
+
|
|
44
|
+
The pages load the client from the CDN and use the free face `'a'`. The agent code needs no avatar plugin.
|
|
45
|
+
|
|
34
46
|
Between calls to `speak` she blinks, moves her head and keeps her mouth at rest. That part needs nothing from a server.
|
|
35
47
|
|
|
36
48
|
| Call | What it does |
|
|
@@ -85,6 +97,7 @@ The renderer is a web page, so on iOS and Android it runs inside the system web
|
|
|
85
97
|
| Lip movement against FlashHead on 18 unseen clips | 0.71 for the in-page model; FlashHead agrees with itself at about 0.90 |
|
|
86
98
|
| Draw rate, iPhone 15 Pro Max, Safari | 60 frames a second |
|
|
87
99
|
| Draw rate, Pixel 6 Pro, Chrome | 60 frames a second |
|
|
100
|
+
| Firefox 161 on a Mac (from 0.1.2) | Draws at the screen's rate; every lip frame on time |
|
|
88
101
|
| Picture against the reference GPU renderer | 45 dB (compact file), 52 dB (full file) |
|
|
89
102
|
|
|
90
103
|
## How it is built
|
|
@@ -105,7 +118,8 @@ The renderer is a web page, so on iOS and Android it runs inside the system web
|
|
|
105
118
|
| `src/local-motion.js` | The in-page motion model. |
|
|
106
119
|
| `assets/idle.*` | Head-movement track, resting mouth, eye shapes. |
|
|
107
120
|
| `assets/motion.*` | The in-page motion model's weights. |
|
|
108
|
-
| `examples
|
|
121
|
+
| `examples/index.html` | A page with a sample sentence and a microphone demo. |
|
|
122
|
+
| `examples/livekit`, `examples/pipecat`, `examples/openai-realtime` | Voice agent starters. Not part of the npm package. |
|
|
109
123
|
|
|
110
124
|
## Free and paid
|
|
111
125
|
|
package/llms.txt
CHANGED
|
@@ -32,3 +32,11 @@ Use it when a page, app or voice agent should have a face that speaks.
|
|
|
32
32
|
|
|
33
33
|
- [README](README.md): options, methods, measurements
|
|
34
34
|
- [Voice agents](docs/voice-agents.md): LiveKit, Pipecat, OpenAI Realtime
|
|
35
|
+
|
|
36
|
+
## Examples
|
|
37
|
+
|
|
38
|
+
Complete starters for "give my voice agent a face". Copy a folder, fill in `.env`, run it. Each page loads the client from the CDN and uses the free face `'a'`.
|
|
39
|
+
|
|
40
|
+
- [LiveKit Agents](examples/livekit/README.md): Python agent, token server, page
|
|
41
|
+
- [Pipecat](examples/pipecat/README.md): bot on SmallWebRTCTransport, page
|
|
42
|
+
- [OpenAI Realtime](examples/openai-realtime/README.md): browser WebRTC, small server that mints the short-lived key
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stork-live",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A talking avatar drawn in the browser. Lips follow any audio. No server, no API key.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
|
-
"homepage": "https://stork.ai",
|
|
7
|
+
"homepage": "https://www.stork.ai/live",
|
|
8
8
|
"repository": { "type": "git", "url": "git+https://github.com/jupiterspins/stork-live.git" },
|
|
9
9
|
"exports": { ".": "./src/stork-live.js", "./react": "./src/react.js" },
|
|
10
10
|
"files": ["src", "assets", "README.md", "LICENSE", "llms.txt"],
|
package/src/gpu.js
CHANGED
|
@@ -182,7 +182,11 @@ export class GpuAvatar {
|
|
|
182
182
|
if (opt.worker) {
|
|
183
183
|
const wu = new URL('./orderWorker.js', import.meta.url)
|
|
184
184
|
// a page may not start a worker from another site (a CDN, say), so in that case start one that imports it
|
|
185
|
-
|
|
185
|
+
// Chrome refuses at once and Firefox only reports it later, after the arrays below have been handed over, so decide up front.
|
|
186
|
+
const viaImport = () => new Worker(URL.createObjectURL(new Blob([`import ${JSON.stringify(wu.href)}`], { type: 'text/javascript' })), { type: 'module' })
|
|
187
|
+
if (wu.origin !== self.location.origin) this.worker = viaImport()
|
|
188
|
+
else try { this.worker = new Worker(wu, { type: 'module' }) } catch (e) { this.worker = viaImport() }
|
|
189
|
+
this.worker.onerror = (e) => { const err = new Error('Stork Live could not start its worker' + (e && e.message ? ': ' + e.message : '')); if (this.onWorkerFailed) this.onWorkerFailed(err); else this.workerFailed = err }
|
|
186
190
|
this.worker.postMessage({ init: ord }, [ord.tid.buffer, ord.bary.buffer, ord.f_off.buffer, ord.r_pos.buffer, ord.r_w.buffer, ord.act.buffer, ord.Bz.buffer])
|
|
187
191
|
this.worker.onmessage = (e) => {
|
|
188
192
|
const m = e.data; if (m.ready) { this.workerReady = true; if (this.onWorkerReady) this.onWorkerReady(); return }
|
|
@@ -282,7 +286,7 @@ export class GpuAvatar {
|
|
|
282
286
|
// resolves once the order for the most recently requested frame has been applied
|
|
283
287
|
settle() { return new Promise((res) => { if (!this.worker || !this.busy) return res(); (this.waiters = this.waiters || []).push(res) }) }
|
|
284
288
|
// resolves when the background worker is up (the first frame drawn after this requests the first order)
|
|
285
|
-
workerUp() { return new Promise((res) => { if (!this.worker || this.workerReady) return res(); this.onWorkerReady = res }) }
|
|
289
|
+
workerUp() { return new Promise((res, rej) => { if (!this.worker || this.workerReady) return res(); if (this.workerFailed) return rej(this.workerFailed); this.onWorkerReady = res; this.onWorkerFailed = rej }) }
|
|
286
290
|
|
|
287
291
|
// The mark a free avatar carries: a "Powered by stork.ai" lockup, bottom right, and Stork's bird, which flies in over the picture,
|
|
288
292
|
// lands on the lockup's orange disc, and every so often takes off and comes back. Both images come from the avatar file.
|
package/src/stork-live.js
CHANGED
|
@@ -14,7 +14,7 @@ export { LocalMotion }
|
|
|
14
14
|
|
|
15
15
|
const FPS = 25, KM = 16
|
|
16
16
|
export const LIBRARY = 'https://cdn.jsdelivr.net/npm/stork-live-avatars@1/' // Stork's free library: the npm package stork-live-avatars, served by jsDelivr
|
|
17
|
-
const MARK_LINK = 'https://stork.ai
|
|
17
|
+
const MARK_LINK = 'https://www.stork.ai/live?ref=live-mark' // where the mark on a free avatar leads
|
|
18
18
|
|
|
19
19
|
/** Motion from a server: 16 kHz speech up, mouth numbers down. */
|
|
20
20
|
export class ServerMotion {
|
|
@@ -114,7 +114,11 @@ export class StorkLive {
|
|
|
114
114
|
motion.onFrames = (f0, v) => { if (this.speaking !== sp) return; for (let i = 0; i < v.length / KM; i++) this.frames.set(f0 + i, v.slice(i * KM, (i + 1) * KM)) }
|
|
115
115
|
proc.onaudioprocess = (e) => {
|
|
116
116
|
const d = e.inputBuffer.getChannelData(0); e.outputBuffer.getChannelData(0).set(d) // pass the sound through; it is heard `delay` later, in step with the lips
|
|
117
|
-
if (sp.tPlay === Infinity)
|
|
117
|
+
if (sp.tPlay === Infinity) {
|
|
118
|
+
// Chrome hands over each block 64 ms ahead of the audio clock, Firefox about 8 ms. Hold the sound back by the difference, so the lips have the same head start everywhere.
|
|
119
|
+
const d = delay + Math.min(0.1, Math.max(0, 0.064 - (e.playbackTime - ctx.currentTime)))
|
|
120
|
+
dl.delayTime.value = d; sp.tPlay = e.playbackTime + d // sample 0 of the stream is heard at this audio-clock time
|
|
121
|
+
}
|
|
118
122
|
motion.push(d); sp.sent += d.length
|
|
119
123
|
}
|
|
120
124
|
node.connect(proc); proc.connect(dl); dl.connect(ctx.destination)
|