Skip to main content

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

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.5-cp314-cp314-manylinux_2_28_x86_64.whl (18.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

bithuman-1.18.5-cp314-cp314-manylinux_2_28_aarch64.whl (17.0 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

bithuman-1.18.5-cp314-cp314-macosx_26_0_arm64.whl (26.8 MB view details)

Uploaded CPython 3.14macOS 26.0+ ARM64

bithuman-1.18.5-cp313-cp313-manylinux_2_28_x86_64.whl (18.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

bithuman-1.18.5-cp313-cp313-manylinux_2_28_aarch64.whl (17.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

bithuman-1.18.5-cp313-cp313-macosx_26_0_arm64.whl (26.8 MB view details)

Uploaded CPython 3.13macOS 26.0+ ARM64

bithuman-1.18.5-cp312-cp312-manylinux_2_28_x86_64.whl (18.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

bithuman-1.18.5-cp312-cp312-manylinux_2_28_aarch64.whl (17.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

bithuman-1.18.5-cp312-cp312-macosx_26_0_arm64.whl (26.8 MB view details)

Uploaded CPython 3.12macOS 26.0+ ARM64

bithuman-1.18.5-cp311-cp311-manylinux_2_28_x86_64.whl (18.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

bithuman-1.18.5-cp311-cp311-manylinux_2_28_aarch64.whl (17.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

bithuman-1.18.5-cp311-cp311-macosx_26_0_arm64.whl (26.8 MB view details)

Uploaded CPython 3.11macOS 26.0+ ARM64

bithuman-1.18.5-cp310-cp310-manylinux_2_28_x86_64.whl (18.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

bithuman-1.18.5-cp310-cp310-manylinux_2_28_aarch64.whl (17.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

bithuman-1.18.5-cp310-cp310-macosx_26_0_arm64.whl (26.8 MB view details)

Uploaded CPython 3.10macOS 26.0+ ARM64

bithuman-1.18.5-cp39-cp39-manylinux_2_28_x86_64.whl (18.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

bithuman-1.18.5-cp39-cp39-manylinux_2_28_aarch64.whl (17.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ ARM64

bithuman-1.18.5-cp39-cp39-macosx_26_0_arm64.whl (26.8 MB view details)

Uploaded CPython 3.9macOS 26.0+ ARM64

File details

Details for the file bithuman-1.18.5-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bithuman-1.18.5-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 32affabe19c20e822041c84e2d963173820a4d8875edd94863fb10b25104ee59
MD5 158226ac9bcebf3fb34f9322ec0bf8c1
BLAKE2b-256 6b682d41bef28707026a13c33fb457d4a0254b49ed64db6ccd79628eced061e4

See more details on using hashes here.

File details

Details for the file bithuman-1.18.5-cp314-cp314-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for bithuman-1.18.5-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a4641d881a1cfdfd69a36bbc9c765ae54809fa5b71537c339804c95a3ec88b6a
MD5 214cb5c1b89f4a7f5dae9d959fefee7b
BLAKE2b-256 9785321f7fefa68f23c59904b4a4109263a2c5757327fbc075e78b47e77a109f

See more details on using hashes here.

File details

Details for the file bithuman-1.18.5-cp314-cp314-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for bithuman-1.18.5-cp314-cp314-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 14bee502b25b9056453affd28302b86cdd38ebfbd4c94d23d00ee91efeb4e49b
MD5 19638a8c4b3e89fab414736d91be2310
BLAKE2b-256 a47522604adb16a133576d664516cc4aad7f391d7a748362191d5d663756289c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.5-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5da5a91e40104443fce381640f8a093d5a4479d61208698127d57e2bec743b84
MD5 04b22855cdbc941d5277f25d0a468363
BLAKE2b-256 4fad3d62f858ab979a1ed7bc2a1a2d72f4f2b22a32b38173571b403ea4f2bfa5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.5-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fb1318a5d3b98acbb0452d4e8c074b1e88fb932817c74eeff219c23a443a83ec
MD5 121ac10c1edb93f3b051bdbea631ee05
BLAKE2b-256 ea74f5133a5e289e264b27cee5b4e450275d3dffe08d720368668474010284e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.5-cp313-cp313-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 d9acb0806d712892684fdea52045265b180a62f4627d6a30ffc8cd8708d3486e
MD5 d83777a5a93ea305af2b786f0afc749e
BLAKE2b-256 61acccfbc7c5a0b09f122257ac58b174f3ef805798098df2fa5cbf805f644eb7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.5-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 547eb6a577850c20fd1f2c17538e5309986311760ce0cde10d19f77358d87d23
MD5 4cc59af496126485c0e4fc95c9dc4ded
BLAKE2b-256 4d308db5e2f155c402cd56919e8c21f0762774e4215fd20f9a1d64f40dd67f6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.5-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5922083419e9445e3ef31f076634cf2c6d06efd0a999c7e0ee787d23a3ac29bd
MD5 dc9acdc4408ee81c4fce224fc547fbe7
BLAKE2b-256 1fa11f6c549c77ff46e9f6c04d79d8b0c479ab8d8afbbda9c5c4a35b1a5b97f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.5-cp312-cp312-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 6cbd0cc838b37c8875592a7a3e7c79a74b25d3cad9696ba9a10451000f949876
MD5 7ceeb34bf3664d7fd95b18299ff23782
BLAKE2b-256 efd74530d3128fb43093d36a0cbffd337fb5ef08117cdf3f76534fc2f1f1c582

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.5-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 34e795fb92314bdd356d9c05a34f821e011bf07d13e6f73bded2941819d55ad7
MD5 1153f9a0926d237bbd14c5396e322a45
BLAKE2b-256 ddae17c2a81046426396fee95dcfb3273ab4bd44548280090374c589dbd0a875

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.5-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 937b3d2546a38dc758b42955fd1eb2a7ff27d1dd1b7661d8e6675cfd8e7ac10e
MD5 315dbf1cc9eb638b21a7bc9ee00b31fe
BLAKE2b-256 e97502f8eac2e2781aaa6a34df31d1c409e5cb15911a084697d832691237d536

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.5-cp311-cp311-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 ca7b2e04212700111a241c4d9aa5817bee0025354e47321e1bc2d03eea8bb9c5
MD5 c0cc6063fc910f97627611dde9bd46d8
BLAKE2b-256 894429d1e30b2a3c9c60c76449391fa48cc8b2ceacfd9b6a4ba609fa06bc840d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.5-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 968b72c62f611f9f1dea492e5514ff6420ece9b6a01482e8cc4ca6169ec9cfad
MD5 302542f1945bc6cea41d51bff735b10d
BLAKE2b-256 5eca37d046bff2dabcbd9632ffae7698c78d6eade56d11ea010c17aad060b21d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.5-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0279ac69ec20e3ec69a72d25de0b4a6a30bd71ec1d35a19f338033ecb84c2d33
MD5 f03c05a47ace771179eb5b67c0d596d3
BLAKE2b-256 f83da7fa92217a3d3f5be8a55136a9e577cac9c71e2d388164472090d969087e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.5-cp310-cp310-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 e086a8a3f5216b375bbbefb775323d633471df6136ca9d656cc051255519d871
MD5 f213e5603559cf2f86d1bfde735ac2c0
BLAKE2b-256 2be8adae26ebc7c59ac824a9e30a29ed137cd3d0ba58feb6be6244f793f0661a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.5-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 99af5a5486222defe4b723f941e56475a48c93aa43ae7f7770c47cc1e4008681
MD5 33b692d68a703643c95e7dfe4821354f
BLAKE2b-256 c8d6e1328e38431ce45cd8559a5441181eaca147cfde2f8b78014d6336854a75

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.5-cp39-cp39-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 66e77e356b23d9a40e9db929ca80e25d0d781d660f71eb4e814497dea23e4d70
MD5 368cf9a380d901007473fc3af2b14a6f
BLAKE2b-256 8ebb326d488edb950bf5e4067251b2ba57d8327983c96e121b6727365a7fe5d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bithuman-1.18.5-cp39-cp39-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 4fdcc24685bc012c94ef64c01caed7b950a974b3aa9114020f3b69aa01efd956
MD5 e73c1b15817bbc29f093fbc3362c7695
BLAKE2b-256 57b9dd04581e8a2aed4c9bb0e3442c9ccdf70749a710e42a581ca2cbe3fac5c4

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