Whisper.Sentis

Whisper speech-to-text running inside Unity on the Sentis inference engine.

Role
Engineering
Areas
AI, Tools, Research

Speech recognition in an app usually means sending audio to a cloud service or depending on whatever the platform provides. In Whisper.Sentis we run Whisper inside Unity itself, on Unity Sentis (the engine Unity later renamed Inference Engine), so transcription stays on the device and works the same on every platform Unity targets.

How it's built

Whisper is split into separate ONNX models that Sentis loads at runtime:

  • a log-mel spectrogram model that turns 16 kHz audio into Whisper's input features;
  • the audio encoder;
  • a decoder, plus a decoder-with-past variant that reuses cached keys and values so each new token doesn't recompute the whole sequence.

A shared base class runs the encode and decode loop and turns tokens back into text with Whisper's vocabulary. The project has two scenes: one transcribes prerecorded clips, the other transcribes live.

Flow diagram of six stages: 16 kHz audio padded to 30 seconds, a log-mel spectrogram model, the audio encoder, a decoder fed four prompt tokens, a decoder-with-past that reuses cached keys and values, and an argmax step that maps tokens to text until end-of-text.
We split Whisper into separate models so the encoder runs once and each new token reuses the decoder's cache.

Real-time transcription

Whisper works on fixed windows of audio, not a stream. The real-time component bridges that gap:

  1. Microphone samples are appended to a ring buffer.
  2. Every two seconds, the latest three seconds of audio are pulled out as a chunk, so consecutive chunks overlap by a second and words at a boundary aren't cut in half.
  3. Each chunk is transcribed, and overlapping text is detected by matching the end of the previous result against the start of the new one, so it isn't repeated.
  4. When listening stops, leftover samples are padded into one final chunk.
Timeline of four horizontal bars, each three seconds long, starting two seconds apart so every bar overlaps the previous one by one second.
We pull the latest three seconds every two seconds, so a word at a boundary always lands whole in one window.

Sentis reference

We also published a reference guide to Unity Sentis: model loading, tensors, workers and backends, the functional API for editing a model graph, texture conversion, and performance and troubleshooting notes, with code examples throughout.

This was research into on-device speech for Frndo, whose app uses Apple's on-device recognizer instead. Related on-device ML work in Unity: Frndo's lip-sync system, which runs its viseme network on Sentis.