MCPcopy Index your code
hub / github.com/diffusionstudio/vits-web

github.com/diffusionstudio/vits-web @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
233 symbols 370 edges 19 files 1 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Maintenance Website shields.io Discord GitHub license TypeScript

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

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.

Usage

First of all, you need to install the library:

npm i @diffusionstudio/vits-web

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

import * as tts from '@diffusionstudio/vits-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

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

That's it! Happy coding :)

Core symbols most depended-on inside this repo

leadingNulls
called by 11
src/piper.js
abort
called by 9
src/piper.js
UTF8ArrayToString
called by 6
src/piper.js
UTF8ToString
called by 6
src/piper.js
removeRunDependency
called by 4
src/piper.js
isFileURI
called by 4
src/piper.js
callRuntimeCallbacks
called by 4
src/piper.js
intArrayFromString
called by 4
src/piper.js

Shape

Function 233

Languages

TypeScript100%

Modules by API surface

src/piper.js218 symbols
src/storage.ts4 symbols
src/opfs.ts3 symbols
src/inference.ts2 symbols
src/voices.ts1 symbols
src/storage.spec.ts1 symbols
src/inference.spec.ts1 symbols
src/http.ts1 symbols
src/audio.ts1 symbols
example/worker.ts1 symbols

For agents

$ claude mcp add vits-web \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact