To use the library, you can either create a Tts instance with a specific backend or use the default() method to select the most appropriate backend for the current platform.
Supported backends include:
- Windows:
Nvda, Tolk (requires tolk feature), or WinRt. - Linux:
Orca or SpeechDispatcher. - macOS/iOS/etc:
AvFoundation. - Android:
Android (requires minSdkVersion 26+). - WebAssembly:
Web.
Use Tts::backends() to get a list of all available backends on the current platform, ordered by preference.
use tts::{Tts, Backends};
// Option 1: Use the platform default
let tts = Tts::default().expect("Failed to initialize default TTS");
// Option 2: Specify a specific backend
#[cfg(target_os = "linux")]
let tts = Tts::new(Backends::SpeechDispatcher).expect("Failed to initialize SpeechDispatcher");