anyvoice-cli-0.3.0 is not a library.
anyvoice-rs
Fast, unified async Text-to-Speech in Rust with native bindings for Node.js / Bun / TypeScript (napi-rs), Python (PyO3), and a CLI (anyvoice).
Features
- Multiple providers behind one typed interface:
- Microsoft Edge Neural TTS (
edge) — free, zero API key, native WebSocket +Sec-MS-GECclock-skew handling +WordBoundarytimings + in-processsymphoniaMP3→PCM decoding. - OpenAI & OpenAI-compatible (
openai) —gpt-4o-mini-tts(with deliveryinstructions),tts-1,tts-1-hd, streaming raw PCM, and custombase_urlfor local servers (Kokoro-FastAPI, Speaches, OpenedAI Speech). - ElevenLabs (
elevenlabs) — streaming 24 kHz PCM, native word timings (/with-timestamps), and live voice listing. - Google Gemini TTS (
gemini) —gemini-2.5-flash-preview-tts/pro-tts, natural-language deliveryinstructions, raw 24 kHz PCM, and 30 prebuilt voices (Kore,Puck,Fenrir, ...). - Cartesia Sonic (
cartesia) —sonic-3/sonic-2ultra-low-latency SSE PCM streaming + native word timestamps + live voice listing. - Deepgram Aura-2 (
deepgram) — low-latencylinear1624 kHz HTTP PCM streaming.
- Microsoft Edge Neural TTS (
- Explicit audio formats & timings: every
Audio/AudioChunkcarries{ sample_rate, channels },.duration(),.to_wav_bytes(),.convert_format(), andWordTiming+ WebVTT (.to_vtt()) export. - Pipelined
SpeechStream: prefetches upcoming sentences concurrently while playing strictly in order, with a smartSentenceSplitterthat preserves decimals (3.14), versions (v0.5.1), URLs, and abbreviations (Dr.,e.g.). - Content-addressed disk cache (
CachedProvider): SHA-256.wav+.timings.jsoncache for 0 ms / $0 repeated runs (ideal for scripted demo videos and tests). - Optional native playback (
playbackfeature): cross-platform speaker output viacpal(no PortAudio required).
Workspace
| Crate | Purpose |
|---|---|
crates/anyvoice |
Pure Rust core library |
crates/anyvoice-cli |
anyvoice CLI (synthesize, voices, optional speak) |
crates/anyvoice-node |
@phil65/anyvoice native Node.js / Bun bindings (napi-rs) |
crates/anyvoice-py |
anyvoice-rs async Python bindings (PyO3 + maturin) |
Quick Start
CLI
# Free Edge TTS -> WAV + WebVTT subtitles + JSON metadata
# List English voices
# OpenAI gpt-4o-mini-tts with style instructions + disk cache
OPENAI_API_KEY=...
Rust
use Arc;
use ;
async
TypeScript / Node.js (@phil65/anyvoice)
import { VoiceClient } from "@phil65/anyvoice";
const tts = VoiceClient.edge("en-US-EmmaMultilingualNeural").withCache(".cache/voice");
const audio = await tts.synthesize("FormCAD builds exact B-Rep solids in WebAssembly.");
console.log(audio.durationMs, audio.timings.length);
Python (anyvoice_rs)
=
= await
License
MIT