npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tauri-plugin-tts-api

v0.1.2

Published

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

Readme

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
  • 🎬 Preview voices - Test voices before using them
  • 📝 Queue mode - Interrupt or queue speech requests
  • ⏸️ Pause/Resume - Control playback on iOS (platform-specific)
  • 📱 Cross-platform - Works on desktop and mobile

Installation

Rust

Add the plugin to your Cargo.toml:

[dependencies]
tauri-plugin-tts = "0.1"

TypeScript

Install the JavaScript guest bindings:

npm install tauri-plugin-tts-api
# or
yarn add tauri-plugin-tts-api
# or
pnpm add tauri-plugin-tts-api

Setup

Register Plugin

In your Tauri app setup:

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

Permissions

Add permissions to your capabilities/default.json:

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

For granular permissions, you can specify individual commands:

{
  "permissions": [
    "tts:allow-speak",
    "tts:allow-stop",
    "tts:allow-get-voices",
    "tts:allow-is-speaking",
    "tts:allow-preview-voice",
    "tts:allow-pause-speaking",
    "tts:allow-resume-speaking"
  ]
}

Usage

Basic Examples

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.1 to 4.0 (1.0 = normal)
  pitch: 1.2, // 0.5 to 2.0 (1.0 = normal)
  volume: 1.0, // 0.0 to 1.0 (1.0 = full)
});

// 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();

Advanced Features

Queue Mode

Control how new speech requests interact with ongoing speech:

// Default: interrupt current speech (flush)
await speak({ text: "First sentence" });
await speak({ text: "Second sentence" }); // Interrupts first

// Queue mode: add to queue
await speak({ text: "First sentence" });
await speak({ text: "Second sentence", queueMode: "add" }); // Waits for first

Voice Preview

Preview voices before selecting them:

import { getVoices, previewVoice } from "tauri-plugin-tts-api";

// Get available voices
const voices = await getVoices("en");

// Preview a voice with default text
await previewVoice({ voiceId: voices[0].id });

// Preview with custom text
await previewVoice({
  voiceId: voices[0].id,
  text: "This is how I sound!",
});

Pause and Resume (iOS only)

import { speak, pauseSpeaking, resumeSpeaking } from "tauri-plugin-tts-api";

await speak({ text: "Long text to speak..." });

// Pause (iOS only)
const pauseResult = await pauseSpeaking();
if (pauseResult.success) {
  console.log("Speech paused");

  // Resume later
  const resumeResult = await resumeSpeaking();
  if (resumeResult.success) {
    console.log("Speech resumed");
  }
} else {
  console.log("Pause not supported:", pauseResult.reason);
}

Platform Support

| Platform | Status | Engine | | -------- | ------------------------------ | ------------------- | | Windows | ✅ Full support | SAPI | | macOS | ✅ Full support | AVSpeechSynthesizer | | Linux | ✅ Full support | speech-dispatcher | | iOS | ✅ Full support + pause/resume | AVSpeechSynthesizer | | Android | ✅ Full support | TextToSpeech |

Feature Support Matrix

| Feature | Windows | macOS | Linux | iOS | Android | | ------------------ | ------- | ----- | ----- | --- | ------- | | speak() | ✅ | ✅ | ✅ | ✅ | ✅ | | stop() | ✅ | ✅ | ✅ | ✅ | ✅ | | getVoices() | ✅ | ✅ | ✅ | ✅ | ✅ | | isSpeaking() | ✅ | ✅ | ✅ | ✅ | ✅ | | previewVoice() | ✅ | ✅ | ✅ | ✅ | ✅ | | queueMode | ✅ | ✅ | ✅ | ✅ | ✅ | | pauseSpeaking() | ❌ | ❌ | ❌ | ✅ | ❌ | | resumeSpeaking() | ❌ | ❌ | ❌ | ✅ | ❌ |

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.1 to 4.0, where 1.0 = normal speed, 2.0 = double, 0.5 = half)
  • pitch: Voice pitch (0.5 to 2.0, where 1.0 = normal, 2.0 = high, 0.5 = low)
  • volume: Volume level (0.0 to 1.0, where 0.0 = silent, 1.0 = full)
  • queueMode: "flush" (default, interrupts current speech) or "add" (queues after current)

stop(): Promise<void>

Stop any ongoing speech immediately.

getVoices(language?: string): Promise<Voice[]>

Get available voices, optionally filtered by language.

Returns: Array of Voice objects with:

  • id: Unique voice identifier
  • name: Display name
  • language: Language code (e.g., "en-US")

isSpeaking(): Promise<boolean>

Check if TTS is currently speaking.

previewVoice(options: PreviewVoiceOptions): Promise<void>

Preview a voice with sample text.

Options:

  • voiceId (required): Voice ID to preview
  • text: Optional custom preview text (uses default if not provided)

pauseSpeaking(): Promise<PauseResumeResponse> (iOS only)

Pause the current speech.

Returns:

  • success: Whether pause succeeded
  • reason: Optional failure reason (e.g., "Not supported on this platform")

resumeSpeaking(): Promise<PauseResumeResponse> (iOS only)

Resume paused speech.

Returns: Same as pauseSpeaking()

Troubleshooting

Linux: "No TTS backend available"

Solution: Install speech-dispatcher:

# Debian/Ubuntu
sudo apt-get install speech-dispatcher

# Fedora
sudo dnf install speech-dispatcher

# Arch
sudo pacman -S speech-dispatcher

Android: No voices available

Solution: Ensure a TTS engine is installed:

  1. Open Android Settings → Accessibility → Text-to-Speech
  2. Install "Google Text-to-Speech" from Play Store if missing
  3. Download language data for your desired languages

iOS: Voices sound robotic

Solution: Download enhanced voices:

  1. Open iOS Settings → Accessibility → Spoken Content → Voices
  2. Select your language and download "Enhanced Quality" voices

Rate/Pitch not working as expected

Note: Platform engines may have different interpretations:

  • Windows SAPI: Limited pitch control
  • Linux: Depends on speech-dispatcher backend
  • Mobile: Full support for rate and pitch

Pause/Resume not working

Note: pauseSpeaking() and resumeSpeaking() are only supported on iOS. Other platforms will return { success: false, reason: "Not supported" }.

Examples

See the examples/tts-example directory for a complete working demo with React + Material UI.

Building

# Build Rust
cargo build

# Build TypeScript
npm run build

# Run tests
cargo test

License

MIT