
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
@sefinek/google-tts-api
Advanced tools
Google TTS (Text-To-Speech) for Node.js without any vulnerabilities. For free without any API keys!
Google TTS (Text-To-Speech) for Node.js. For free without any API keys!
This is a fork of zlargon/google-tts with updated dependencies (the old versions had vulnerabilities).
$ npm install --save google-tts-api
$ npm install -D typescript @types/node # Only for TypeScript
Method | Options (all optional) | Return Type | Handle Long Text |
---|---|---|---|
getAudioUrl | lang , slow , host | string | |
getAudioBase64 | lang , slow , host , timeout | Promise<string> | |
getAllAudioUrls | lang , slow , host , splitPunct | { shortText: string; url: string; }[] | ✅ |
getAllAudioBase64 | lang , slow , host , timeout , splitPunct | Promise<{ shortText: string; base64: string; }[]> | ✅ |
Option | Type | Default | Description |
---|---|---|---|
lang | string | en | See all available language code at https://cloud.google.com/speech/docs/languages |
slow | boolean | false | Use the slow audio speed if set slow to true |
host | string | https://translate.google.com | You can change the host if the default host could not work in your region (e.g. https://translate.google.com.cn). |
timeout | number | 10000 (ms) | (Only for getAudioBase64 and getAllAudioBase64 ) Set timeout for the HTTP request. |
splitPunct | string | (Only for getAllAudioUrls and getAllAudioBase64 ) Set the punctuation to split the long text to short text. (e.g. ",、。") |
getAudioUrl(text, [option])
import * as googleTTS from '@sefinek/google-tts-api'; // ES6 or TypeScript
const googleTTS = require('@sefinek/google-tts-api'); // CommonJS
// Get audio URL
const url = googleTTS.getAudioUrl('Hello world!', {
lang: 'en',
slow: false,
host: 'https://translate.google.com',
});
console.log(url); // https://translate.google.com/translate_tts?...
getAudioBase64(text, [option])
import * as googleTTS from '@sefinek/google-tts-api'; // ES6 or TypeScript
const googleTTS = require('@sefinek/google-tts-api'); // CommonJS
// Get base64 text
googleTTS
.getAudioBase64('Hello world!', {
lang: 'en',
slow: false,
host: 'https://translate.google.com',
timeout: 10000,
})
.then(console.log) // base64 text
.catch(console.error);
getAllAudioUrls(text, [option])
(For text longer than 200 characters)import * as googleTTS from '@sefinek/google-tts-api'; // ES6 or TypeScript
const googleTTS = require('@sefinek/google-tts-api'); // CommonJS
const results = googleTTS.getAllAudioUrls('LONG_TEXT_...', {
lang: 'en',
slow: false,
host: 'https://translate.google.com',
splitPunct: ',.?',
});
console.log(results);
// [
// { shortText: '...', url: '...' },
// { shortText: '...', url: '...' },
// ...
// ];
getAllAudioBase64(text, [option])
(For text longer than 200 characters)import * as googleTTS from '@sefinek/google-tts-api'; // ES6 or TypeScript
const googleTTS = require('@sefinek/google-tts-api'); // CommonJS
googleTTS
.getAllAudioBase64('LONG_TEXT_...', {
lang: 'en',
slow: false,
host: 'https://translate.google.com',
timeout: 10000,
splitPunct: ',.?',
})
.then(console.log)
// [
// { shortText: '...', base64: '...' },
// { shortText: '...', base64: '...' },
// ...
// ];
.catch(console.error);
MIT
FAQs
Google TTS (Text-To-Speech) for Node.js without any vulnerabilities. For free without any API keys!
The npm package @sefinek/google-tts-api receives a total of 318 weekly downloads. As such, @sefinek/google-tts-api popularity was classified as not popular.
We found that @sefinek/google-tts-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.