Expand description
§rust-tts-wrapper
Cross-platform TTS (Text-to-Speech) wrapper with a C ABI.
Mirrors js-tts-wrapper and SwiftTTSWrapper, supporting 21 engines:
system (speech-dispatcher), Sherpa-ONNX (191 local models), and 19 cloud providers.
§Quick start (C)
tts_ctx* ctx = tts_create("system", NULL);
tts_speak(ctx, "Hello world");
tts_destroy(ctx);Modules§
- engine
- Core TTS engine trait.
- factory
- Engine factory: create engines by ID and list all registered engines.
- types
- Shared types used across the crate.
Structs§
Functions§
- tts_
create - Create a new TTS engine instance.
- tts_
destroy - Destroy a TTS context and free all associated resources.
- tts_
free_ bytes - Free a byte buffer returned by
tts_synth_to_bytes. - tts_
free_ engine_ info - Free an engine info array previously returned by
tts_get_engines. - tts_
free_ voices - Free a voice array previously returned by
tts_get_voices. - tts_
get_ engine_ count - Return the number of registered engines.
- tts_
get_ engines - Write engine descriptors into a caller-allocated array.
- tts_
get_ last_ error - Return the last error message as a C string, or null if none.
- tts_
get_ voices - Retrieve the list of available voices for the engine.
- tts_
pause - Pause in-progress speech.
- tts_
resume - Resume paused speech.
- tts_
set_ on_ audio - Set the callback for streaming audio chunks.
- tts_
set_ on_ boundary - Set the callback for word boundary events.
- tts_
set_ pitch - Set the speech pitch (1.0 = normal).
- tts_
set_ rate - Set the speech rate (1.0 = normal).
- tts_
set_ voice - Set the voice for subsequent speak calls.
- tts_
set_ volume - Set the speech volume (1.0 = normal).
- tts_
speak - Speak
textasynchronously using the engine inctx. - tts_
speak_ sync - Speak
textsynchronously (blocks until complete). - tts_
stop - Stop any in-progress speech.
- tts_
synth_ to_ bytes - Synthesize text to audio bytes without playback.
Writes a heap-allocated buffer to
*out_bytesand its length to*out_len. Caller must free withtts_free_bytes. Returns 0 on success, -1 on failure.
Type Aliases§
- CAudio
Cb - Opaque context holding an engine instance and its per-instance settings.
- CBoundary
Cb