File size: 3,930 Bytes
4e02c98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e98ff03
4e02c98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e98ff03
4e02c98
 
e98ff03
4e02c98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
license: apache-2.0
language:
- ne
- en
tags:
- talking-head
- lip-sync
- audio-driven
- coreml
- tensorrt
- webgpu
- onnx
library_name: ampixa-talkinghead
pipeline_tag: image-to-video
---

# ampixa-talkinghead

One photo + a speech clip → a lip-synced talking-head video. Real time on Apple silicon (M4 Pro, M3 Pro) and
on an RTX 3050 Ti laptop GPU with TensorRT (40 ms/frame, just 25 fps); 168-169 MB per platform. Built and evaluated for **Nepali and English**.

<video controls src="https://huggingface.co/ampixa/talkinghead/resolve/main/demo/hero.mp4"></video>

Code: [github.com/Ampixa/talkinghead](https://github.com/Ampixa/talkinghead) · Try it in your browser: [ampixa.com/talkinghead](https://ampixa.com/talkinghead)

```bash
pip install "git+https://github.com/Ampixa/talkinghead.git"            # Apple silicon / CPU
pip install "ampixa-talkinghead[tensorrt] @ git+https://github.com/Ampixa/talkinghead.git"   # NVIDIA
```

```python
from ampixa_talkinghead import Avatar
Avatar("photo.jpg").speak("speech.wav", "out.mp4")
```

## Measured

| | |
|---|---|
| Render loop, Apple M4 Pro (Core ML) | 36.5 ms/frame (≈27 fps) |
| Render loop, Apple M3 Pro (Core ML) | 39.9 ms/frame (25 fps) |
| Render loop, RTX 3050 Ti laptop (TensorRT) | 40.0-40.5 ms/frame (25 fps; networks alone 25.7 ms) |
| Download per machine | 169 MB (Apple silicon), 168 MB (NVIDIA) |
| Peak memory | ~1.7 GB during `speak()` |
| Lip sync | close to Ditto, not equal: an earlier full-quality build scored SyncNet LSE-C 5.23 vs Ditto's 5.31 (15 Nepali + English cases); the real-time renderer shipped here scored 0.51 lower than Ditto on a 7-case gate. Details: [GitHub README](https://github.com/Ampixa/talkinghead#measured) |

## Files

| folder | what | used on |
|---|---|---|
| `common/` | face setup, audio and motion models | every platform |
| `coreml/` | real-time renderer | Apple silicon |
| `onnx/` | real-time renderer (TensorRT engines are built on first use) | NVIDIA |
| `realtime/` | real-time renderer, PyTorch | fallback |
| `full/` | full-quality renderer, PyTorch | offline / CPU |
| `web/` | every network as ONNX for onnxruntime-web (WebGPU) | the browser demo |

The library downloads only the folders your machine needs. `MANIFEST.json` lists every file with its sha256.

## In the browser

[ampixa.com/talkinghead](https://ampixa.com/talkinghead) runs the whole pipeline on the visitor's own GPU (WebGPU):
the models in `web/` download from this repo once, and nothing is uploaded. It is **not real time** in a browser:
about 245 ms per frame on an M4 Pro (a 10 s clip takes about a minute), because a browser cannot use the Neural Engine
that the native Core ML path uses. Lip sync matches the Python package (SyncNet LSE-C on the same inputs: 5.66 vs 5.44,
4.54 vs 4.63). Needs a recent Chrome or Edge (WebGPU, WebCodecs, JSPI).

## Demos

Paintings (public domain) with voices from [sanoTTS](https://huggingface.co/ampixa/sanoTTS); people from the
package's `examples/` speaking Nepali and English ([FLEURS](https://huggingface.co/datasets/google/fleurs), CC BY 4.0).

Photo credits (Wikimedia Commons): face04 Bibek Raut (CC BY-SA 4.0), face05 MaximusPrasad (CC BY-SA 4.0),
face06 Nithi Anand (CC BY 2.0), face13 Dr. Hans-Günter Wagner (CC BY-SA 2.0), face15 Jeremy Bishop (CC0).
Demo videos made from CC BY-SA photos are shared under CC BY-SA.

## Limits

- Works best with a frontal photo, mouth **closed** (visible teeth stop the mouth from closing while speaking).
- Weak on stylised paintings with heavy beards / brushwork, very small faces in full-body shots, and profiles.
- Do not use it to impersonate real people or to make anyone appear to say things they did not say.

## Licence

Apache-2.0. Derived from [Ditto](https://github.com/antgroup/ditto-talkinghead) (Apache-2.0) and LivePortrait /
S2G-MDDiffusion (MIT); see `NOTICE` in the code repository. The face crop uses MediaPipe (Apache-2.0).