Tauri Plugin TTS (Text-to-Speech)
Native Text-to-Speech plugin for Tauri 2.x applications. Provides cross-platform TTS functionality for desktop (Windows, macOS, Linux) and mobile (iOS, Android).
Features
- ๐ฃ๏ธ Speak text with customizable rate, pitch, and volume
- ๐ Multi-language support - Set language/locale for speech
- ๐๏ธ Voice selection - Get available voices and filter by language
- โน๏ธ Control playback - Stop speech and check speaking status
- ๐ฑ Cross-platform - Works on desktop and mobile
Installation
Rust
Add the plugin to your Cargo.toml:
[]
= { = "../tauri-plugin-tts" }
Register the plugin
In your src-tauri/src/lib.rs:
Permissions
Add permissions to your capabilities/default.json:
Usage
TypeScript/JavaScript
import { speak, stop, getVoices, isSpeaking } from "tauri-plugin-tts-api";
// Simple speech
await speak({ text: "Hello, world!" });
// With options
await speak({
text: "Olรก, mundo!",
language: "pt-BR",
rate: 0.8, // 0.5 to 2.0
pitch: 1.2, // 0.5 to 2.0
volume: 1.0, // 0.0 to 1.0
});
// Stop speaking
await stop();
// Get all voices
const voices = await getVoices();
// Get voices for a specific language
const englishVoices = await getVoices("en");
// Check if speaking
const speaking = await isSpeaking();
Rust
use TtsExt;
// In a command or setup
Platform Support
| Platform | Status |
|---|---|
| Windows | โ Full support (SAPI) |
| macOS | โ Full support (AVSpeechSynthesizer) |
| Linux | โ Full support (speech-dispatcher) |
| iOS | โ Full support (AVSpeechSynthesizer) |
| Android | โ Full support (TextToSpeech) |
API Reference
speak(options: SpeakOptions): Promise<void>
Speak the given text.
Options:
text(required): The text to speaklanguage: Language/locale code (e.g., "en-US", "pt-BR")voiceId: Specific voice ID fromgetVoices()(takes priority overlanguage)rate: Speech rate (0.25 = quarter, 0.5 = half, 1.0 = normal, 2.0 = double)pitch: Voice pitch (0.5 = low, 1.0 = normal, 2.0 = high)volume: Volume level (0.0 = silent, 1.0 = full)
stop(): Promise<void>
Stop any ongoing speech immediately.
getVoices(language?: string): Promise<Voice[]>
Get available voices, optionally filtered by language.
isSpeaking(): Promise<boolean>
Check if TTS is currently speaking.
License
MIT