tauri-plugin-tts 0.1.1

Native text-to-speech plugin for Tauri with multi-language and voice selection
Documentation

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:

[dependencies]
tauri-plugin-tts = { path = "../tauri-plugin-tts" }

Register the plugin

In your src-tauri/src/lib.rs:

pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_tts::init())
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Permissions

Add permissions to your capabilities/default.json:

{
  "permissions": ["tts:default"]
}

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 tauri_plugin_tts::TtsExt;

// In a command or setup
fn my_command(app: tauri::AppHandle) {
    let tts = app.tts();

    tts.speak(SpeakRequest {
        text: "Hello!".into(),
        language: Some("en-US".into()),
        rate: 1.0,
        pitch: 1.0,
        volume: 1.0,
    }).unwrap();
}

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 speak
  • language: Language/locale code (e.g., "en-US", "pt-BR")
  • voiceId: Specific voice ID from getVoices() (takes priority over language)
  • 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