Skip to main content

Portable C++ avatar runtime — Python bindings via pybind11. Powers the bitHuman Essence pipeline cross-platform.

Reason this release was yanked:

bug identified

Project description

bithuman

This is the Python flavor of Layer 3: a platform-specific library for app developers. It wraps the Layer 1 libessence engine. For the CLI tool see docs/CLI.md.

┌─────────────────────────────────────────────────────────────┐
│ Layer 3: Platform-specific libraries (app developers)       │
│   - Python wheel       pip install bithuman    ◄──── you are here
│   - Swift package      SwiftPM Bithuman                     │
│   - Kotlin AAR         ai.bithuman:sdk                      │
│   - (future) Rust crate, JS/TS, Go, ...                     │
└─────────────────────────────────────────────────────────────┘
                          ▼ embeds
┌─────────────────────────────────────────────────────────────┐
│ Layer 2: bithuman CLI (end-user tool)                       │
│   - one cross-platform binary on macOS / Linux / Windows    │
│   - brew install bithuman · curl-pipe installer             │
└─────────────────────────────────────────────────────────────┘
                          ▼ links
┌─────────────────────────────────────────────────────────────┐
│ Layer 1: libessence engine (cross-platform C++ core)        │
│   - portable C ABI, same source on every target             │
│   - macOS · iOS · Android · Linux · Windows                 │
│   - never imported directly by app developers               │
└─────────────────────────────────────────────────────────────┘

Python bindings for the bitHuman SDK — the portable C++ avatar engine (libessence) that powers our cross-platform lipsync pipeline. The wheel ships a native pybind11 module that talks directly to libessence, so you get the same per-frame cost as our Swift and Kotlin clients with none of the GIL noise.

On an Apple M5 with 24 GB unified memory we measure ~640 FPS sustained compose (1.56 ms/frame mean, 2.03 ms p99) for a 1248×704 avatar, with ~206 MB peak RSS end-to-end. Cold load is ~14 ms for the fixture and ~400 ms for the first compose tick (lazy ONNX init).

This package is namespace-isolated from the v0 bithuman SDK; you can install both side-by-side.

Install

pip install bithuman

Status — Python wheel lags the rest of the SDK. The PyPI bithuman wheel is v1.12.4 (ABI v4), built from the legacy python/ tree at the root of bithuman-sdk. The new ABI-v6 streaming surface (be_runtime_push_audio / be_runtime_pull_frame / …) is C-level only in this binding tree until the Rust PyO3 wheel at cpp/bindings/rust/crates/bithuman-py ships to PyPI as the canonical replacement. Today's PyPI users keep the legacy AsyncBithuman.push_audio + async for ... in runtime.run() shape — see the legacy quickstart.

Compatibility

  • Platforms: macOS arm64, Linux x86_64, Linux arm64 — all ship as wheels. Windows is tracked for a follow-up.
  • Python: 3.10 – 3.13 (cp310, cp311, cp312, cp313). CPython only.
  • ABI: the published wheel wraps libessence ABI v4. The libessence engine itself is on ABI v6 — that surface is currently exposed via the Swift / Kotlin / Rust bindings only. PyO3 wheel migration in flight.
  • Auth: ships with live heartbeat against api.bithuman.ai baked into libessence. Avatar.load(api_secret=...) is the entry point; BITHUMAN_API_SECRET env var works too. Set BITHUMAN_UNMETERED=1 for dev / parity-test runs.

What you get

The package exposes three API tiers (all importable from bithuman):

Tier Types Use when…
Async AsyncAvatar, AudioChunk, VideoControl, VideoFrame Hosting a service / parity with legacy AsyncBithuman
Sync facade Avatar, ComposedFrame, EP Offline / batch / CLI rendering
Low-level Fixture, Runtime, EP_CPU/EP_AUTO/EP_COREML/EP_NNAPI/EP_QNN Direct C ABI access, custom audio pipeline

Error types: BithumanError (base), TokenError / TokenExpiredError / TokenValidationError / TokenRequestError / AccountStatusError (auth), ModelError / ModelNotFoundError / ModelLoadError / ModelSecurityError / ExpressionModelNotSupported (fixture), RuntimeNotReadyError.

Version info: bithuman.__version__ (Python package), bithuman.__core_version__ (linked libessence), bithuman.__abi_version__.

Quickstart (legacy AsyncBithuman — PyPI)

This is the shape of the current published wheel. It ports directly from the v0 bithuman SDK: feed PCM with push_audio, drain frames from the runtime.run() async generator.

import asyncio
from bithuman import AsyncBithuman

async def main():
    runtime = await AsyncBithuman(
        model_path="model.imx",
        api_secret="...",  # or BITHUMAN_API_SECRET env var
    ).start()

    await runtime.push_audio(pcm_16k_mono_int16_bytes,
                             sample_rate=16000, last_chunk=True)

    async for frame in runtime.run():
        # frame.bgr_image is (H, W, 3) uint8 in BGR order
        ...

