Skip to main content

Inference for the OpenBEATs audio encoder (vendored ESPnet BeatsEncoder)

Project description

OpenBEATs inference

Run inference with OpenBEATs, a general-purpose audio encoder pre-trained on speech, music, environmental sound, and bioacoustics (paper). Given an audio file, it produces patch-level embeddings.

Install

pip install openbeats

This installs the openbeats-infer / openbeats-download commands. Dependencies are kept lean (torch, torchaudio, numpy, huggingface-hub, pyyaml, soundfile) and declared with lower bounds, so an existing torch install is reused rather than reinstalled. For a fully isolated CLI that doesn't touch your environment, use uv tool or pipx:

uv tool install openbeats     # or: pipx install openbeats

Usage

CLI — quick prototyping

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

--checkpoint accepts a Hugging Face repo id (auto-downloaded), a local directory, or a checkpoint file. The .npz holds patch_embeddings (num_patches, 1024) (plus logits/probs for classification checkpoints). Options: --device cuda, --max-layer N, --chunk-seconds 10 (long audio).

Python — from an audio file

from openbeats.model import OpenBeats

model = OpenBeats.from_pretrained("espnet/OpenBEATS-Large-i1-as20k", device="cuda")
out = model.encode_file("your_audio.wav")          # or chunk_seconds=10 for long audio
print(out["patch_embeddings"].shape)               # (num_patches, 1024)

Python — from your own waveform

Pass a 1-D 16 kHz waveform in [-1, 1] (use load_audio for other rates):

import numpy as np
from openbeats.utils import load_audio

wav, sr = load_audio("your_audio.wav")             # any rate -> mono 16 kHz
out = model.encode(wav, sr)                         # or pass your own np.ndarray
print(out["patch_embeddings"].shape)               # (num_patches, 1024)

Checkpoints

Browse variants (Base/Large, AudioSet and bioacoustics fine-tunes) 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   # + end-to-end (downloads from HF)
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.0.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.0-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: openbeats-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 1b93bb16951edbf1552090737ff6b887d14c98f975d86bbcee243570478fe67b
MD5 69ed5a72d3079074888692b51c4fb897
BLAKE2b-256 988b57722b67f5ba31069a0b47efb9346eaf488aa36b50c4bb7ffe6f85d014e0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: openbeats-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18eaee7cae58c66d8d64b6219cba24cb8bbacbeda8006dba105b0853a983b4ea
MD5 abde2c4046a3a86ae58870e4abd283cf
BLAKE2b-256 9a3866f0e0056b13dc4012d43716a583b81684d12fcba6bc4bfa0b98f7fc6fb6

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