Run this model with HF Jobs

Run moonbox-dev/sava-TensorRT on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/moonbox-dev/sava-TensorRT. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/moonbox-dev/sava-TensorRT on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
File size: 13,813 Bytes
36fc6d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
---
base_model: inworld/sava
base_model_relation: quantized
license: apache-2.0
pipeline_tag: voice-activity-detection
library_name: tensorrt
tags:
- tensorrt
- moonbox
- inworld
- sava
- voice-activity-detection
- vad
- end-of-turn
- turn-detection
- streaming
- realtime
---

# SAVA (voice activity + end of turn) TensorRT

TensorRT engines of [SAVA (voice activity + end of turn)](https://huggingface.co/inworld/sava), made by Moonbox for NVIDIA RTX GPUs. Each precision is one folder holding the
engine, `trt_runner.py` (a small numpy runner: TensorRT plus Polygraphy, no PyTorch) and a script that does the rest
of the pipeline. What the engine takes and returns is under *How to run*.

**Compatibility.** The engines are built *hardware compatible* (Ampere and newer: RTX 30, 40 and 50 series) and
*version compatible* (any TensorRT 10.x from 10.13 on, through its lean runtime). That costs a little speed against an
engine built for one GPU, but no rebuild is needed. Install the runtime with
`pip install "tensorrt-cu12>=10.13,<11" "tensorrt-lean-cu12>=10.13,<11" polygraphy numpy`.

## Files

The last column is the benchmark (details under *How to run*).

| Precision | File | Size | sha256 | Benchmark |
|---|---|---|---|---|
| fp16 | [`fp16/LICENSE`](https://huggingface.co/moonbox-dev/sava-TensorRT/blob/main/fp16/LICENSE) | 11.4 kB | `cfc7749b96f6` | fp32 math (as the ONNX fp16-storage build): probabilities within 9e-6 of the ONNX build's, 0 of 45,334 decisions changed (1 vs the original, as that build); RTF 0.043 (ONNX on one CPU thread 0.18, on CUDA 0.21) |
| fp16 | [`fp16/NOTICE`](https://huggingface.co/moonbox-dev/sava-TensorRT/blob/main/fp16/NOTICE) | 0.7 kB | `f845c91d8624` | (the same build: numbers in its first row) |
| fp16 | [`fp16/config.json`](https://huggingface.co/moonbox-dev/sava-TensorRT/blob/main/fp16/config.json) | 1.8 kB | `87345d68edc7` | (the same build: numbers in its first row) |
| fp16 | [`fp16/device_chain.py`](https://huggingface.co/moonbox-dev/sava-TensorRT/blob/main/fp16/device_chain.py) | 9.4 kB | `f34bec2d7d50` | (the same build: numbers in its first row) |
| fp16 | [`fp16/pipeline.py`](https://huggingface.co/moonbox-dev/sava-TensorRT/blob/main/fp16/pipeline.py) | 6.3 kB | `c475d6911a2d` | (the same build: numbers in its first row) |
| fp16 | [`fp16/pipeline_trt.py`](https://huggingface.co/moonbox-dev/sava-TensorRT/blob/main/fp16/pipeline_trt.py) | 3.3 kB | `dd952d4f2f35` | (the same build: numbers in its first row) |
| fp16 | [`fp16/step.engine`](https://huggingface.co/moonbox-dev/sava-TensorRT/blob/main/fp16/step.engine) | 151.3 MB | `70f78d526207` | (the same build: numbers in its first row) |
| fp16 | [`fp16/trt_runner.py`](https://huggingface.co/moonbox-dev/sava-TensorRT/blob/main/fp16/trt_runner.py) | 4.4 kB | `3075c6bb264c` | (the same build: numbers in its first row) |

## How to run

Inworld's SAVA as one TensorRT engine of its streaming step plus `pipeline_trt.py`. SAVA does streaming voice activity
and end-of-turn detection in one 25.5M model: 16 kHz mono goes in, and a speech probability and an end-of-turn
probability come out every 40 ms.

The pipeline is this model's ONNX `pipeline.py`, a numpy port of the `inworld-sava` package's `Session` (push / flush)
and `run`, with the step run as the engine. The stream state stays on the GPU between steps: two sets of buffers per
stream, read from one and written to the other each frame. Only the 40 ms frame goes in and the three logits come
out.

```python
import sys
import soundfile as sf
sys.path.insert(0, "fp16")
from pipeline import Session
from pipeline_trt import SavaTrt
model = SavaTrt("fp16")
s = Session(model)
x, sr = sf.read("call_16k.wav", dtype="float32")     # 16 kHz mono
frames = s.push(x)                                   # any chunk size; then s.flush() at the end
print(frames.speech[-5:], frames.turn[-5:])
```

Or `python fp16/pipeline_trt.py call_16k.wav`. It needs numpy, TensorRT 10.13 (`tensorrt-cu12` or
`tensorrt-lean-cu12`) and Polygraphy, and soundfile to read files. The engine is version-compatible and built for
Ampere or newer GPUs (RTX 30-series and up).

**The engine.** `step.engine` takes `pcm` [1, 640] (one 40 ms frame, float32 in [-1, 1]) and the stream state. The
state is 19 tensors named `state.*`, with shapes and dtypes in `config.json`:
- the mel front end's sample context and the frame mixer's previous frame;
- the three Mamba-2 blocks' conv tails and SSM states;
- the four attention blocks' 512-frame key / value windows and position counters;
- the previous speech probability and the frame counter.

It returns `lookahead` (the speech logit of the frame three frames back), `speech` (on time), `turn` [1, 1, 4]
(end-of-turn logits at horizons of 0, 200, 400 and 800 ms) and the next state (`next.*`). All shapes are fixed.

**Precisions.** `fp16/` is built from the ONNX `fp16/` build, whose weights are stored in fp16 and read as fp32. The
casts are folded into fp32 weights, so the engine's math is fp32 like the ONNX build's, and the engine is 151 MB.
There is no int8: TensorRT's int8 needs calibrated activations.

**Benchmark.**
- **Data:** 20 synthetic conversations, 904 s and 22,667 frames, streamed through each build in the same pushes.
- **Score:** each frame's speech and end-of-turn probability, and the decisions at 0.5, against the ONNX `fp16/` build
  and against the package's own `Session` (fp32, CPU).
- **Pass mark** (set before the first run): no more than 0.01 % of decisions different from the ONNX build's.

| | max probability difference | decisions changed | real-time factor |
|---|---|---|---|
| ONNX `fp16/` on one CPU thread | 1.6e-3 vs the original | 1 of 45,334 vs the original | 0.18 |
| ONNX `fp16/` on CUDA | - | - | 0.21 |
| TensorRT `fp16/` | 9e-6 vs the ONNX build (1.6e-3 vs the original) | 0 vs the ONNX build (1 vs the original) | 0.043 |

Timing is on an RTX 3080 Laptop GPU. The real-time factor is for the whole streaming loop in Python, frame by frame.

## How these were made

From [SAVA (voice activity + end of turn)](https://huggingface.co/inworld/sava) at revision `1beae7c1dd`: each engine was built with TensorRT's builder from Moonbox's published
ONNX graph of the same model and precision. The network is *strongly typed*: every tensor keeps the precision the
ONNX graph gives it, so an fp16 engine computes what the fp16 ONNX build computes. Built on an RTX 3080 Laptop GPU,
it was benchmarked against the original before upload, and the `sha256` column above is what the files must hash to.

## License

Apache-2.0. These files are a derivative of the original model and carry its license: it is copied in this
repository, and it governs your use of these files. The original model card follows unchanged.

---

# Original model card

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/inworld/sava/resolve/main/docs/assets/inworld-logo-white.svg">
    <img src="https://huggingface.co/inworld/sava/resolve/main/docs/assets/inworld-logo-black.svg" alt="Inworld" width="220">
  </picture>
</p>

<h1 align="center">SAVA</h1>

<p align="center">
  Semantic acoustic voice activity: streaming speech and end-of-turn detection in one model with an open license.
</p>

<p align="center">
  <a href="https://github.com/inworld-ai/sava"><img src="https://img.shields.io/badge/GitHub-inworld--ai%2Fsava-181717?logo=github" alt="GitHub: inworld-ai/sava"></a>
</p>

---

## TL;DR

SAVA returns two probabilities for a live audio stream:
* `speech` → whether a frame holds speech
* `turn` → whether the speaker's turn has ended

The model's shared network uses acoustic and sentence context to distinguish speech from coughs, laughs, music and keyboard clatter.

| | SAVA |
|---|---|
| made for | voice activity and conversational turn taking |
| input | 16 kHz mono audio |
| output | two probabilities every 40 ms |
| timing | speech probability for a frame is emitted 120 ms later (lookahead); end-of-turn probability has no lookahead |
| parameters | 25.5M |
| execution | plain PyTorch, CPU or an explicitly selected device |

Use it to open a turn when speech starts and close it when the sentence is complete.
The [reference turn policy](https://github.com/inworld-ai/sava/blob/main/docs/USAGE.md) turns the probabilities into segments; applications can supply their own policy.
SAVA responds to any voice. It does not pick out a target speaker, and it leaves interruptions and backchannels to the application's dialogue policy.

## Quick start

Using a coding agent? Point it at the [setup section of AGENTS.md](https://github.com/inworld-ai/sava/blob/main/AGENTS.md#setting-up-sava-for-a-user): it installs the package, checks the machine with `sava-doctor` and runs SAVA on a first recording.

With Python 3.10 or later:

```bash
python -m pip install inworld-sava
# Or from a clone: git clone https://github.com/inworld-ai/sava && cd sava && python -m pip install -e .
sava run recording.wav
sava run recording.wav --turns_dir turns/ --curves curves.json
```

```python
from inworld import sava

model = sava.load("inworld/sava")
curves = sava.run(model, sava.load_audio("recording.wav"))
turns = sava.segment(curves, sava.Policy(), model.lookahead_frames)

session = sava.Session(model)
for piece in pieces_of_16k_audio:  # One-dimensional floating-point mono samples.
    frames = session.push(piece)
frames = session.flush()
```

`sava.load("inworld/sava")` and the CLI's default model download the weights on first use and verify their checksum.
The CLI defaults to CPU; `--device` selects another device.
For microphone input, install `python -m pip install "inworld-sava[mic]"` and run `sava mic`.

The code, [the integration guide](https://github.com/inworld-ai/sava/blob/main/docs/USAGE.md) and the [benchmarks](https://github.com/inworld-ai/sava/blob/main/bench/README.md) are on GitHub: [inworld-ai/sava](https://github.com/inworld-ai/sava).

## Hardware

Tested on NVIDIA Ampere, Hopper and Blackwell GPUs and on CPU.
On an Apple M3 Max CPU one stream takes 3.8 ms per 40 ms frame; [the integration guide](https://github.com/inworld-ai/sava/blob/main/docs/USAGE.md) lists the measured configurations.

## The benchmarks

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/inworld/sava/resolve/main/docs/assets/vad-dark.svg">
    <img src="https://huggingface.co/inworld/sava/resolve/main/docs/assets/vad-light.svg" alt="Voice-activity frame AUC for SAVA and Silero VAD on nine public dataset readings" width="100%">
  </picture>
</p>

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/inworld/sava/resolve/main/docs/assets/turn-dark.svg">
    <img src="https://huggingface.co/inworld/sava/resolve/main/docs/assets/turn-light.svg" alt="End-of-turn clip AUC for SAVA and smart-turn on public datasets" width="100%">
  </picture>
</p>

Voice activity is compared with Silero VAD; end of turn is compared with pipecat smart-turn v3.2.
These are per-dataset measurements, with no combined ranking.
Speech scores use each model's own output timing, so SAVA's 120 ms lookahead makes the comparison unequal in latency.
Quiet speech-like noise can trigger SAVA; the ESC-50 results measure that failure mode.

[The complete tables, confidence intervals, noise tests, turn latency and reproduction steps](https://github.com/inworld-ai/sava/blob/main/bench/README.md) are on GitHub.

## Architecture

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/inworld/sava/resolve/main/docs/assets/architecture-dark.svg">
    <img src="https://huggingface.co/inworld/sava/resolve/main/docs/assets/architecture-light.svg" alt="SAVA: causal log-mel features, frame mixer, Mamba and attention trunk, speech and turn heads" width="100%">
  </picture>
</p>

| part | detail |
|---|---|
| front end | causal log-mel, 128 Slaney mel bins of a 25 ms Hann DFT every 10 ms, log10 with a 1e-10 floor, `(x + 4) / 4`; four hops per frame plus the frame's log RMS |
| mixer | the current and previous frame's features, one linear projection to 512, RMSNorm |
| trunk | three Mamba-2 blocks (expand 2, head dim 64, state 128, conv kernel 4) and one attention block (8 query heads, 2 key/value heads, head dim 64, 512-frame causal window, rotary positions, RMS-normed q and k, exclusive self attention), each with a SwiGLU FFN of 2048 |
| voice-activity head | RMSNorm, down-projection to 512, one attention block (window 512, FFN 1536), RMSNorm, two linear readouts: on time, and the released three-frame look-ahead |
| end-of-turn head | the trunk output with a 64-wide embedding of the previous frame's on-time speech probability, the same block shape, a linear readout with four horizon columns (0, 200, 400, 800 ms); column 0 is the released output |

## Training data

SAVA was trained on approximately 5,000 hours of unique audio.
Inworld built training examples from real and synthetic conversational speech
mixed with non-verbal vocal sounds, noise, music and room acoustics, with a
speech label and an end-of-turn label for every frame. The training recipe,
code and data are not part of this release.

Third-party datasets used in training are credited in [NOTICE](NOTICE).

## License

Code and weights are Apache-2.0 ([LICENSE](LICENSE)).
Third-party notices are in [NOTICE](NOTICE).

## How to contribute

Everyone is welcome to use the model however they like and to make it better in any way they see fit!
Development happens on GitHub: see [CONTRIBUTING.md](https://github.com/inworld-ai/sava/blob/main/CONTRIBUTING.md) for setup, tests and bug reports.

---

<p align="center">Built for people with ❤️ by Inworld.</p>