asyncio.run(main())

PCM accepted is int16 little-endian bytes at 16 kHz mono. WAV / MP3 / FLAC / OGG decoding is the caller's responsibility (use soundfile).

Quickstart (low-level, C-level streaming surface)

The Rust PyO3 wheel will expose the ABI-v6 streaming pair (runtime.push_audio + runtime.pull_frame) on the same shape as the Swift / Kotlin bindings. Until it ships to PyPI, the snippet below uses the legacy Fixture / Runtime types in the published wheel.

CLI

A essence-render console script ships with the wheel:

pip install 'bithuman[cli]'

essence-render \
  --model ~/.cache/bithuman/models/sample-avatar.imx \
  --audio speech.wav \
  --output out.mp4

Pass --output - to stream raw BGR24 frames to stdout (handy for piping into a separate ffmpeg pipeline or a custom encoder). Other flags:

Flag Default Description
--fps 25 Output FPS for the MP4 container.
--quality 80 libx264 quality 1..100 (higher = better).
--ep cpu Execution provider hint (cpu/auto/coreml/…).
--threads 1 ORT intra-op thread count.
--no-audio Skip audio muxing; produce a silent video.

Example end-to-end run (5 s sine sweep):

essence-render 0.1.0: model=sample-avatar.imx audio=sine_sweep_5s.wav ep=cpu threads=1
essence-render: loaded fixture in 14.9 ms — 1248x704 @ 25 fps, 183 clusters, 202 src frames
essence-render: composed 122 frames in 1.83s (14.96 ms/frame, 66.8 fps)
essence-render: wrote /tmp/sine_sweep_5s.mp4

(Throughput here is bounded by H.264 encode, not Essence inference. Use --output - if you want to measure raw compose speed.)

Low-level API

If you need finer control or want to swap in a custom audio pipeline, the C ABI is exposed directly:

import numpy as np
from bithuman import Fixture, Runtime, EP_CPU

fx = Fixture("model.imx", preferred_ep=EP_CPU, intra_op_threads=1)
rt = Runtime(fx)
pcm = np.fromfile("speech.f32", dtype=np.float32)  # 16 kHz mono float32
cluster_idx, bgr = rt.tick_compose(pcm, frame_idx_hint=-1)
# bgr.shape == (fx.frame_height, fx.frame_width, 3), dtype uint8

Pass the entire pcm buffer to each tick_compose call; the runtime maintains an internal cursor and advances one tick per call until the audio is exhausted.

Zero-alloc hot path (since 1.12.4)

For tight render loops, pre-allocate the BGR buffer once and pass it via out=. The runtime writes into it in place and returns just the cluster_idx. This drops wrapper overhead to within ~3 % of raw libessence (vs ~8 % for the alloc-per-tick path):

out = np.empty((fx.frame_height, fx.frame_width, 3), dtype=np.uint8)
for _ in range(num_ticks):
    cluster_idx = rt.tick_compose(pcm, -1, out=out)
    # `out` now holds this tick's frame; read it before the next call.

The same out= keyword works on tick_compose_to_size. See docs/ARCHITECTURE.md §9 for the cross-wrapper perf table.

Build from source

You need the prebuilt parent C++ archive at cpp/build/libessence.a (run the parent CMake build first), plus the runtime deps from Homebrew (onnxruntime, webp, ffmpeg, hdf5, jpeg-turbo).

cd cpp/bindings/python
uv pip install -e '.[cli,test]' --no-build-isolation

The CMake glue links the prebuilt static archive directly — it does NOT re-run the parent build, so iterate on bindings without paying the C++ rebuild cost.

Performance

Measured with tests/bench.py against the v1 compose path (audio → composited BGR frame) on Apple M5 24 GB, libessence 1.16.0:

Metric Alloc per tick out= reuse buffer
Steady-state mean 1.53 ms / frame 1.45 ms / frame
p99 1.66 ms 1.53 ms
Sustained throughput 655 FPS 692 FPS
Overhead vs raw libessence +8.3 % +2.6 %
Peak RSS (proc) 192 MB 182 MB

Wrapper overhead is within 5 % of raw libessence on the out= path; see docs/ARCHITECTURE.md §9 for the apples-to-apples methodology and the cross-wrapper comparison. Reproduce with:

scripts/bench-wrappers.sh

Linux wheels

Pre-built manylinux_2_28 wheels ship for x86_64 + aarch64 across cp310 through cp313 — 8 wheels in total, all auditwheel-repaired with the full dep tree bundled (ORT, FFmpeg, HDF5, libjpeg-turbo, libwebp, libcurl, OpenSSL).

