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

@realtimex/piper-tts-web

v1.1.1

Published

Fork of @diffusion-studio/vits-web for easier built-in PiperTTS use.

Downloads

302

Readme

This is a fork of @Mintplex-Labs/piper-tts-web/ for use of PiperTTS modules inside of a browser/Electron for RealTimeX.ai. A big shout-out goes to Rhasspy Piper, who open-sourced all the currently available models (MIT License) and to @jozefchutka who came up with the wasm build steps.

This fork includes upgrades to ONNX Runtime 1.22.0 and enhanced offline support.

Run PiperTTS based text-to-speech in the browser powered by ONNX Runtime 1.22.0

Difference from the original

Caching for client

You can leverage TTSSessions for a faster inference. (see index.js for implementation) Credit to this PR for the starting point.

Local WASM/Loading

You can define local WASM paths for the ort wasm as well as the phenomizer wasm and data file for faster local loading since the client could be offline.

Note:

This is a frontend library and will not work with NodeJS.

Usage

First of all, you need to install the library:

yarn add @therealtimex/piper-tts-web

Then you're able to import the library like this (ES only)

import * as tts from '@realtimex/piper-tts-web';

Now you can start synthesizing speech!

const wav = await tts.predict({
  text: "Text to speech in the browser is amazing!",
  voiceId: 'en_US-hfc_female-medium',
});

const audio = new Audio();
audio.src = URL.createObjectURL(wav);
audio.play();

// as seen in /example with Web Worker

Advanced Configuration

TTS Session Options

For more control over the TTS session, you can use the TtsSession class directly:

import { TtsSession } from '@realtimex/piper-tts-web';

const session = new TtsSession({
  voiceId: 'en_US-hfc_female-medium',
  allowLocalModels: true, // Allow loading local models (default: true)
  fallbackStrategy: 'auto', // 'cdn', 'local', or 'auto' (default: 'cdn')
  wasmPaths: {
    onnxWasm: '/custom/path/to/onnx/',
    piperData: '/custom/path/to/piper_phonemize.data',
    piperWasm: '/custom/path/to/piper_phonemize.wasm'
  },
  progress: (progress) => {
    console.log(`Loading: ${Math.round(progress.loaded * 100 / progress.total)}%`);
  },
  logger: (message) => {
    console.log(`TTS: ${message}`);
  }
});

const wav = await session.predict('Hello, world!');

Configuration Options

  • allowLocalModels: Enable/disable local model loading (default: true)
  • fallbackStrategy: How to handle CDN failures:
    • 'cdn': Only use CDN (original behavior)
    • 'local': Only use local paths
    • 'auto': Try CDN first, fallback to local on failure
  • wasmPaths: Custom paths for WASM files
  • progress: Callback for download progress
  • logger: Callback for debug messages

Offline Support

This version includes enhanced offline support:

  1. Automatic fallback: When fallbackStrategy: 'auto' is used, the library will automatically fallback to local WASM files if CDN is unreachable
  2. Retry logic: Failed downloads are automatically retried with exponential backoff
  3. Better error messages: More descriptive error messages help diagnose issues

Migration from @mintplex-labs/piper-tts-web

  1. Update your package.json:
{
  "dependencies": {
    "@therealtimex/piper-tts-web": "^1.1.0"
  }
}
  1. Update imports:
// Old
import * as tts from '@mintplex-labs/piper-tts-web';

// New
import * as tts from '@realtimex/piper-tts-web';
  1. Optionally configure new options:
const session = new TtsSession({
  voiceId: 'en_US-hfc_female-medium',
  allowLocalModels: true, // Now configurable!
  fallbackStrategy: 'auto' // Enhanced offline support
});

With the initial run of the predict function you will download the model which will then be stored in your Origin private file system. You can also do this manually in advance (recommended), as follows:

await tts.download('en_US-hfc_female-medium', (progress) => {
  console.log(`Downloading ${progress.url} - ${Math.round(progress.loaded * 100 / progress.total)}%`);
});

The predict function also accepts a download progress callback as the second argument (tts.predict(..., console.log)).

If you want to know which models have already been stored, do the following

console.log(await tts.stored());

// will log ['en_US-hfc_female-medium']

You can remove models from opfs by calling

await tts.remove('en_US-hfc_female-medium');

// alternatively delete all

await tts.flush();

And last but not least use this snippet if you would like to retrieve all available voices:

console.log(await tts.voices());

// Hint: the key can be used as voiceId

What's New in v1.1.0

  • ONNX Runtime 1.22.0: Updated to the latest version
  • Configurable allowLocalModels: No more hardcoded restrictions
  • Enhanced offline support: Automatic CDN fallback strategies
  • Better error handling: Retry logic and descriptive error messages
  • Improved logging: Optional debug logging for troubleshooting

That's it! Happy coding :)