Skip to content

GlobalTechInfo/gspeak

gspeak

gspeak

Google Text to Speech for Node.js — modern, typed, zero deprecated dependencies.

A TypeScript rewrite of gtts — drop-in compatible.

License NPM Version Code Quality Downloads


✨ Features

  • 🔊 Convert any text to speech using Google TTS
  • 📦 Zero deprecated dependencies
  • 🔷 Full TypeScript support
  • 🔗 Drop-in replacement for gtts
  • 🌍 60+ languages supported
  • 💾 Save to file or stream directly
  • 🖥️ CLI included

📦 Installation

npm i gspeak

🚀 Quick Start

import { gSpeak } from 'gspeak'

const tts = new gSpeak('Hello world', 'en')
tts.save('/tmp/hello.mp3', (err) => {
  if (err) throw err
  console.log('Saved to /tmp/hello.mp3')
})

📥 Import

import { gSpeak } from 'gspeak'         // ESM ✅

const { gSpeak } = require('gspeak')     // CJS ✅

const gSpeak = require('gspeak').default // CJS ✅

📖 Usage

Save to file

import { gSpeak } from 'gspeak'

const tts = new gSpeak('Text to speak', 'en')
tts.save('/tmp/output.mp3', (err) => {
  if (err) throw err
  console.log('Done!')
})

Stream (e.g. with Express)

import express from 'express'
import { gSpeak } from 'gspeak'

const app = express()

app.get('/speak', (req, res) => {
  const tts = new gSpeak(req.query.text as string, req.query.lang as string)
  tts.stream().pipe(res)
})

app.listen(3000, () => {
  console.log('http://localhost:3000/speak?lang=en&text=Hello')
})

Debug mode

const tts = new gSpeak('Hello', 'en', true) // 3rd param enables debug logging

🖥️ CLI

npm install -g gspeak
gspeak "Hello Google Text to Speech" -l en -o /tmp/hello.mp3
Flag Alias Description
--language -l Language code (default: en)
--output -o Output file path (required)
--verbose -v Print debug messages

🌍 Supported Languages

Code Language
af Afrikaans
sq Albanian
ar Arabic
hy Armenian
ca Catalan
zh Chinese
zh-cn Chinese (Mandarin/China)
zh-tw Chinese (Mandarin/Taiwan)
zh-yue Chinese (Cantonese)
hr Croatian
cs Czech
da Danish
nl Dutch
en English
en-au English (Australia)
en-uk English (United Kingdom)
en-us English (United States)
eo Esperanto
fi Finnish
fr French
de German
el Greek
ht Haitian Creole
hi Hindi
hu Hungarian
is Icelandic
id Indonesian
it Italian
ja Japanese
ko Korean
la Latin
lv Latvian
mk Macedonian
no Norwegian
pl Polish
pt Portuguese
pt-br Portuguese (Brazil)
ro Romanian
ru Russian
sr Serbian
sk Slovak
es Spanish
es-es Spanish (Spain)
es-us Spanish (United States)
sw Swahili
sv Swedish
ta Tamil
th Thai
tr Turkish
vi Vietnamese
cy Welsh

🔄 Migrating from gtts

gspeak is a drop-in replacement. Just change the import:

// before
const gTTS = require('gtts')
const tts = new gTTS('Hello', 'en')

// after
const { gSpeak } = require('gspeak')
const tts = new gSpeak('Hello', 'en')

Same constructor, same .save(), same .stream() — nothing else changes.


📄 License

MIT © Qasim Ali


Made with ❤️ — Thanks for using gspeak!

About

Google Text to Speech for Node.js — modern, typed, zero deprecated dependencies.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors