callable-lipsync 0.0.0-stage → 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ callable-lipsync
2
+ Copyright 2026 Callable
3
+
4
+ This product includes callable-lipsync, a speech-to-face model by Callable.
package/README.md CHANGED
@@ -1,3 +1,332 @@
1
- # Temporary Holding Version
1
+ [![Email](https://img.shields.io/badge/Email-gray.svg?style=for-the-badge&logo=gmail)](mailto:support@callable.com.ai) [![Website](https://img.shields.io/badge/callable.com.ai-blue.svg?style=for-the-badge)](https://callable.com.ai) [![Demo](https://img.shields.io/badge/Live_demo-green.svg?style=for-the-badge)](https://research.callable.com.ai/lipsync/) [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-lightgrey.svg?style=for-the-badge)](https://github.com/callabledev/callable-lipsync/blob/main/LICENSE)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![PyPI version](https://img.shields.io/pypi/v/callable-lipsync)](https://pypi.org/project/callable-lipsync/) [![npm version](https://img.shields.io/npm/v/callable-lipsync)](https://www.npmjs.com/package/callable-lipsync) [![Python version](https://img.shields.io/pypi/pyversions/callable-lipsync)](https://pypi.org/project/callable-lipsync/)
4
+
5
+ <br/>
6
+ <h1 align="center">callable-lipsync</h1>
7
+ <br/>
8
+
9
+ **callable-lipsync** - a tiny pre-trained streaming speech-to-face model by [Callable](https://callable.com.ai/). Speech (audio) goes in, face animation parameters come out (FLAME 2023 Open / ARKit). Needs 160ms lookahead for lips+face and 640ms for head movements. Try the [live demo](https://research.callable.com.ai/lipsync/).
10
+
11
+ Comes in 2 sizes: `tiny` (17.1M; 36x realtime) and `nano` (2.4M; 95x realtime), on one CPU thread in Python. In a browser (WebAssembly) they run at 7x and 18x realtime.
12
+
13
+ Trained on English, might work on other languages.
14
+
15
+ <br/>
16
+
17
+ <p align="center">
18
+ <img src="https://raw.githubusercontent.com/callabledev/callable-lipsync/main/files/demo.gif" width="720" />
19
+ </p>
20
+
21
+ <details>
22
+ <summary>Demo with sound</summary>
23
+
24
+ [files/demo.mp4](https://github.com/callabledev/callable-lipsync/blob/main/files/demo.mp4)
25
+
26
+ A recorded two-person conversation. The avatar voices one speaker and listens to the other. Both faces are drawn from the same frames of the `tiny` model: a FLAME 2023 Open head, and a 2D face driven by ARKit blendshape weights.
27
+
28
+ </details>
29
+
30
+ <br/>
31
+
32
+ <h2 align="center">Fast start</h2>
33
+ <br/>
34
+
35
+ <details>
36
+ <summary>Dependencies</summary>
37
+
38
+ Python:
39
+
40
+ - `python 3.9+`;
41
+ - `onnxruntime>=1.17` and `numpy` (installed with the package);
42
+ - no GPU, no PyTorch.
43
+
44
+ JavaScript:
45
+
46
+ - `onnxruntime-web>=1.17` (a peer dependency);
47
+ - any current browser, or Node 18+.
48
+
49
+ The model files ship inside both packages (about 21 MB for the two models and the ARKit converter's data together). Nothing is downloaded at run time.
50
+
51
+ </details>
52
+
53
+ **Using pip**:
54
+ `pip install callable-lipsync`
55
+
56
+ ```python3
57
+ from callable_lipsync import LipSync
58
+
59
+ model = LipSync("tiny") # or "nano"
60
+ for chunk in audio_stream: # float32, 16 kHz mono, any chunk size
61
+ frames = model(chunk) # (n, 118): the frames this audio settled, 25 per second
62
+ ```
63
+
64
+ A whole clip at once:
65
+
66
+ ```python3
67
+ from callable_lipsync import animate
68
+
69
+ frames = animate(wav, model="tiny") # (len(wav) // 640, 118)
70
+ ```
71
+
72
+ **Using npm**:
73
+ `npm install callable-lipsync onnxruntime-web`
74
+
75
+ ```js
76
+ import * as ort from 'onnxruntime-web';
77
+ import { LipSync } from 'callable-lipsync';
78
+
79
+ // in a browser: serve node_modules/callable-lipsync/models/ and point `base` at it; in Node, leave `base` out
80
+ const model = await LipSync.load(ort, { model: 'tiny', base: '/models/tiny/' });
81
+ const frames = await model.process(samples); // Float32Array, 16 kHz mono -> [Float32Array(118), ...]
82
+ ```
83
+
84
+ Python and JavaScript run the same engine: the same audio and seed give the same frames in both.
85
+
86
+ <br/>
87
+
88
+ <h2 align="center">Key Features</h2>
89
+ <br/>
90
+
91
+ - **Tiny**
92
+
93
+ Two sizes. `tiny` is 17.1M parameters and a 17.7 MB download. `nano` is 2.4M parameters and 2.5 MB.
94
+
95
+ - **Fast**
96
+
97
+ One 40 ms frame takes about **1 ms** on a single CPU thread in Python and about **6 ms** in WebAssembly in a browser (`tiny`). `nano` takes 0.4 ms and 2 ms.
98
+
99
+ - **The whole face, not only the lips**
100
+
101
+ `tiny` gives lips, jaw, cheeks and brows, blinks, gaze, head and neck rotation and a little upper-body sway. `nano` gives lips, jaw, face and head rotation.
102
+
103
+ - **Streaming**
104
+
105
+ Feed it audio in chunks of any size as it arrives. It keeps its own state and costs the same per frame however long the stream runs.
106
+
107
+ - **Works with any amount of audio ahead**
108
+
109
+ A text-to-speech engine usually has audio ready slightly before it is heard, and the model uses that to make the head move with the words. With a live microphone it has none, and it still works: tell it how much it gets (0 to 0.64 s), the same weights handle all of it.
110
+
111
+ - **FLAME and ARKit output**
112
+
113
+ Frames are [FLAME 2023 Open](https://flame.is.tue.mpg.de/) parameters. For avatars rigged with ARKit blendshapes, a converter in both packages turns each frame into the 51 ARKit weights (see [Output](#output)).
114
+
115
+ - **No Strings Attached**
116
+
117
+ Published under a permissive license (Apache 2.0). No telemetry, no keys, no registration, no server: the model runs where your code runs.
118
+
119
+ <br/>
120
+
121
+ <h2 align="center">Benchmarks</h2>
122
+ <br/>
123
+
124
+ <!-- benchmarks:start (generated by the research repo's compare/summary.py) -->
125
+ <p align="center">
126
+ <picture>
127
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/callabledev/callable-lipsync/main/files/benchmarks-dark.svg">
128
+ <img alt="Benchmark summary: callable-lipsync tiny and nano against 13 other speech-to-face models on seven measures" src="https://raw.githubusercontent.com/callabledev/callable-lipsync/main/files/benchmarks-light.svg" width="100%">
129
+ </picture>
130
+ </p>
131
+
132
+ Each column is colored by rank among the models: blue is better, red is worse, and **bold** marks the best few.
133
+
134
+ - On speech from people it has never heard (Multiface), `tiny` has the best overall score and exact timing, and it has the lowest lip error on Callable held-out.
135
+ - Since 0.2.0 both models close the lips on p, b and m as often as real speakers do (93% and 91%; real 92%), up from 75% and 45% in 0.1.0.
136
+ - Lip reading is where they still trail: the larger SelfTalk, UniTalker and ARTalk read better.
137
+ - On VOCASET's own test the models trained on VOCASET win clearly, as expected.
138
+
139
+ <details>
140
+ <summary>The table as text, and how it was measured</summary>
141
+
142
+ | Model | Size | Audio ahead | Runs on | Head | Multiface score | Lip error, Callable held-out (mm) | Lip error, VOCASET (×10⁻⁵ m²) | Timing on Multiface (ms) | Lips close on p/b/m (real 92%) | SyncNet confidence | Lip-reading error |
143
+ |---|---|---|---|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
144
+ | *Real speech* | | | | | *0.00* | *0.0* | *0.0* | *0* | *92%* | – | – |
145
+ | **callable-lipsync tiny** | 17.1M | 0.16 s lips / 0.64 s head | 1 CPU thread | ✓ | **0.67** | **7.4** | 6.1 | **0** | **93%** | 6.07 | 72% |
146
+ | **callable-lipsync nano** | 2.4M | 0.16 s | 1 CPU thread | ✓ | **0.69** | **7.7** | 6.3 | **0** | 91% | **6.13** | 74% |
147
+ | UniTalker-B | 96M | whole clip | GPU | | **0.81** | 9.5 | **1.4** | −28 | 81% | 5.76 | **67%** |
148
+ | ARTalk | 490M | 4 s windows | GPU | ✓ | 0.87 | **8.1** | 7.6 | +12 | 89% | 5.44 | **69%** |
149
+ | NVIDIA Audio2Face-3D v3.0 † | 181M | 0.75 s | GPU | | 1.00 | 13.3 | 12.1 | −24 | **96%** | 2.13 | 80% |
150
+ | EmoTalk | 641M | whole clip | GPU | | 1.00 | 8.2 | 4.1 | −16 | 0% | 2.56 | 85% |
151
+ | NVIDIA Audio2Face-3D v2.3 † | 18M | 0.26 s | GPU | | 1.00 | 8.9 | 5.3 | **0** | **98%** | 4.53 | 78% |
152
+ | SelfTalk | 769M | whole clip | GPU | | 1.11 | 9.0 | **2.6** | −80 | 90% | **6.10** | **52%** |
153
+ | CodeTalker | 319M | whole clip | GPU | | 1.17 | 9.3 | **3.2** | −84 | 68% | **6.08** | 69% |
154
+ | HeadAudio | 3.6K | none | browser | | 1.26 | 9.4 | 5.6 | +132 | 47% | 1.68 | 80% |
155
+ | LAM-A2E | 102M | whole clip | GPU | | 1.30 | 9.2 | 3.9 | −80 | 18% | 3.77 | 78% |
156
+ | SAiD | 101M | whole clip | GPU | | 1.30 | 10.0 | 4.9 | −80 | 83% | 3.36 | 79% |
157
+ | DiffPoseTalk | 129M | whole clip | GPU | ✓ | 1.57 | 11.0 | 17.2 | −96 | 38% | 5.68 | 71% |
158
+ | wawa-lipsync | rules | none | browser | | 1.98 | 11.2 | 12.9 | +240 | 14% | 1.32 | 79% |
159
+ | DualTalk | 647M | whole clip | GPU | ✓ | 2.07 | 11.9 | 15.5 | −64 | 14% | 4.51 | 74% |
160
+ | *Still face* | | | | | *1.00* | – | – | – | *0%* | *0.68* | *77%* |
161
+
162
+ - Every model ran with its public weights and its default settings. Each output is turned into the motion of the same FLAME face and compared with the real speaker.
163
+ - Multiface (612 sentences, 10 people) is the neutral set: none of these models was trained on it. Callable held-out is held-out clips of Callable's proprietary dataset, recorded like our training data, so it favours our models. VOCASET is the field's standard test, and favours the models trained on it (UniTalker, CodeTalker, SelfTalk).
164
+ - † Audio2Face is measured on its own face for the Multiface columns. Models with ARKit output (Audio2Face, LAM-A2E, EmoTalk, SAiD) are otherwise shown through one ARKit rig on FLAME, which may cost them some lip closures.
165
+ - SyncNet and lip reading run on grey renders of the face. Their numbers are relative: the real speaker's render reads far better than any model.
166
+ - Size is the parameter count, audio encoder included. Audio ahead is how much audio after a frame the model uses to make it; "whole clip" models need the whole recording first. tiny's lips use 0.16 s and its head 0.64 s; it also runs with less (0 to 0.64 s, your choice).
167
+ - Speed is not compared: ours run on one CPU thread, the others on a GPU.
168
+
169
+ </details>
170
+ <!-- benchmarks:end -->
171
+
172
+ <br/>
173
+
174
+ <h2 align="center">Models</h2>
175
+ <br/>
176
+
177
+ | | tiny | nano |
178
+ |---|:---:|:---:|
179
+ | Lips and jaw | ✅ | ✅ |
180
+ | Cheeks, brows, rest of the face | ✅ | ✅ |
181
+ | Head rotation | ✅ | ✅ |
182
+ | Blinks | ✅ | ❌ |
183
+ | Gaze | ✅ | ❌ |
184
+ | Neck separate from the chest | ✅ | ❌ |
185
+ | Upper-body sway | ✅ | ❌ |
186
+ | Works with no audio ahead (live microphone) | ✅ | ❌ |
187
+ | Head motion planned on up to 0.64 s of audio ahead | ✅ | ❌ |
188
+ | New head and eye motion on every run | ✅ | ❌ |
189
+ | Streaming, any chunk size | ✅ | ✅ |
190
+ | ARKit blendshape weights | ✅ | ✅ |
191
+ | Python and JavaScript | ✅ | ✅ |
192
+ | Parameters | 17.1M | 2.4M |
193
+ | Size (ONNX, 8-bit weights) | 17.7 MB | 2.5 MB |
194
+ | Audio ahead | 0 to 0.64 s, your choice | 0.16 s, fixed |
195
+ | Python, one thread | 1.1 ms a frame | 0.4 ms a frame |
196
+ | Browser (WebAssembly), one thread | 5.9 ms a frame | 2.2 ms a frame |
197
+
198
+ Measured on an AMD Ryzen 7 9700X; a frame is 40 ms of audio. `tiny` at 0.64 s of audio ahead.
199
+
200
+ How much audio `tiny` gets ahead of each frame decides how well the head follows the speech:
201
+
202
+ | Audio ahead | Lips | Head, eyes, body |
203
+ |---|---|---|
204
+ | 0.64 s | full | turns and nods land on the speech (the reference) |
205
+ | 0.32 s | full | nods about 75% of that, turns about 55% |
206
+ | 0.16 s | full | nods about 40%; turns no longer follow the speech |
207
+ | none | lip error about 30% higher | natural motion, not timed to the speech |
208
+
209
+ ```python3
210
+ model = LipSync("tiny", ahead=0.16) # 0.64, 0.48, 0.32, 0.16, 0.08 or 0
211
+ ```
212
+
213
+ <br/>
214
+
215
+ <h2 align="center">Output</h2>
216
+ <br/>
217
+
218
+ 25 frames a second, 118 numbers each. Rotations are axis-angle, in radians.
219
+
220
+ | Numbers | What |
221
+ |---|---|
222
+ | 0..99 | FLAME 2023 Open expression |
223
+ | 100..102 | chest rotation |
224
+ | 103..105 | jaw |
225
+ | 106..108 | neck |
226
+ | 109..114 | left and right eye |
227
+ | 115..117 | travel of the upper body, metres |
228
+
229
+ `nano` fills expression, jaw and neck and leaves the rest at zero. In Python, `callable_lipsync.LAYOUT` has these as slices.
230
+
231
+ **ARKit blendshapes**
232
+
233
+ If your avatar is rigged with ARKit blendshapes (as most game-engine and phone-tracked faces are), convert the frames to the 51 ARKit weights, 0 to 1 each: `jawOpen`, `mouthFunnel`, `mouthSmileLeft`, `eyeBlinkLeft`, `browInnerUp` and the rest. The converter is in both packages and gives the same weights in both.
234
+
235
+ ```python3
236
+ from callable_lipsync import LipSync, Arkit
237
+
238
+ model, arkit = LipSync("tiny"), Arkit("tiny")
239
+ weights = arkit(model(chunk)) # (n, 51), in the order of arkit.names
240
+ ```
241
+
242
+ ```js
243
+ import { LipSync, Arkit } from 'callable-lipsync';
244
+
245
+ const arkit = await Arkit.load({ model: 'tiny', base: '/models/arkit/' }); // in Node, leave `base` out
246
+ for (const frame of await model.process(samples)) {
247
+ const weights = arkit.convert(frame); // Float32Array(51), in the order of arkit.names
248
+ }
249
+ ```
250
+
251
+ It takes about 0.2 ms a frame. `jawOpen` and the eight `eyeLook` weights come straight from the jaw's and the eyes' rotation; the others are solved from the face's shape. The head, neck and chest rotations and the travel are not blendshapes: apply them to your rig's bones from the frame itself. It is an approximation: ARKit's 51 shapes reproduce about three quarters of `tiny`'s face motion, so treat the weights as a starting point.
252
+
253
+ <br/>
254
+
255
+ <h2 align="center">Typical Use Cases</h2>
256
+ <br/>
257
+
258
+ - Faces for voice agents and voice bots, driven by the text-to-speech audio
259
+ - Avatars in games, apps and video calls, driven by a live microphone
260
+ - Lip sync for characters in the browser with no server and no GPU
261
+ - Batch animation of recorded speech
262
+
263
+ <br/>
264
+ <h2 align="center">Roadmap</h2>
265
+ <br/>
266
+
267
+ **Done**
268
+
269
+ - ✅ `tiny` and `nano` models, streaming, with a choice of lookahead
270
+ - ✅ Python package (`pip install callable-lipsync`)
271
+ - ✅ JavaScript package (`npm install callable-lipsync`), for browsers and Node
272
+ - ✅ FLAME 2023 Open output
273
+ - ✅ ARKit blendshape converter in both packages
274
+ - ✅ Browser demo
275
+ - ✅ Benchmarks against 13 other speech-to-face models
276
+
277
+ **Planned**
278
+
279
+ - ⬜ Unreal Engine MetaHuman support
280
+ - ⬜ VRM model support
281
+ - ⬜ Unity support
282
+
283
+ <br/>
284
+ <h2 align="center">Links</h2>
285
+ <br/>
286
+
287
+ - [Live demo](https://research.callable.com.ai/lipsync/), and its [source](https://github.com/callabledev/callable-lipsync/tree/main/examples/browser): both models on a recorded conversation, a 3D head and a 2D face
288
+ - The ARKit converter [in JavaScript](https://github.com/callabledev/callable-lipsync/blob/main/js/arkit.js) and [in Python](https://github.com/callabledev/callable-lipsync/blob/main/src/callable_lipsync/arkit.py)
289
+ - [Python example](https://github.com/callabledev/callable-lipsync/blob/main/examples/python/wav_to_frames.py) and [Node example](https://github.com/callabledev/callable-lipsync/blob/main/examples/node/wav_to_frames.mjs)
290
+ - [The engine in JavaScript](https://github.com/callabledev/callable-lipsync/blob/main/js/engine.js) and [in Python](https://github.com/callabledev/callable-lipsync/blob/main/src/callable_lipsync/engine.py)
291
+ - [Callable](https://callable.com.ai)
292
+
293
+ <br/>
294
+ <h2 align="center">Get In Touch</h2>
295
+ <br/>
296
+
297
+ Try the models, create an [issue](https://github.com/callabledev/callable-lipsync/issues/new), or [email](mailto:support@callable.com.ai) us. More about what we build at [callable.com.ai](https://callable.com.ai).
298
+
299
+ **Limitations**
300
+
301
+ - One speaker at a time. Feed it a mix of two voices and it will lip-sync both.
302
+ - Measured mostly on English. It listens to sound, not text, so other languages work, but we have not measured how well.
303
+ - No tongue and no teeth in the output.
304
+ - Input is 16 kHz mono. Resample other audio first.
305
+
306
+ **Model card**
307
+
308
+ | | |
309
+ |---|---|
310
+ | Model | callable-lipsync tiny and nano, by Callable |
311
+ | License | [Apache 2.0](https://github.com/callabledev/callable-lipsync/blob/main/LICENSE) (weights and code) |
312
+ | Training data | Callable's proprietary dataset |
313
+
314
+ **Citations**
315
+
316
+ ```
317
+ @misc{callable-lipsync,
318
+ author = {Callable},
319
+ title = {callable-lipsync: a tiny streaming speech-to-face model},
320
+ year = {2026},
321
+ publisher = {GitHub},
322
+ journal = {GitHub repository},
323
+ howpublished = {\url{https://github.com/callabledev/callable-lipsync}},
324
+ email = {support@callable.com.ai}
325
+ }
326
+ ```
327
+
328
+ <br/>
329
+ <h2 align="center">Third-party material</h2>
330
+ <br/>
331
+
332
+ The browser demo uses the [FLAME 2023 Open](https://flame.is.tue.mpg.de/) head model (CC BY 4.0), conversations from [DailyTalkContiguous](https://huggingface.co/datasets/kyutai/DailyTalkContiguous) (CC BY-SA 4.0, unmodified), [ONNX Runtime Web](https://onnxruntime.ai/) and [three.js](https://threejs.org/). The demo video uses the same head model and one of those conversations.
package/js/arkit.js ADDED
@@ -0,0 +1,81 @@
1
+ // Frames as ARKit blendshape weights.
2
+ //
3
+ // import { LipSync, Arkit } from 'callable-lipsync';
4
+ // const arkit = await Arkit.load({ model: 'tiny', base: '/models/arkit/' }); // in Node, leave `base` out
5
+ // const weights = arkit.convert(frame); // Float32Array(51), each 0..1, in the order of arkit.names
6
+ //
7
+ // The 51 ARKit shapes are displacements of the FLAME head's vertices, so a frame's weights are the mix of them closest
8
+ // to how far the frame's face is from the model's resting face. jawOpen comes straight from the jaw's rotation and the
9
+ // eight eyeLook weights from the eyes'; the rest are solved from the face's shape (exactly: the problem has one answer,
10
+ // so the Python package gives the same weights). The head, neck and chest rotations and the travel are not
11
+ // blendshapes: apply those to your rig's bones from the frame itself.
12
+ const LOOK = ['eyeLookDownLeft', 'eyeLookDownRight', 'eyeLookInLeft', 'eyeLookInRight', 'eyeLookOutLeft', 'eyeLookOutRight', 'eyeLookUpLeft', 'eyeLookUpRight'];
13
+
14
+ function rotation(x, y, z, R) { // axis-angle -> row-major 3x3
15
+ const t = Math.hypot(x, y, z); if (t < 1e-9) { R[0] = 1; R[1] = -z; R[2] = y; R[3] = z; R[4] = 1; R[5] = -x; R[6] = -y; R[7] = x; R[8] = 1; return R; }
16
+ const kx = x / t, ky = y / t, kz = z / t, c = Math.cos(t), s = Math.sin(t), v = 1 - c;
17
+ R[0] = c + kx * kx * v; R[1] = kx * ky * v - kz * s; R[2] = kx * kz * v + ky * s; R[3] = ky * kx * v + kz * s; R[4] = c + ky * ky * v; R[5] = ky * kz * v - kx * s; R[6] = kz * kx * v - ky * s; R[7] = kz * ky * v + kx * s; R[8] = c + kz * kz * v; return R;
18
+ }
19
+
20
+ export class Arkit {
21
+ // options: model 'tiny' or 'nano' (whose resting face the weights are measured from) or rest (your own frame of 118);
22
+ // base: URL of the folder with arkit.json and arkit.bin (browser); load: your own (name) => ArrayBuffer;
23
+ // jaw: the jaw rotation, in radians past rest, that counts as jawOpen = 1; lookRange: the same for the eyeLook weights
24
+ static async load({ model = 'tiny', base = null, load = null, ...options } = {}) {
25
+ if (!load) { const { loader } = await import('./index.js'); load = await loader('arkit', base); }
26
+ const meta = JSON.parse(new TextDecoder().decode(await load('arkit.json'))); return new Arkit(meta, await load('arkit.bin'), { model, ...options });
27
+ }
28
+ constructor(meta, buf, { model = 'tiny', rest = null, jaw = 0.35, lookRange = 0.5, ridge = 0.01 } = {}) {
29
+ const d = {}; for (const [k, a] of Object.entries(meta.arrays)) { const n = a.shape.reduce((x, y) => x * y, 1); d[k] = a.dtype === 'uint32' ? new Uint32Array(buf, a.offset, n) : Float64Array.from(new Float32Array(buf, a.offset, n)); }
30
+ Object.assign(this, d); this.names = meta.names; this.index = Object.fromEntries(this.names.map((n, i) => [n, i])); this.U = meta.vertices; this.nS = meta.skin; this.P = meta.points; this.jaw = jaw; this.lookRange = lookRange;
31
+ this.rest = Float64Array.from(rest || meta.rest[model]); const K = this.K = this.names.length, n = this.n = 3 * (this.nS + this.P), jo = this.index.jawOpen;
32
+ this.v = new Float64Array(this.U * 3); this.R = new Float64Array(9); this.restPoints = this.points(this.rest, new Float64Array(n));
33
+ const A = this.A = Float64Array.from(this.shapes), step = Float64Array.from(this.rest); step[103] += 0.05; const p = this.points(step, new Float64Array(n)); // jawOpen is the jaw's own rotation: the direction it starts in, from rest
34
+ for (let k = 0; k < n; k++) A[jo * n + k] = (p[k] - this.restPoints[k]) * jaw / 0.05;
35
+ const free = this.free = []; this.names.forEach((x, i) => { if (!LOOK.includes(x) && i !== jo) free.push(i); }); const m = this.m = free.length, H = this.H = new Float64Array(m * m); let tr = 0;
36
+ for (let a = 0; a < K; a++) { let s = 0; for (let k = 0; k < n; k++) s += A[a * n + k] * A[a * n + k]; tr += s; }
37
+ for (let a = 0; a < m; a++) for (let b = a; b < m; b++) { let s = 0; const X = free[a] * n, Y = free[b] * n; for (let k = 0; k < n; k++) s += A[X + k] * A[Y + k]; H[a * m + b] = H[b * m + a] = s; }
38
+ const lam = ridge * tr / K; for (let a = 0; a < m; a++) H[a * m + a] += lam;
39
+ this.d = new Float64Array(n); this.b = new Float64Array(m); this.w = new Float64Array(m); this.z = new Float64Array(m); this.lo = new Uint8Array(m).fill(1); this.hi = new Uint8Array(m); this.L = new Float64Array(m * m); this.rhs = new Float64Array(m); this.out = new Float32Array(K);
40
+ }
41
+ points(f, out) { // a frame -> the compared points in the head's frame: the skin vertices, then the control points (weighted)
42
+ const U = this.U, v = this.v, E = this.expr, R = rotation(f[103], f[104], f[105], this.R), T = this.template, PD = this.jaw_dirs, JE = this.jaw_joint_expr, n3 = U * 3; v.set(T); let jx = this.jaw_joint[0], jy = this.jaw_joint[1], jz = this.jaw_joint[2];
43
+ for (let i = 0; i < 100; i++) { const c = f[i]; if (c === 0) continue; const o = i * n3; for (let k = 0; k < n3; k++) v[k] += c * E[o + k]; jx += c * JE[3 * i]; jy += c * JE[3 * i + 1]; jz += c * JE[3 * i + 2]; }
44
+ for (let p = 0; p < 9; p++) { const c = R[p] - (p % 4 === 0 ? 1 : 0); if (c === 0) continue; const o = p * n3; for (let k = 0; k < n3; k++) v[k] += c * PD[o + k]; }
45
+ for (let u = 0; u < U; u++) { const w = this.jaw_weight[u]; if (w === 0) continue; const x = v[3 * u] - jx, y = v[3 * u + 1] - jy, z = v[3 * u + 2] - jz; v[3 * u] += w * (R[0] * x + R[1] * y + R[2] * z - x); v[3 * u + 1] += w * (R[3] * x + R[4] * y + R[5] * z - y); v[3 * u + 2] += w * (R[6] * x + R[7] * y + R[8] * z - z); }
46
+ const nS = this.nS, S = this.skin, C = this.corners, B = this.bary, W = this.point_weight;
47
+ for (let i = 0; i < nS; i++) for (let c = 0; c < 3; c++) out[3 * i + c] = v[3 * S[i] + c];
48
+ for (let i = 0; i < this.P; i++) for (let c = 0; c < 3; c++) out[3 * (nS + i) + c] = W[i] * (B[3 * i] * v[3 * C[3 * i] + c] + B[3 * i + 1] * v[3 * C[3 * i + 1] + c] + B[3 * i + 2] * v[3 * C[3 * i + 2] + c]);
49
+ return out;
50
+ }
51
+ box() { // the weights in 0..1 that minimise w.H.w / 2 - b.w, exactly (an active-set solve, started from where the last frame's ended; the answer does not depend on the start)
52
+ const { H, b, w, z, lo, hi, m, L, rhs } = this, tol = 1e-9, ix = []; for (let i = 0; i < m; i++) w[i] = hi[i] ? 1 : lo[i] ? 0 : w[i];
53
+ for (let it = 0; it < 20 * m; it++) {
54
+ for (;;) { // the best weights with the bound ones held; walk towards them until none leaves 0..1
55
+ ix.length = 0; for (let i = 0; i < m; i++) if (!lo[i] && !hi[i]) ix.push(i); const q = ix.length; if (!q) break;
56
+ for (let a = 0; a < q; a++) { let s = b[ix[a]]; for (let j = 0; j < m; j++) if (lo[j] || hi[j]) s -= H[ix[a] * m + j] * w[j]; rhs[a] = s; }
57
+ for (let a = 0; a < q; a++) for (let c = 0; c <= a; c++) { let s = H[ix[a] * m + ix[c]]; for (let k = 0; k < c; k++) s -= L[a * m + k] * L[c * m + k]; L[a * m + c] = a === c ? Math.sqrt(s) : s / L[c * m + c]; } // Cholesky
58
+ for (let a = 0; a < q; a++) { let s = rhs[a]; for (let k = 0; k < a; k++) s -= L[a * m + k] * rhs[k]; rhs[a] = s / L[a * m + a]; }
59
+ for (let a = q - 1; a >= 0; a--) { let s = rhs[a]; for (let k = a + 1; k < q; k++) s -= L[k * m + a] * rhs[k]; rhs[a] = s / L[a * m + a]; }
60
+ let step = Infinity, any = false; for (let a = 0; a < q; a++) { const i = ix[a], t = rhs[a]; z[i] = t; if (t < -tol) { any = true; step = Math.min(step, w[i] / Math.max(w[i] - t, 1e-300)); } else if (t > 1 + tol) { any = true; step = Math.min(step, (1 - w[i]) / Math.max(t - w[i], 1e-300)); } }
61
+ if (!any) { for (let a = 0; a < q; a++) w[ix[a]] = z[ix[a]]; break; }
62
+ step = Math.max(0, step);
63
+ for (let a = 0; a < q; a++) { const i = ix[a], t = z[i], s = t < -tol ? w[i] / Math.max(w[i] - t, 1e-300) : t > 1 + tol ? (1 - w[i]) / Math.max(t - w[i], 1e-300) : Infinity; w[i] += step * (t - w[i]); if (s <= step + 1e-12) { if (t < 0) { lo[i] = 1; w[i] = 0; } else { hi[i] = 1; w[i] = 1; } } }
64
+ }
65
+ let k = -1, worst = 1e-10; for (let i = 0; i < m; i++) { if (!lo[i] && !hi[i]) continue; let g = -b[i]; for (let j = 0; j < m; j++) g += H[i * m + j] * w[j]; const bad = lo[i] ? -g : g; if (bad > worst) { worst = bad; k = i; } } // a bound weight that would rather move inward
66
+ if (k < 0) break; lo[k] = hi[k] = 0;
67
+ }
68
+ return w;
69
+ }
70
+ // A frame (118 numbers) -> its 51 weights. The returned array is reused by the next call: copy it to keep it.
71
+ convert(f) {
72
+ const { n, A, d, b, free, m, out } = this, jo = this.index.jawOpen, r = this.restPoints, wj = Math.min(1, Math.max(0, (f[103] - this.rest[103]) / this.jaw)), X = jo * n; this.points(f, d);
73
+ for (let k = 0; k < n; k++) d[k] -= r[k] + wj * A[X + k]; // the jaw's turn is known; the other shapes explain what is left
74
+ for (let a = 0; a < m; a++) { let s = 0; const o = free[a] * n; for (let k = 0; k < n; k++) s += A[o + k] * d[k]; b[a] = s; }
75
+ const w = this.box(); out.fill(0); for (let a = 0; a < m; a++) out[free[a]] = Math.min(1, Math.max(0, w[a])); out[jo] = wj;
76
+ const R = this.lookRange, set = (name, x) => { out[this.index[name]] = Math.min(1, Math.max(0, x / R)); }; // +x is the face's left; turning about +x looks down, about +y towards the face's left
77
+ set('eyeLookDownLeft', f[109]); set('eyeLookUpLeft', -f[109]); set('eyeLookOutLeft', f[110]); set('eyeLookInLeft', -f[110]);
78
+ set('eyeLookDownRight', f[112]); set('eyeLookUpRight', -f[112]); set('eyeLookInRight', f[113]); set('eyeLookOutRight', -f[113]);
79
+ return out;
80
+ }
81
+ }