livekit-plugins-speakerbeamss
A LiveKit Agents STT plugin that runs OpenSpeakerBeam-SS target-speaker extraction in front of any inner STT instance. The agent hears only the user — even with competing speakers, music, or noise in the room.
The plugin is ONNX-only. The PyTorch separator never ships here.
The trained INT8 model is bundled inside the wheel at
livekit/plugins/speakerbeamss/models/speakerbeam_ss_trained_int8.onnx
(≈13 MB), so a fresh pip install livekit-plugins-speakerbeamss is
enough — no separate download. Follow step 0 below only if you want to
swap in a different export (FP32, the base release, or your own
fine-tune).
The reference audio for the target speaker is taken from the
agent's first user turn: the first sentence the user speaks is
forwarded to the inner STT as-is so the agent can still
understand it, and is also kept in a buffer. When the inner STT
emits END_OF_SPEECH, the buffer is collapsed to a Resemblyzer
d-vector and the plugin flips to extraction mode for every
subsequent utterance.
You can also pass a pre-recorded enrollment audio via
reference_audio="path.wav" to skip the capture phase entirely.
Installation
# 1. Install this plugin (from the plugin source root):
cd livekit/plugins/speakerbeamss
pip install -e .
That's it — pip install wires up livekit.plugins.speakerbeamss
and ships the trained ONNX bundle, which the loader resolves via
importlib.resources. No env vars, no separate download.
Using a different exported variant
If you have your own export (FP32, base release, a re-trained checkpoint, …) you'd rather use, point the loader at it explicitly:
from livekit.plugins.speakerbeamss import STT
sb_stt = STT(
inner=inner,
onnx_dir="/Users/linsan/Public/projects/OpenSpeakerBeam-SS/exports",
onnx_filename="speakerbeam_ss_int8.onnx", # base INT8 release
)
The loader's lookup order is:
- Bundled —
livekit.plugins.speakerbeamss.models/<filename>(the trained INT8 lives here by default). - Disk —
{onnx_dir}/{filename}if set, otherwise the~/Public/projects/OpenSpeakerBeam-SS/exports/fallback.
To export a different variant yourself:
cd ~/Public/projects/OpenSpeakerBeam-SS
pip install -r requirements.txt
python export_onnx.py --ckpt checkpoints/best_model.pth
ls exports/ # -> speakerbeam_ss_{fp32,int8,trained_fp32,trained_int8}.onnx
Usage — wrap any inner STT
from livekit.plugins.speakerbeamss import STT
from livekit.plugins.volcengine import STT as VolcSTT # any streaming inner STT
inner = VolcSTT() # read keys from env, etc.
stt = STT(inner=inner)
# ... pass `stt` to your VoicePipelineAgent as usual.
That's it. The agent will see exactly the transcripts it would have seen without the wrapper, but with the first turn's enrollment frozen into a d-vector and applied to every chunk that follows.
Usage — offline
import numpy as np
from livekit.plugins.speakerbeamss import OnnxSpeakerBeamExtractor
extractor = OnnxSpeakerBeamExtractor() # INT8 by default
extractor.enroll(np.random.randn(16000).astype(np.float32)) # reference audio
chunk = np.random.randn(8000).astype(np.float32) # < 1 s
print(extractor.append(chunk)) # [] (no full chunk yet)
print(extractor.append(np.zeros(8000, dtype=np.float32))) # [ndarray of len 16000]
How the state machine works
| Phase | Inner STT input | Plugin behavior |
|---|---|---|
CAPTURING (first user turn) |
Raw audio, downmixed to mono 16 kHz | Buffers audio; on END_OF_SPEECH, computes d-vector and locks |
LOCKED (after first turn) |
ONNX-extracted mono 16 kHz | Embedding reused for all subsequent user turns until stream ends |
EXTERNAL (when reference_audio was provided) |
Raw audio, downmixed to mono 16 kHz | No enrollment phase; extraction applied from the first frame |
Configuration knobs
STT(...) arguments:
| Name | Default | Purpose |
|---|---|---|
inner |
(required) | Any stt.STT with streaming=True. |
reference_audio |
None |
Path to an enrollment WAV/PCM file. Bypasses the capture phase. |
onnx_dir |
~/Public/projects/OpenSpeakerBeam-SS/exports |
Fallback directory for .onnx files (used only when the bundled model is missing). |
onnx_filename |
speakerbeam_ss_trained_int8.onnx (bundled) |
Override the exact model filename. Looked up in the bundled models/ directory first, then on disk. |
chunk_seconds |
1.0 |
ONNX window length. Must match the time axis baked into the export. |
sample_rate |
16_000 |
Sample rate for both extractor and the framework resampler. |
min_enrollment_seconds |
0.5 |
Refuse to lock enrollment from < this much captured audio. |
pass_through_first_utterance |
True |
When True, the first turn reaches the inner STT untouched so the agent's first reply still makes sense. |
interim_results |
(inherit from inner) | Capability flag for downstream VoicePipelineAgent. |
Environment variables:
| Var | Purpose |
|---|---|
SPEAKERBEAMSS_ONNX_DIR |
Override onnx_dir for one-off runs. |
Verified against
- LiveKit Agents
>= 1.5.13 - OpenSpeakerBeam-SS commit exporting
speakerbeam_ss_trained_int8.onnx(~13 MB) at opset 20, chunk length 16 000 samples / 16 kHz — the bundle that ships inside the wheel.
License
Apache-2.0 (same as LiveKit Agents).
Release files for livekit-plugins-speakerbeamss 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| livekit_plugins_speakerbeamss-0.2.5.tar.gz | 16.4 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| livekit_plugins_speakerbeamss-0.2.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.9 MB
Release files / livekit_plugins_speakerbeamss-0.2.5.tar.gz
| Download URL | livekit_plugins_speakerbeamss-0.2.5.tar.gz |
|---|---|
| Size | 16.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f1f4525ae26079bf83b8ba18819f54f9829f78290670b641dad485772cad2e20
|
|
BLAKE2b-256 checksum How to use checksums |
b04737b152ee0756743beb8442b5ef1da06e820a16c41ad10689682abed0cf53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.20
|
Release files / livekit_plugins_speakerbeamss-0.2.5-py3-none-any.whl
| Download URL | livekit_plugins_speakerbeamss-0.2.5-py3-none-any.whl |
|---|---|
| Size | 16.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f4bade37fa833c9aca0ba56ba932c4b8eb5f6eaaa10d7db6319b60458b84205
|
|
BLAKE2b-256 checksum How to use checksums |
7af0cfd296c4b2c92afa54f481ece9c9bcc4337a77357557ffeed31744889a12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.20
|