Skip to content

About

Cross-platform TTS wrapper with C API — mirrors js-tts-wrapper / SwiftTTSWrapper. 21 engines: system, Sherpa-ONNX (191 models), and 19 cloud providers.

Resources

Stars

5 stars

Watchers

0 watching

Forks

Repository files navigation

rust-tts-wrapper

Cross-platform text-to-speech for Rust — 28 engines behind one API, plus a flat C ABI with bindings for .NET, Python, Node and Swift.

  • One API, three families: OS voices (SAPI, AVSpeech, speech-dispatcher), offline engines (Sherpa-ONNX, floravox, qwen3, OmniVoice, Kyutai pocket), and 22 cloud providers (Azure, Google, OpenAI, ElevenLabs, Polly, …).
  • Real word timings where the engine provides them (Azure/Edge WebSockets, Google timepoints, floravox duration tensors, pocket attention), honest estimates everywhere else.
  • Streaming audio through callbacks as it arrives, SpeechMarkdown input, SSML, voice cloning (experimental).
  • A stable C ABI (include/tts_wrapper.h) with stable error codes, a typed engine-setup schema and a tri-state credential check.

Sibling projects: js-tts-wrapper · swift-tts-wrapper · dotnet-tts-wrapper

Quick start

use rust_tts_wrapper::{create_engine, TtsEngine};

let engine = create_engine("openai", r#"{"apiKey":"sk-…"}"#)?;

let mut boundary = |word: &str, start: f32, end: f32, _: i32, _: i32, est: bool| {
    println!("{word} @ {start:.2}s–{end:.2}s{}", if est { " (est.)" } else { "" });
};
engine.speak("Hello world", Some("alloy"), 1.0, 1.0, 1.0,
    Some(&mut |_chunk: &[u8]| {}), Some(&mut boundary), None)?;
cargo build --no-default-features --features system,cloud   # Linux
cargo build --no-default-features --features sapi,cloud     # Windows
cargo build --no-default-features --features avsynth,cloud  # macOS

Documentation

Doc Contents
Rust usage creating engines, callbacks, voices, errors, setup schema, timeline, feature flags
.NET usage NuGet package, TtsClient, the AbstractTtsClient adapter, migration guide
Python usage ctypes client, loading, examples
Node usage npm package, events API
Swift usage SwiftPM package
C ABI reference every symbol, ownership rules, error codes
Engines capability matrix, credential keys, local-engine guides
Voice cloning banking, enrollment, consent-gated providers

Full API docs are generated from source (#![warn(missing_docs)] keeps every public item documented):

cargo doc --open

Runnable examples live in examples/ — including a complete Avalonia app on the released NuGet package.

Language bindings

Binding Package Status
.NET RustTtsWrapper.Bindings (NuGet, native assets included) CI-tested on Windows + Linux
Node @aactools/tts-wrapper (npm) CI-tested on 3 OSes
Swift RustTtsWrapper (SwiftPM, in-repo) CI-tested on macOS
Python bindings/python/ (single file, vendor it) CI-tested on 3 OSes
C bindings/c/ reference harness compiled -Wall -Wextra -Werror

All six suites (including Python) run in CI on every push (.github/workflows/bindings.yml).

Feature flags

system sapi avsynth — OS voices · cloud — 22 providers · sherpaonnx sherpa-g2p qwen3-local omnivoice-local floravox pocket-timing — offline engines · cloning — voice banking · display_names — ICU locale names. Details in the engines doc; local GGML engines need their C++ runtime built first (scripts/dev-stubs/ has dev stubs).

Development

cargo fmt --all && cargo clippy --all-targets -- -D warnings
cargo test --no-default-features --features system,cloud
cargo doc --no-deps --document-private-items   # docs build is CI-enforced

CI runs the full matrix: lint + tests on 3 OSes, every binding suite, the offline engines against their real C++ runtimes, and release builds for ~20 targets. Live cloud calls are exercised locally via tests/live_cloud.rs.template + .env.example.

Status & license

Active development; the C ABI surface is additive-only in practice (see docs/c-abi.md). MIT — see LICENSE.

About

Cross-platform TTS wrapper with C API — mirrors js-tts-wrapper / SwiftTTSWrapper. 21 engines: system, Sherpa-ONNX (191 models), and 19 cloud providers.

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages