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

plapre-in-a-browser

v0.1.0

Published

Open-source Danish text-to-speech (Plapre) running fully in the browser on onnxruntime-web (WebGPU + WASM). Provider-neutral engine with drop-in OpenAI and ElevenLabs adapters, plus local voice cloning.

Downloads

180

Readme

plapre-in-a-browser

Open-source Danish text-to-speech (Plapre) running fully in the browser — no server, no cloud, no API key. Inference runs on onnxruntime-web (WebGPU, with a WASM fallback).

It ships a provider-neutral engine plus thin drop-in adapters for the OpenAI (audio.speech) and ElevenLabs (text-to-speech) APIs, and supports local voice cloning from a reference clip.

Full project (model conversion toolchain, architecture, phased plan): https://github.com/elgehelge/plapre-in-a-browser

Install

npm install plapre-in-a-browser

onnxruntime-web, @huggingface/transformers, and @breezystack/lamejs are installed as dependencies and left external in the bundle, so your bundler controls and dedupes them.

Model artifacts

The library is code only — the converted ONNX models (~0.5 GB) are not bundled. You host them yourself and point the engine at them with modelsBaseUrl (default /models, i.e. served next to your app).

Get the artifacts one of three ways:

  • Fetch from Hugging Face (easiest). A prebuilt set is hosted at elgehelge/plapre-onnx-web with CORS-enabled per-file access:

    const engine = await loadPlapreEngine({
      modelsBaseUrl: "https://huggingface.co/elgehelge/plapre-onnx-web/resolve/main",
    });
  • Download a bundle from GitHub Releases and serve its contents (preserving the directory layout) from your modelsBaseUrl.

  • Produce them yourself with the Python conversion toolchain (conversion/). The Plapre language-model weights are license-gated on Hugging Face; the decoder, vocoder, and clone encoder are public.

Probe what's reachable before loading:

import { setModelsBaseUrl, reportArtifacts } from "plapre-in-a-browser";

setModelsBaseUrl("https://huggingface.co/elgehelge/plapre-onnx-web/resolve/main");
console.log(await reportArtifacts()); // { lm: true, kanadeDecoder: true, ... }

Quickstart

import { loadPlapreEngine } from "plapre-in-a-browser";

const engine = await loadPlapreEngine({
  backend: "webgpu",                 // falls back to "wasm" automatically
  modelsBaseUrl: "/models",          // where you host the artifacts
  cache: { onProgress: (loaded, total) => console.log(loaded / total) },
});

const { samples, sampleRate } = await engine.synthesizeToPcm({
  text: "Hej, hvordan har du det i dag?",
  voice: "ida",                      // tor | ida | liv | ask | kaj
});

// `samples` is mono Float32Array @ 24 kHz — play it however you like.

Stream sentence-by-sentence instead of buffering:

for await (const chunk of engine.synthesize({ text, voice: "tor" })) {
  // chunk.samples (Float32Array), chunk.sampleRate (24000), chunk.startSec
}

listVoices(), an AbortSignal (request.signal), pitch-preserving playback speed (request.rate), and sampling knobs (request.generation) are all supported. See docs/INTERFACE.md.

Drop-in API adapters

Swap a hosted TTS API for local inference with the same request shapes:

import { loadPlapreEngine, createOpenAISpeech, createElevenLabsClient } from "plapre-in-a-browser";

const engine = await loadPlapreEngine();

// OpenAI: mirrors `openai.audio.speech.create(...)`, returns a web Response.
const openai = createOpenAISpeech(engine);
const res = await openai.create({ model: "tts-1", input: "Hej!", voice: "alloy" });
const mp3 = await res.arrayBuffer();

// ElevenLabs: mirrors `client.textToSpeech.convert(voiceId, {...})`.
const eleven = createElevenLabsClient(engine);
const audio = await (await eleven.textToSpeech.convert("ida", { text: "Hej!" })).arrayBuffer();

Each adapter returns a standard Response and defaults to its provider's own default format (OpenAI mp3, ElevenLabs mp3_44100_128), so existing call sites (await res.arrayBuffer() / streaming via res.body) work unchanged. MP3 is encoded in pure JS; raw pcm passes through unencoded.

Voice cloning (local)

if (engine.canCloneVoice()) {
  const voice = await engine.cloneVoice(referenceSamples, 24000, { displayName: "My voice" });
  const out = await engine.synthesizeToPcm({ text: "Hej fra min klonede stemme.", voice: voice.id });
}

The reference audio never leaves the browser. The ElevenLabs adapter maps voices.add({ name, files }) onto this.

Cross-origin isolation

Threaded WASM (the fallback backend) needs SharedArrayBuffer, which requires your page to be cross-origin isolated. Serve it with:

Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp

WebGPU does not require this, but the WASM fallback does. In a Chrome MV3 extension, mirror these in the manifest (see docs/EXTENSION.md).

License

CC BY 4.0, matching upstream Plapre. See NOTICE for attribution of all incorporated works.