Skip to main content

Built and signed on GitHub Actions

Use Microsoft Edge's online text-to-speech service from JS code directly!

This package works with Deno, BunIt is unknown whether this package works with Cloudflare Workers, Node.js, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
This package works with Bun
It is unknown whether this package works with Browsers
JSR Score
100%
Published
a month ago (0.0.7)

edge-tts is a package that allows you to use Microsoft Edge's online text-to-speech service from within your JS code. Zero dependencies and you can use it anywhere! (Server runtime/Browser)

Heavily inspired by rany2/edge-tts and SchneeHertz/node-edge-tts

// Web
const { audio, subtitle } = await generate({
  text: "Hello, world!",
  voice: "en-US-JennyNeural",
  language: "en-US",
});

// Create an audio element and play the generated audio
const audioElement = new Audio(URL.createObjectURL(audio));
audioElement.play();

// Access subtitle data
console.log(subtitle);
// Node.js
const { audio, subtitle } = await generate({
  text: "Hello, world!",
  voice: "en-US-JennyNeural",
  language: "en-US",
});

// Save the audio Blob to a file
const fs = require('fs');
const buffer = Buffer.from(await audio.arrayBuffer());
fs.writeFileSync('output.mp3', buffer);

// Access subtitle data
console.log(subtitle);
// Deno
import { generate } from './yourModule.ts';
const { audio, subtitle } = await generate({
  text: "Hello, world!",
  voice: "en-US-JennyNeural",
  language: "en-US",
});

// Save the audio Blob to a file
const bytes = await audio.bytes()
await Deno.writeFile('output.mp3', bytes);

// Access subtitle data
console.log(subtitle);
Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@ericc/edge-tts

Import symbol

import * as mod from "@ericc/edge-tts";

---- OR ----

Import directly with a jsr specifier

import * as mod from "jsr:@ericc/edge-tts";

Add Package

npx jsr add @ericc/edge-tts

Import symbol

import * as mod from "@ericc/edge-tts";

Add Package

yarn dlx jsr add @ericc/edge-tts

Import symbol

import * as mod from "@ericc/edge-tts";

Add Package

pnpm dlx jsr add @ericc/edge-tts

Import symbol

import * as mod from "@ericc/edge-tts";

Add Package

bunx jsr add @ericc/edge-tts

Import symbol

import * as mod from "@ericc/edge-tts";