gradium-ai/xn-moshi

Rust

1

7 commits

updated Sep 22, 2026

See the code

README

xn-moshi

Rust implementation of the Moshi model family — the Mimi neural audio codec, the streaming ASR model, and the speech-to-speech model — built on top of the xn inference framework.

This crate used to live in the xn repository as the xn-moshi workspace member.

Usage

Add the dependency:

[dependencies]
xn-moshi = "0.2.4"

The library is backend-agnostic; pick one through the feature flags, which are forwarded to xn:

featureeffect
cudaCUDA backend
metalMetal backend
vulkanVulkan backend
webgpuWebGPU backend
accelerateAccelerate BLAS on macOS
audioaudio file IO via kaudio, needed for examples

Examples

The moshi example needs the audio feature. It downloads the weights from the Hugging Face hub on first use.

# Encode an audio file to Mimi codes and decode it back.
cargo run --release --features audio --example moshi -- audio-to-audio input.wav -o output.wav

# Transcribe an audio file.
cargo run --release --features audio --example moshi -- asr input.wav

# Run the speech-to-speech model.
cargo run --release --features audio --example moshi -- s2s input.wav --voice voice.safetensors --config config.json

Add e.g. --features cuda to run on a GPU.

The quantize example converts an ASR safetensors checkpoint to a quantized GGUF file:

cargo run --release --example quantize -- asr model.safetensors model-q8.gguf --quant q8_0

Development

Install the formatting pre-commit hook with:

./scripts/setup-git-hooks.sh

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Contributors

LaurentMazare

7 commits

gradium-ai/xn-moshi

Rust

1

7 commits

updated Sep 22, 2026

See the code

README

xn-moshi

Rust implementation of the Moshi model family — the Mimi neural audio codec, the streaming ASR model, and the speech-to-speech model — built on top of the xn inference framework.

This crate used to live in the xn repository as the xn-moshi workspace member.

Usage

Add the dependency:

[dependencies]
xn-moshi = "0.2.4"

The library is backend-agnostic; pick one through the feature flags, which are forwarded to xn:

featureeffect
cudaCUDA backend
metalMetal backend
vulkanVulkan backend
webgpuWebGPU backend
accelerateAccelerate BLAS on macOS
audioaudio file IO via kaudio, needed for examples

Examples

The moshi example needs the audio feature. It downloads the weights from the Hugging Face hub on first use.

# Encode an audio file to Mimi codes and decode it back.
cargo run --release --features audio --example moshi -- audio-to-audio input.wav -o output.wav

# Transcribe an audio file.
cargo run --release --features audio --example moshi -- asr input.wav

# Run the speech-to-speech model.
cargo run --release --features audio --example moshi -- s2s input.wav --voice voice.safetensors --config config.json

Add e.g. --features cuda to run on a GPU.

The quantize example converts an ASR safetensors checkpoint to a quantized GGUF file:

cargo run --release --example quantize -- asr model.safetensors model-q8.gguf --quant q8_0

Development

Install the formatting pre-commit hook with:

./scripts/setup-git-hooks.sh

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Contributors

LaurentMazare

7 commits

Languages

Rust

99.9%