@the-vedantic-coder/piper-tts-web
v1.0.10
Published
Fork of @mintplex-labs/piper-tts-web for easier built-in PiperTTS use.
Maintainers
Readme
UPDATE: 2026-01-24: This repository is no longer actively maintained and deprecated. NavGurukul Foundation for Social Welfare holds the rights to this repository. For the latest updates and versions, please refer to NavGurukul's GitHub repository.
This is a fork of @mintplex-labs/piper-tts-web for use of PiperTTS modules inside of a browser. A big shout-out goes to OHF Piper1, who open-sourced all the currently available models. The updated fork is present in Vinit-source/piper1-gpl.
This repository uses
en_IN-spicor-mediumvoice which was trained using theen_US-ljspeech-mediumvoice for 89 epochs on the IISc's SPICOR English dataset. More details about the dataset can be found here
Run PiperTTS based text-to-speech in the browser powered by the ONNX Runtime
Difference from the original
- Includes an Indian English voice
en_IN-spicor-mediumby default. - Works well with all the other voices from the original repository.
Caching for client
You can leverage TTSSessions for a faster inference. (see index.js for implementation)
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:
npm install @the-vedantic-coder/piper-tts-webThen you're able to import the library like this (ES only)
import * as tts from '@the-vedantic-coder/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_IN-spicor-medium',
});
const audio = new Audio();
audio.src = URL.createObjectURL(wav);
audio.play();
// as seen in /example with Web WorkerWith 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_IN-spicor-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_IN-spicor-medium']You can remove models from opfs by calling
await tts.remove('en_IN-spicor-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