@diffusionstudio/vits-web

中文文档
1.0.3发布于 2024/09/09MITTypeScriptES Module近 30 天下载 2.6万

Web api for using VITS based models in the browser!

原始使用文档

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 :)

版本与发布记录

@diffusionstudio/vits-web 共发布 4 个版本,首次发布于 2024/07/06;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.3latest2024/09/092 年前
1.0.22024/07/082 年前
1.0.12024/07/082 年前
1.0.02024/07/062 年前

关于 @diffusionstudio/vits-web 的常见问题

@diffusionstudio/vits-web 是什么?

Web api for using VITS based models in the browser!

如何安装 @diffusionstudio/vits-web?

在项目目录运行 npm install @diffusionstudio/vits-web,或使用 pnpm add / yarn add / bun add。

@diffusionstudio/vits-web 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@diffusionstudio/vits-web 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@diffusionstudio/vits-web 可以商用吗?

@diffusionstudio/vits-web 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@diffusionstudio/vits-web 的下载量有多少?

根据 npm 官方下载统计,@diffusionstudio/vits-web 在 2026/10/12 – 2026/11/10 这 30 天内被下载 26,295 次,日均约 877 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@diffusionstudio/vits-web 还在维护吗?

最新版本 1.0.3 发布于 2024/09/09(2 年前);至今共发布 4 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/07/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。