edge-tts
v1.0.1
Published
Use Microsoft Edge's online text-to-speech service from JavaScript WITHOUT needing Microsoft Edge or Windows or an API key
Downloads
492
Readme
edge-tts
edge-tts
is a allows you to use Microsoft Edge's online text-to-speech service from within your TypeScript code.
Based on edge-tts for python.
Usage
import { tts, ttsSave } from 'edge-tts'
// buffer of mp3 data
const audioBuffer = await tts('hello world')
// or if you just want a file
await ttsSave('hello world', './tts.mp3')
// customize voice
await tts('hello world', {
voice: 'es-VE-PaolaNeural', // can be any Voice.Name, Voice.ShortName, or Voice.FriendlyName
volume: '+50%', // 50% louder
rate: '-50%', // 50% the speed
pitch: '-50Hz' // 50Hz lower
})
Find voices to use for the voice
param using getVoices
import { getVoices, tts } from 'edge-tts'
// get list of available voices
const voices = await getVoices()
// get voices done by native english speakers
const englishVoices = voices.filter(v => v.Locale === 'en-US')
// select a random english voice
const voice = englishVoices[Math.floor(Math.random() * englishVoices.length)]
// can also use voice.ShortName, or voice.FriendlyName
const audioBuffer = await tts('hello world', { voice: voice.Name })