sensevoice
Rust bindings for the local SenseVoice GGUF runtime in runtime/llama.cpp.
This crate packages the Rust API and native ggml/FSMN-VAD runtime sources only. It does not package model files.
Models
Create a local model directory and place the GGUF files there:
models/
sensevoice-small-q8.gguf
fsmn-vad.gguf
Pre-converted models are available from:
- SenseVoiceSmall GGUF: https://huggingface.co/FunAudioLLM/SenseVoiceSmall-GGUF
- FSMN-VAD GGUF: https://huggingface.co/FunAudioLLM/fsmn-vad-GGUF
File transcription
use Recognizer;
Realtime PCM
The realtime API expects 16 kHz mono f32 PCM samples in [-1.0, 1.0].
use RealtimeRecognizer;
Microphone example
The microphone example uses cpal, which is a dev-dependency and is not required
by library users.
Use --verbose to print input levels and endpoint diagnostics.
For lower-latency interactive use, the example continuously re-runs ASR on the current speech buffer and refreshes the same stdout line before an endpoint is detected.
Native build
The native runtime is built by CMake. Install:
- Rust 1.85+
- CMake
- A C/C++ toolchain
- Linux microphone example only: ALSA development headers, e.g.
libasound2-dev
Supported build targets are macOS, Linux, and Windows on the architectures
supported by llama.cpp/ggml. The crate is a native binding crate, so
cross-compilation also needs a matching C/C++ toolchain and CMake generator for
the target platform.
By default the CMake project fetches a pinned llama.cpp revision. For offline
or reproducible builds, provide a local checkout:
FUNASR_LLAMA_SOURCE=/path/to/llama.cpp
Model files are runtime inputs and are intentionally not part of the crate package.
Windows
Use the MSVC Rust toolchain on Windows. Install:
- Rust stable for
x86_64-pc-windows-msvc - Visual Studio 2022 Build Tools with Desktop development with C++
- A Windows 10/11 SDK
- CMake and Git available in
PATH
Windows ARM64 is also supported when Cargo, MSVC, the Windows SDK, and the CMake
generator are all configured for aarch64-pc-windows-msvc.
PowerShell example:
rustup default stable-x86_64-pc-windows-msvc
cargo build --release
cargo run --example microphone_realtime -- --list-devices
cargo run --example microphone_realtime -- --device 0
The build script compiles ggml and the C ABI bridge, then copies
funasr_rs.dll into Cargo's binary, dependency, and example output directories.
When distributing a standalone application, ship
target\release\funasr_rs.dll beside the application .exe. Model GGUF files
remain separate runtime files and can be placed anywhere the application can
access.
Publishing
The crate package uses an explicit include whitelist in Cargo.toml; models/
is also git-ignored. Release packages contain the Rust API, examples, and native
runtime bridge sources, but not SenseVoice/FSMN-VAD model files.
Before publishing:
DOCS_RS=1
If the local build should avoid network access to fetch llama.cpp, set
FUNASR_LLAMA_SOURCE for the cargo check, cargo package, and
cargo publish --dry-run commands.