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

edge-tts-ts

v1.0.0

Published

Use Microsoft Edge's online text-to-speech service from JavaScript (Node.js/Browser) WITHOUT needing Microsoft Edge or Windows or an API key.

Readme

edge-tts-ts

A TypeScript port of the edge-tts Python module.

This module allows you to use Microsoft Edge's online text-to-speech service from within your JavaScript/TypeScript code or using the provided edge-tts or edge-playback command.

Features

  • Browser & Node.js Compatible: The core logic is written to work in both environments.
  • WebSocket Communication: Efficient streaming of audio and metadata.
  • Subtitles Support: Generates SRT subtitles from WordBoundary/SentenceBoundary events.
  • CLI Tools: Command-line interfaces for synthesis and playback.

Installation

pnpm add edge-tts-ts
# or
npm install edge-tts-ts

CDN Usage (Vanilla JS / Browser)

You can use the library directly in the browser via ESM-friendly CDNs like esm.sh:

<script type="module">
  import { Communicate } from "https://esm.sh/edge-tts-ts";

  const comm = new Communicate("Hello from the CDN!", {
    voice: "en-US-EmmaMultilingualNeural"
  });

  for await (const chunk of comm.stream()) {
    if (chunk.type === "audio") {
      // Use the audio chunk
    }
  }
</script>

Usage

CLI

# List available voices
edge-tts --list-voices

# Synthesize text to MP3 and SRT
edge-tts --text "Hello, world!" --write-media hello.mp3 --write-subtitles hello.srt

# Playback immediately (requires sound-play on Node)
edge-playback --text "Hello, world!"

Library (Node.js & Browser)

import { Communicate } from "edge-tts-ts";

const comm = new Communicate("Hello world", {
	voice: "en-US-EmmaMultilingualNeural",
});

for await (const chunk of comm.stream()) {
	if (chunk.type === "audio") {
		// chunk.data is a Uint8Array
		console.log("Received audio chunk of size:", chunk.data.length);
	} else {
		// chunk.type is "WordBoundary" or "SentenceBoundary"
		console.log("Boundary:", chunk.text, "at", chunk.offset);
	}
}

Browser Example

In the browser, you can use the Communicate class directly. You might need to handle the audio chunks and play them using the Web Audio API or by creating a Blob and using an Audio element.

const chunks = [];
for await (const chunk of comm.stream()) {
	if (chunk.type === "audio") {
		chunks.push(chunk.data);
	}
}
const blob = new Blob(chunks, { type: "audio/mpeg" });
const url = URL.createObjectURL(blob);
const audio = new Audio(url);
audio.play();

Examples

There are two examples provided in the examples directory:

Node.js (CLI & Script)

Located in examples/nodejs. You can test the CLI functionality using the provided scripts:

  • Bash: bash test-cli.sh
  • PowerShell: powershell ./test-cli.ps1

These scripts will build the project and run various CLI commands to demonstrate synthesis and playback.

Browser (React + Tailwind)

Located in examples/browser. This is a tiny React application that demonstrates how to use the library in a browser environment. To run it:

cd examples/browser
pnpm install
pnpm dev

The app allows you to enter text, select a voice, and adjust rate/volume/pitch directly from your browser.

Differences from Python Version

  • No SSML Removal: This port follows the same rules as the Python version regarding SSML (it uses the same format).
  • Playback: Uses sound-play on Node for cross-platform playback, or native APIs in the browser.
  • isomorphic-ws: Uses isomorphic-ws to support both Node and Browser WebSockets.

Development

pnpm install
pnpm build
pnpm test

License

MIT