🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

node-google-tts-api

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-google-tts-api

Simple node.js library for google text to speech

1.1.1
latest
Version published
Weekly downloads
23
15%
Maintainers
1
Weekly downloads
 
Created

node-google-tts-api

Simple node.js library for google text to speech service

Installation

npm i node-google-tts-api 

Usage

const googleTTS = require('node-google-tts-api');
const tts = new googleTTS();

const fs = require('fs');

tts.get({
  text: "hello world",
  lang: "en"
}).then(data => {
  // returns mp3 audio src buffer
  fs.writeFileSync("./audio.mp3", data);
});

Text length limit

Google forbids sending text over 200 characters - which is not very cool. Therefore, a bypass was made:

tts.get({
  text: "a".repeat(200) + "b".repeat(50),
  lang: "en",
  limit_bypass: true // required parameter
}).then(arr => {
  // returns array with mp3 audio src buffers
  let data = tts.concat(arr); // concat audio files
  fs.writeFileSync("./audio.mp3", data);
});

Supported languages

Google text to speech service supports the following language codes:
https://github.com/IldarSham/node-google-tts/blob/master/supported-languages.txt

FAQs

Package last updated on 12 Aug 2020

Did you know?

Socket

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.

Install

Related posts