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

tts-in-1-line

v1.0.0

Published

The fastest way to convert text to speech in JavaScript. 1 line = instant audio. No setup, no API key.

Readme

tts-in-1-line

The Easiest Text-to-Speech Library for JavaScript (1 Line)

npm version npm downloads License: MIT

🔥 No API key. No config. No setup. Just one line of JavaScript — instant audio.


⚡ Install & speak in 10 seconds

npm install tts-in-1-line
import { speak } from 'tts-in-1-line'

await speak('Hello world')

That's it. Your speakers will play the audio immediately.


🎧 Features

  • Zero setup — no API key, no account, works out of the box
  • Cross-platform — macOS, Windows, Linux
  • ESM + CommonJS — works with import and require
  • Save to file — export as .mp3 for any use case
  • Multiple voices — female, male, US, UK, Australian accents
  • Long text — auto-chunks long text for smooth playback
  • Node.js 18+ — no native addons, no binary installs

🧠 API

speak(text, options?)

| Option | Type | Default | Description | |--------|------|---------|-------------| | voice | string | 'female' | Voice preset (see below) | | save | string \| null | null | File path to save MP3. If set, skips playback. |

Returns: Promise<string> — path to the audio file


Voice presets

| Preset | Accent | |--------|--------| | 'female' | British English female (default) | | 'male' | British English male | | 'female-us' | US English female | | 'male-us' | US English male | | 'female-uk' | UK English female | | 'female-au' | Australian English female | | 'male-au' | Australian English male |

You can also pass any StreamElements voice name directly (e.g. 'Joanna', 'Matthew', 'Brian').


📖 Examples

Play immediately

import { speak } from 'tts-in-1-line'

await speak('Hello world')

Choose a voice

await speak('Hello from the US!', { voice: 'female-us' })
await speak('G\'day mate!', { voice: 'female-au' })
await speak('Good morning.', { voice: 'male' })

Save to MP3

const filePath = await speak('This will be saved, not played.', {
  save: './output.mp3'
})

console.log('Saved to:', filePath)

CommonJS (require)

const { speak } = require('tts-in-1-line')

await speak('Works with require too!')

Long text (auto-chunked)

await speak(`
  Text to speech has never been this simple in JavaScript.
  No configuration files. No API keys to manage.
  Just install the package and speak.
`)

🖥️ Platform requirements

| Platform | Requirement | |----------|------------| | macOS | Nothing — afplay is built-in | | Windows | Nothing — Windows Media Player COM is built-in | | Linux | mpg123 (auto-detected), or mplayer, ffmpeg, or vlc |

Install on Linux if needed:

sudo apt install mpg123   # Ubuntu/Debian
sudo dnf install mpg123   # Fedora
sudo pacman -S mpg123     # Arch

🧩 Why tts-in-1-line?

Every other TTS library for JavaScript requires you to:

  • Sign up for an API key
  • Read through pages of documentation
  • Configure auth credentials
  • Handle audio playback yourself

tts-in-1-line does all of that for you. Install it, call speak(), done.


🚀 Want higher quality voices?

This package uses free voices by default. For ultra-realistic, studio-quality speech synthesis — including voice cloning, emotions, and custom voices — check out Vocallab.ai.


📦 Related keywords

text to speech npm · javascript text to speech · tts nodejs simple · node tts · speak npm · audio synthesis javascript · nodejs speak text · tts without api key


License

MIT