Access under PolyForm Small Business
Access is approved automatically after you confirm eligibility or written permission.
Read the PolyForm Small Business License 1.0.0 linked below before requesting access. Your Hugging Face username and email are shared with Trelis Research to manage access and send a welcome email.
Log in or Sign Up to review the conditions and access this model content.
Trelis Barge-In Detector
Detect user interruptions during AI voice-agent playback and distinguish them from backchannels that let the agent continue speaking.
Includes Silero VAD, playback arming, the one-second early-reply reflex and the learned classifier. The loader automatically downloads the pinned Moonshine Tiny base (MIT). Moonshine and Silero notices.
Licence and access
Available under the PolyForm Small Business License 1.0.0, which permits commercial use by qualifying small businesses. Access is approved automatically after you confirm eligibility or written permission from Trelis Research.
If your company does not qualify, contact hello@trelis.com for a simple annual commercial licence.
Install and run
Accept access on this page, then use Python 3.12 and uv. This CPU setup is tested on Linux:
uvx --from huggingface-hub==0.36.2 hf auth login
uvx --from huggingface-hub==0.36.2 hf download \
Trelis/barge-in-detector --local-dir trelis-barge
cd trelis-barge
uv venv --python 3.12
uv pip install --index-url https://download.pytorch.org/whl/cpu \
torch==2.11.0 torchaudio==2.11.0
uv pip install -r requirements.txt
uv run --no-project python example.py microphone.wav \
--playback 0 3
Supply a 16 kHz mono microphone WAV and the actual audible assistant-playback intervals in seconds; repeat --playback START STOP for additional replies. The example prints JSON events with recording timestamps and continues replaying each interval to show episode endings. It does not control audio playback. To run the included contract tests: uv run --no-project python -m unittest -v test_barge_detector.
Optional voice isolation
The optional Trelis Voice Isolator suppresses background speech and noise before both the VAD guard and interruption classifier. Accept access to both repositories and download the isolator separately:
uvx --from huggingface-hub==0.36.2 hf download Trelis/voice-isolator --revision <isolator-commit-hash> --local-dir ../voice-isolator
uv run --no-project python example.py microphone.wav --playback 0 3 --voice-isolator ../voice-isolator
Replace <isolator-commit-hash> with the full release commit from the isolator's Files page. The loader verifies the model and native-library hashes before loading them. The native runtime requires x86-64 Linux with glibc.
For streaming use:
from barge_detector import BargeDetector
from voice_isolation import load_voice_isolator
model = load_voice_isolator("../voice-isolator")
stream = model.stream()
try:
detector = BargeDetector(enhancer=stream)
# Use playback_started(), feed(pcm16) and playback_stopped() as below.
# Supply raw microphone PCM to feed(); do not enhance it twice.
finally:
stream.close()
Keep one model and independent enhancement stream per detector for its lifetime. Playback transitions reset enhancement state. Incomplete frames are buffered during playback and discarded when it stops. Event times do not compensate for native-model delay. Keep raw microphone audio for ASR unless you have evaluated enhancement for that use.
Enhancement runs throughout each armed playback interval. Loading or processing errors are raised to the caller. Omit --voice-isolator to use raw audio. Run the included tests with uv run --no-project python -m unittest -v test_barge_detector test_voice_isolation.
Streaming integration
from barge_detector import BargeDetector
# One per microphone stream; load once before playback.
detector = BargeDetector()
# Arm at the first audible sample of each committed reply.
detector.playback_started()
def on_microphone_pcm(pcm16):
# PCM16 little-endian, mono, 16 kHz; whole-sample chunks.
for event in detector.feed(pcm16):
if event.kind == "barge":
# Your app stops output and discards queued audio.
stop_assistant_playback()
detector.playback_stopped()
break
# Also disarm when playback finishes or is cancelled.
# detector.playback_stopped()
Serialize calls on a worker thread, away from your realtime audio callback or async event loop. Arm only while committed assistant audio is audible, not while TTS is generating or a speculative reply is pending. playback_stopped() disarms and clears audio/VAD state; playback_started(new_reply=False) starts a fresh context without reopening the early-reply reflex for an already-started reply.
The guard requires five consecutive 32 ms Silero frames at probability โฅ 0.8. During the first 1,000 ms of a new reply, a confirmation triggers barge with reason early_vad, bypassing the classifier. Later confirmations score up to two seconds of microphone context; scores โฅ 0.5 trigger reason classifier. There is no duration-only fallback. Set reflex_window_ms=0 to disable the reflex.
Events are speech_onset, barge and speech_over, timed in milliseconds since playback_started(). A barge fires once per speech episode; if you continue feeding while armed, 550 ms below the smoothed VAD offset threshold closes the episode. score is the classifier's interruption score only for reason="classifier"; reflex events have score 0.
Benchmark
| Configuration | Interruption recall | Negative-span FPR |
|---|---|---|
| Trelis/barge-in-detector | 92.22% | 10.77% |
| Silero VAD | 98.27% | 34.24% |
| VAP OTO (threshold 0.5) | 94.81% | 36.35% |
TurnBench: all 38 development conversations, 347 positives and 3,733 negative spans; fixed pipelines at different operating points. Trelis results use raw audio without the optional isolator. These are development-set results, not held-out test or live-latency measurements.
Limitations
The detector can confuse background speech with an intended interruption and can miss quiet or short interruptions. The early-reply reflex bypasses the learned classifier.
- Downloads last month
- 11