SuperAPI AI Directory

delayed-streams-modeling

Delayed Streams Modeling is a streaming X-to-Y task modeling framework proposed by the Kyutai lab, and based on this framework, the Kyutai speech-to-text (STT) and text-to-speech (TTS) models were released. This repository provides instructions and examples for running these models, covering multiple implementations such as PyTorch, Rust, and MLX, and supporting real-time streaming inference, batch processing, word-level timestamps, and semantic voice activity detection (VAD). The STT models include an approximately 1B-parameter English-French bilingual model (0.5-second latency) and an approximately 2.6B-parameter English-only model (2.5-second latency); the TTS models likewise provide both streaming and non-streaming implementations. The project also includes a Rust server for production environments, an MLX implementation for iPhone/Mac, as well as Colab notebooks and example scripts. The code is licensed under MIT and Apache, and the model weights are licensed under CC-BY 4.0.

Open website

About this tool

Delayed Streams Modeling (DSM) is a technical framework proposed by the Kyutai lab for solving a variety of streaming X-to-Y tasks (where X and Y belong to {speech, text}), formalizing the approach previously used by Moshi and Hibiki. This repository provides instructions and examples for running the Kyutai speech-to-text (STT) and Kyutai text-to-speech (TTS) models. In addition, Unmute, a speech AI system built on Kyutai STT and Kyutai TTS, is also available for reference.

Kyutai Speech-to-Text (STT)

The Kyutai STT models are optimized for real-time use, can process in batches for improved efficiency, and return word-level timestamps. Two models are provided:

  • kyutai/stt-1b-en_fr: an English and French model, approximately 1B parameters, 0.5-second latency, with semantic VAD.
  • kyutai/stt-2.6b-en: an English-only model, approximately 2.6B parameters, 2.5-second latency.

These speech-to-text models have the following advantages:

  • Streaming inference: the models can process audio in chunks to achieve real-time transcription, making them ideal for interactive applications.
  • Easy batch processing for maximum efficiency: a single H100 can process 400 streams in real time.
  • Returns word-level timestamps.
  • The 1B model has a semantic voice activity detection (VAD) component, which can be used to detect when the user is speaking, and is particularly useful for building speech agents.

Implementation Overview

Different Kyutai STT implementations are provided for different use cases:

  • PyTorch: for research and experimentation. If you want to call the model from Python for research or experimentation, use the PyTorch implementation.
  • Rust: for production environments. If you want to serve Kyutai STT in a production environment, use the Rust server. This server provides streaming access via websockets. On an L40S GPU, it can serve 64 concurrent connections at a 3x real-time factor.
  • MLX: for on-device inference on iPhone and Mac. MLX is Apple's machine learning framework that can leverage the hardware acceleration of Apple chips. If you want to run the model on a Mac or iPhone, choose the MLX implementation.

For an example of how to stream directly in PyTorch tensors, seeRefer to the Colab notebook. This requires the moshi package version 0.2.6 or higher, installable via pip. If you only want to run the model on a file, you can use moshi.run_inference. If uv is installed, you can skip the installation step and simply prefix the command with uvx --with moshi.

In addition, two scripts are provided to highlight different use cases: the first script explains how to extract word-level timestamps from the model output; the second script can be used to run the model on an existing Hugging Face dataset and compute performance metrics. Another example shows how to provide text, audio, or text-audio prompts to the STT model. For example, using Loonah spelling instead of Luna without a prompt generates the transcription of bria.mp3. Besides adjusting the spelling of specific words, other potential use cases include speaker adaptation, guiding the model to adopt a specific formatting style or even language. However, please note that this is an experimental feature, and its behavior is very sensitive to the provided prompt.

The Rust implementation provides a server that can process multiple streaming queries in parallel. Depending on the amount of GPU memory, the batch size in the configuration file may need to be adjusted. For an L40S GPU, a batch size of 64 works well, and requests can be processed at 3x real-time speed. To run the server, install the moshi-server crate with the following command. The server code can be found in the kyutai-labs/moshi repository. Then start the server using this repository's configuration file. For kyutai/stt-1b-en_fr, use configs/config-stt-en_fr.hf.toml; for kyutai/stt-2.6b-en, use configs/config-stt-en-hf.toml. Once the server is running, you can use a script to transcribe audio from a microphone, and a script for transcribing from an audio file is also provided. The script limits decoding speed to simulate real-time processing. Faster processing can be triggered by setting the real-time factor, for example --rtf 1000 will process data as fast as possible. A standalone Rust example script is provided in the stt-rs directory of this repository. Timestamps can be obtained by adding the --timestamps flag, and the output of the semantic VAD can be viewed by adding the --vad flag.

MLX is Apple's machine learning framework that allows hardware acceleration on Apple chips. This requires moshi-mlx Package 0.2.6 or higher, installable via pip. If you only want to run the model on a file, you can use moshi_mlx.run_inference. If uv is installed, you can skip the installation step and simply prefix the command with uvx --with moshi-mlx. If you want to transcribe audio from a microphone, use the corresponding command. The MLX model can also be used in Swift with the moshi-swift codebase, and the 1b model has been tested and works on the iPhone 16 Pro.

Kyutai Text-to-Speech (TTS)

Different Kyutai TTS implementations are provided for different use cases:

  • Rust: for production environments. If you want to serve Kyutai TTS in a production environment, use the Rust server. This server provides streaming access via websockets.

You can check out the Colab notebook or use the scripts. The tts_pytorch.py script waits until all text is available before starting to generate audio. A fully streaming implementation is available in the tts_pytorch_streaming.py script. This requires the moshi package, installable via pip. If uv is installed, you can skip the installation step and simply prefix the command with uvx --with moshi.

The Rust implementation provides a server that can handle multiple streaming queries in parallel. Installing the Rust server is a bit tricky, because it uses a Python implementation under the hood and also requires installing Python dependencies. Use the start_tts.sh script to install the Rust server correctly. If you have previously installed the moshi-server crate and it does not work, you may need to run cargo uninstall moshi-server first to force a reinstall. If installation still has problems, you can file an issue. After installation, start the server using this repository's configuration file. Once the server is running, you can connect using the script. You can configure the server by modifying configs/config-tts.toml; see the comments in that file for the available options.

Use the example script to run Kyutai TTS on MLX. The script gets text from stdin or a file, and can output to a file or stream the generated audio. When streaming, if the model is not fast enough to keep up with real time, you can use the --quantize 8 or --quantize 4 flag to quantize the model to speed up inference. This requires the moshi-mlx package, installable via pip. If uv is installed, you can skip the installation step and simply prefix the command with uvx --with moshi-mlx.

License and Citation

The Python part of the current code is provided under the MIT license, and the Rust backend is provided under the Apache license. The web client code is provided under the MIT license. Note that some code is based on AudioCraft, released under the MIT license. The weights of the speech-to-text model are released under the CC-BY 4.0 license.

Install the pre-commit hook by running the corresponding command. If you use uv, you can replace the two commands with uvx pre-commit install. Please cite the relevant papers.