Skip to main content

Inference for the OpenBEATs audio encoder (vendored ESPnet BeatsEncoder)

Project description

OpenBEATs

OpenBEATs is a general-purpose audio encoder pre-trained on speech, music, environmental sound, and bioacoustics. This package runs it on audio and returns patch-level embeddings, plus class probabilities when a fine-tuned checkpoint is used.

Install

pip install openbeats

This adds two commands, openbeats-infer and openbeats-download. The dependencies are kept light (torch, torchaudio, numpy, huggingface-hub, pyyaml, soundfile), and torch is pinned loosely so an existing build is not replaced. To avoid touching an existing environment, install it in its own with uv or pipx:

uv tool install openbeats     # or: pipx install openbeats

Usage

From the command line

Handy for a quick look:

openbeats-infer --checkpoint espnet/OpenBEATS-Large-i2-as20k \
    --audio audio.wav --out embeddings.npz

--checkpoint takes a Hugging Face repo id (downloaded automatically), a local directory, or a checkpoint file. The .npz holds patch_embeddings (num_patches, 1024), plus logits and probs when the checkpoint has a classifier. Other options: --device cuda, --max-layer N, and --chunk-seconds 10 for long recordings.

From Python

from openbeats.model import OpenBeats
from openbeats.utils import load_audio

# load model
model = OpenBeats.from_pretrained("espnet/OpenBEATS-Large-i2-as20k", device="cuda")

# from a file with any sample rate
out = model.encode_file("audio.wav")              # pass chunk_seconds=10 for long audio

# or load the waveform in 16khz monoaural array with values in [-1,1]
wav, sr = load_audio("audio.wav")
# and pass it
out = model.encode(wav, sr)

print(out["patch_embeddings"].shape)               # (num_patches, 1024)

Checkpoints

The variants (Base and Large, plus AudioSet and bioacoustics fine-tunes) live in the espnet OpenBEATs collection.

Development

uv sync                                  # install with dev deps (pytest)
uv run pytest                            # unit tests, no downloads
OPENBEATS_INTEGRATION=1 uv run pytest    # also run the end-to-end tests
uv build                                 # build wheel + sdist into dist/
uv publish                               # publish to PyPI

Project details


Download files

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

Source Distribution

openbeats-0.1.1.tar.gz (103.9 kB view details)

Uploaded Source

Built Distribution

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

openbeats-0.1.1-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file openbeats-0.1.1.tar.gz.

File metadata

  • Download URL: openbeats-0.1.1.tar.gz
  • Upload date:
  • Size: 103.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for openbeats-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a858b0028b5073bff8bcf522166bdfdc09be712ef2bef738d0977a3019035b94
MD5 effd25c02cb42d0e1684d0021b258dd6
BLAKE2b-256 b8a816382396036b32e93030c8a61ea977cb52bd06e42f40e8df89aad8462a97

See more details on using hashes here.

File details

Details for the file openbeats-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: openbeats-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for openbeats-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c0a99dc920eba7404d272d68a343d9c1885528d0b1d61248c16d0f0e9c99ef49
MD5 7565f9154517055d36919563013eb9c9
BLAKE2b-256 d30e539b2f250ede7f5a5038bc02026722868dd55a00a086afaba780c927f752

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