To rebuild them locally:

# One-time: build the dep-baked Docker images (~10 min each).
docker build --platform linux/amd64 -t libessence/manylinux-x86_64:0.1 \
    -f scripts/Dockerfile.manylinux-x86_64 scripts/
docker build --platform linux/arm64/v8 -t libessence/manylinux-aarch64:0.1 \
    -f scripts/Dockerfile.manylinux-aarch64 scripts/

# Per wheel build (~2 min):
docker run --rm --platform linux/amd64 -v "$REPO":/src \
    -e PYTAG=cp311 -e ARCH_INSIDE=x86_64 \
    libessence/manylinux-x86_64:0.1 \
    bash /src/cpp/bindings/python/scripts/build-wheel-in-container.sh

Limitations

  • Windows wheels not yet built — tracked for v0.2.
  • The CLI's output framerate is fixed at 25 fps to match the model's internal rate. Pass --output - and pipe to your own encoder if you need temporal resampling.
  • preferred_ep=COREML/NNAPI/QNN is accepted but currently no-ops to CPU in the v0.1 build.

License

Commercial. Contact hello@bithuman.ai.

See also

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

bithuman-1.17.5-cp313-cp313-manylinux_2_28_x86_64.whl (14.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

bithuman-1.17.5-cp313-cp313-manylinux_2_28_aarch64.whl (13.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

bithuman-1.17.5-cp313-cp313-macosx_26_0_arm64.whl (23.4 MB view details)

Uploaded CPython 3.13macOS 26.0+ ARM64

bithuman-1.17.5-cp312-cp312-manylinux_2_28_x86_64.whl (14.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

bithuman-1.17.5-cp312-cp312-manylinux_2_28_aarch64.whl (13.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

bithuman-1.17.5-cp312-cp312-macosx_26_0_arm64.whl (23.3 MB view details)

Uploaded CPython 3.12macOS 26.0+ ARM64

bithuman-1.17.5-cp311-cp311-manylinux_2_28_x86_64.whl (14.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

bithuman-1.17.5-cp311-cp311-manylinux_2_28_aarch64.whl (13.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

bithuman-1.17.5-cp311-cp311-macosx_26_0_arm64.whl (23.4 MB view details)

Uploaded CPython 3.11macOS 26.0+ ARM64

bithuman-1.17.5-cp310-cp310-manylinux_2_28_x86_64.whl (14.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

bithuman-1.17.5-cp310-cp310-manylinux_2_28_aarch64.whl (13.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

bithuman-1.17.5-cp310-cp310-macosx_26_0_arm64.whl (23.3 MB view details)

Uploaded CPython 3.10macOS 26.0+ ARM64

bithuman-1.17.5-cp39-cp39-manylinux_2_28_x86_64.whl (14.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

bithuman-1.17.5-cp39-cp39-manylinux_2_28_aarch64.whl (13.4 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ ARM64

bithuman-1.17.5-cp39-cp39-macosx_26_0_arm64.whl (23.3 MB view details)

Uploaded CPython 3.9macOS 26.0+ ARM64

File details

Details for the file bithuman-1.17.5-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bithuman-1.17.5-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b34843bbe3a935ea5f91d8be0d27980553b71c747a4ff9476dc4fc69ffe2e40d
MD5 b207fff232fa15f9a696bbc3afb52b8f
BLAKE2b-256 b66c87d6a83ed57a8b728e22243be0f25ce2fb80da1eaa485c9ab64c9ce06855

See more details on using hashes here.

File details

Details for the file bithuman-1.17.5-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for bithuman-1.17.5-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6f1800e9f8dc332c6fb50e8ef1a5449596655f5ed99028f388f9596dbb43c3f7
MD5 e554b4f93a4499bcdc5a41ee8cc57b04
BLAKE2b-256 17317b8bda1bfad0a02787f299c407f13fc4ab8e0803b3a35ca83612dae4e47f

See more details on using hashes here.

File details

Details for the file bithuman-1.17.5-cp313-cp313-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for bithuman-1.17.5-cp313-cp313-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 89b29834ff21f1405fee96cc81a78ff3bf8a6c1a83da88b657cce917551134b9
MD5 cde88751d1876616356a261e541acb5b
BLAKE2b-256 3509c8e631a75a3e87b2f41b0caf9085a7e0452a0519b1a149d010e40354ca94

See more details on using hashes here.

File details

Details for the file bithuman-1.17.5-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bithuman-1.17.5-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4cc877d7c880eee4e97b120205e2a9a0d1e50edfea50eda5890d3e38bed20908
MD5 56bc0f101b779531fd2e54faa95c7f02
BLAKE2b-256 e5a806561af63741d4c181184419be346940c9fe54f64c8a823e132132885c65

See more details on using hashes here.

File details

Details for the file bithuman-1.17.5-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for bithuman-1.17.5-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 633ec44cc4cebfc4e1be3d6651c8f86411494438e265fa90d9662e13a3523bf9
MD5 3a84faca8de93a12ec3abedd7ce2b91b
BLAKE2b-256 9804baef5e11ac06ce894001d204f47cb87b71aa2779c3a4ddf470c9c38e4009

See more details on using hashes here.

File details

Details for the file bithuman-1.17.5-cp312-cp312-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for bithuman-1.17.5-cp312-cp312-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 1de001f23dfcbd27158eee68f2247b0de27c7677db46066fe5a9552f7a8ee170
MD5 48da47b8ef076febf1241ae9638d20bc
BLAKE2b-256 195e8489b76a4903876369a9e37b4f66b0f57d60b3ce43807616e0178ed1d380

See more details on using hashes here.

File details

Details for the file bithuman-1.17.5-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bithuman-1.17.5-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1d789a9e22424a6e3f50ec76ca095250dd2a3a7e90a27a3ad62e52bacd0ffb8b
MD5 792deeceb250539b042eb07f9d359925
BLAKE2b-256 77a4040f79366f82ff54fa610472d0b831060dd236b1d5097e801a6fc7ec7503

See more details on using hashes here.

File details

Details for the file bithuman-1.17.5-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for bithuman-1.17.5-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a64decd3517095ea896e27378ffd656146b980e8f5d016ece0ba2f78c81f411b
MD5 da3baefa23fc6a6ec53965772594a0d2
BLAKE2b-256 39b9fbc8da7af30964096bf2526f7950feb0af9e71ab5f6c0e64b7dbc9b441c4

See more details on using hashes here.

File details

Details for the file bithuman-1.17.5-cp311-cp311-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for bithuman-1.17.5-cp311-cp311-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 468e106a8ac78a35260451d4cfb03a3124924ea2a22fe32af2bd5a7983db2f07
MD5 4c035193f4a5889d7a2073b1316f9bca
BLAKE2b-256 3228119a5161dd2cb8d9474a33e0967fbdc14c005d597a277698ac91428082a9

See more details on using hashes here.

File details

Details for the file bithuman-1.17.5-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bithuman-1.17.5-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 105144dacbe615cdda22b12c58d97d390bf25ba12d672ee058d817f015313af0
MD5 19abdaa8f3385917e6e1fd7934804409
BLAKE2b-256 cde807a6eb90119fe3d454c9d0c1b90e838f02ffb34ea6e3e7cdcf93918f0562

See more details on using hashes here.

File details

Details for the file bithuman-1.17.5-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for bithuman-1.17.5-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 eea7e6199b9f9b2b5bda22616fd4a4e97c39f8d2cb1c1174c814017faa013a08
MD5 ec431373a6e2160d5b33b5a5fdf21eee
BLAKE2b-256 931b9d56135a2fc70ddfd34ca18e45fc456485eb9e3abc709f674f463e1b7443

See more details on using hashes here.

File details

Details for the file bithuman-1.17.5-cp310-cp310-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for bithuman-1.17.5-cp310-cp310-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 e8d3082976a7baa0c156633af33dfe23da53cc1ebc8d2cbb64bc77dbae7f84e6
MD5 ae04a9a46e4d2d67b56e80bd256debfa
BLAKE2b-256 ee6d9a65dbb1bc45f7c2d3de28c135b814236176ac852f8e269b2eef7581dd4f

See more details on using hashes here.

File details

Details for the file bithuman-1.17.5-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bithuman-1.17.5-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 019ae8653065dcb815dbe86bd9f1a2bb6cc5ece6bd3554417a23186602ad11ff
MD5 703c1c3eb41260252bcd3a3236175d18
BLAKE2b-256 248396e71e7b644ecb376f68b826face7c428b369ea61fc29cc8ba7e80c716c9

See more details on using hashes here.

File details

Details for the file bithuman-1.17.5-cp39-cp39-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for bithuman-1.17.5-cp39-cp39-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9031fbfa6c6d4adcf7377dafb12331fa1852951feb2ef86ac8547ac9dcdc540d
MD5 bf75de7508092f76a91177c35f55f634
BLAKE2b-256 343cf9f5d80cd245cc4357c49fef959be1232b2bea45175d8ca5c7a58e972138

See more details on using hashes here.

File details

Details for the file bithuman-1.17.5-cp39-cp39-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for bithuman-1.17.5-cp39-cp39-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 5d53a01e81fbf79c37dec4860ae51f5b30f2a48e44ec3bad5babdd4e59dc434c
MD5 7121dfdf3ba46b6be3cea4f5f796ed63
BLAKE2b-256 028460a366ba127a57cd5d790eeef469db37de3e37bfdaa022d94a071e52cbfb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page