| Crates.io | smart-turn-rs |
| lib.rs | smart-turn-rs |
| version | 0.1.0 |
| created_at | 2025-11-21 03:11:36.612369+00 |
| updated_at | 2025-11-21 03:11:36.612369+00 |
| description | A Rust library for livekit's smart turn detection v3 using ONNX Runtime. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1943030 |
| size | 43,565 |
Rust re-implementation of the pipecat-ai/smart-turn endpoint detector. It wraps ONNX Runtime via the ort crate and exposes a small API plus an example CLI for running predictions locally.
examples/basic.rs) demonstrates loading audio, computing features, and printing prediction results.Smart Turn expects exactly 8 seconds of 16 kHz mono PCM audio per prediction. Provide audio in WAV format with:
16_000 HzFeeding data that violates these constraints leads to preprocessing errors or unreliable predictions.
ort crate requirement).smart-turn-v3.0.onnx from the upstream repo.cargo run --example basic -- --audio <path/to/8s_16k.wav> --model <path/to/smart-turn-v3.0.onnx>
The example prints prediction, probability, real-time factor, and a JSON payload.Add the crate to your project (currently via path/git dependency) and call the predictor:
use smart_turn_rs::{SmartTurnPredictor, features::log_mel_spectrogram};
use ndarray::Array3;
use std::path::Path;
fn run_smart_turn(model_path: &Path, features: Array3<f32>) -> anyhow::Result<()> {
let mut predictor = SmartTurnPredictor::new(model_path)?;
let result = predictor.predict(features)?;
println!("prediction: {} (p={:.3})", result.prediction, result.probability);
Ok(())
}
Follows the upstream project: BSD 2-Clause License. Refer to the original pipecat-ai/smart-turn for model provenance and additional documentation.