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.18.3-cp313-cp313-manylinux_2_28_x86_64.whl (16.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

bithuman-1.18.3-cp313-cp313-manylinux_2_28_aarch64.whl (15.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

bithuman-1.18.3-cp313-cp313-macosx_26_0_arm64.whl (25.3 MB view details)

Uploaded CPython 3.13macOS 26.0+ ARM64

bithuman-1.18.3-cp312-cp312-manylinux_2_28_x86_64.whl (16.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

bithuman-1.18.3-cp312-cp312-manylinux_2_28_aarch64.whl (15.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

bithuman-1.18.3-cp312-cp312-macosx_26_0_arm64.whl (25.3 MB view details)

Uploaded CPython 3.12macOS 26.0+ ARM64

bithuman-1.18.3-cp311-cp311-manylinux_2_28_x86_64.whl (16.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

bithuman-1.18.3-cp311-cp311-manylinux_2_28_aarch64.whl (15.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

bithuman-1.18.3-cp311-cp311-macosx_26_0_arm64.whl (25.3 MB view details)

Uploaded CPython 3.11macOS 26.0+ ARM64

bithuman-1.18.3-cp310-cp310-manylinux_2_28_x86_64.whl (16.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

bithuman-1.18.3-cp310-cp310-manylinux_2_28_aarch64.whl (15.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

bithuman-1.18.3-cp310-cp310-macosx_26_0_arm64.whl (25.3 MB view details)

Uploaded CPython 3.10macOS 26.0+ ARM64

bithuman-1.18.3-cp39-cp39-manylinux_2_28_x86_64.whl (16.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

bithuman-1.18.3-cp39-cp39-manylinux_2_28_aarch64.whl (15.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ ARM64

bithuman-1.18.3-cp39-cp39-macosx_26_0_arm64.whl (25.3 MB view details)

Uploaded CPython 3.9macOS 26.0+ ARM64

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 374d26a440bb1ababe914eb09d76f6c4e28d27a00144598413904df3f0c74d89
MD5 c26c3e0047b4f64a071fca6259ee6798
BLAKE2b-256 af847ca29eec8b258c6437f41f2875241af48bbfa8a0f75ad6fba2bd7b3a8a2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.3-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c2f383568584e40e3cdf830bbbb36e7c7f326a76c9b10a7db8b7df4697e03da7
MD5 15ee9815d15e74da6328ce99544e1c57
BLAKE2b-256 61baae6468d8548d40c91e3921e03d58398a2bc85afb3362dbf0b3627f4f2046

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.3-cp313-cp313-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 c580c6b119fa84b5c87d3332f8b6ed9256158f067911ecd068b359e0c6397971
MD5 49ea97dc8c3e0a3c7c0ce071274e98ad
BLAKE2b-256 8ac4b5087e739a659e70fe7319928afafd82402d16458a9e13c3a7cf5a9e7c70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d74d4cfb0964acf4ba540a3d125ebdd4afa07c9c61b06f5cb0f3d428f7a5a893
MD5 99ce9d0c9ef0ccaa2977a104776a61b3
BLAKE2b-256 b04639c53df6cffc69c6b941523c42c5b9ec442f8999b556421814df28e0da16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.3-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8443e9083fa11ee1d12a6bac8b25226996ee81e5fffef2419f7dc0f9b7a68021
MD5 f4110e224dd4dd98e1f31bc66bd3ad9a
BLAKE2b-256 859aac202148ddd5102457ce057aec62319530d23becd0c6fcf19a3f1de928c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.3-cp312-cp312-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 33aa200a8ba90b81b2a1f01df91abe5cd8f788fc6130003660a69cde9d55faa9
MD5 b0293cdf10987b789da4128929d5b2d5
BLAKE2b-256 0f890f50de0f0bc7ed3a50f4e573f9054d8ef7bef8a98181b6dc468214d692ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c048a00993468c6c34bf4252b318e6ff2b1fd1b6c6da7f4a7ae36ca4846952e8
MD5 a8c6189269feab3e99da53c570d38ff5
BLAKE2b-256 f51719f347b35e04d97e413496d73295fdf2b35285e816b3d72c9d0c9bd1ba49

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.3-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f25e681ddd1167fc527df32b369d44fb44c3573509d95e14dbdb60709a72407d
MD5 feb0dc247020a7540ecb420ffd7be1e1
BLAKE2b-256 57907abd966d9481a875fed0acee1dd49a5aa1418c2460ed3ca2aaab15502ee1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.3-cp311-cp311-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 b83ed6477afaab705ab7a1b30b2b2cffce005709cbf8359c45603c60e440482b
MD5 7752452fc6a542477f4ec496d9bd597c
BLAKE2b-256 5df22406370dc350da445e82a48dd2cd01724ec3c9589c9ac6dbb21d804d313d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 926a715974eea47213cf7d33b7cf3c2e35896acc3d252fd4b28598d0466e5dba
MD5 4dfdcaab31ea1505d03f15855f765e29
BLAKE2b-256 67ef77df1b405968073f600e04917afae34d94cfe6f241019b73008f0792cb57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.3-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 72ebc18f52e356256de5011c1c4c9f427792c965ba828c64652b4b9323580e85
MD5 c9e47f6dc0f76a36363f48859074186b
BLAKE2b-256 bcd4fbf0c3b38e0dcca2c1dea4defcd37de4f001129d6700ca5f36fe6f382446

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.3-cp310-cp310-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 480ceb877921546a5ed1972ac5538634a42ba3206c1da035eb09a4f6295d0cb5
MD5 4909529b140406279ee71fcae9c2ba38
BLAKE2b-256 a0e36cd10695c07e8c9a6ae59fade89ba6f5b85571b4300c53af89ccbc386241

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.3-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 38ca7d2702c2a8158dce0d146c79c531dc56bdd8105678bb1e7c867efc8fc0ef
MD5 b1c3690b60de3e56cec551b69fa19f39
BLAKE2b-256 ba9c99a69abd7c5b38eaeb37680b6890a9668d75b48abb3a644432e69f1342d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.3-cp39-cp39-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 72e0593f9022c12a6a1ca92a7389c7733f9a200d34fb246abcf179a839f5ac64
MD5 23218e3f4e2f965076dda23730257aed
BLAKE2b-256 4c8a735f4a171c180ad49b6d881a2fe08cb818ed7dfdc2aa3e6b4cc00152b63c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.3-cp39-cp39-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 7313aff493fa89907d176a2f2cfd539b8b6eea1939c5ef6eb52ceadb320e1ffb
MD5 c7979c09b55375007dca1ab7ca9c365a
BLAKE2b-256 6cfacb19f83fbe3f505efd27772a9c64e0cf9f2087131bfa8500c7006b92a09e

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