GithubHelp home page GithubHelp logo

lino-levan / better-node-gtts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thiennq/node-gtts

8.0 2.0 3.0 92 KB

Google Text-to-Speech for NodeJS (Unofficial API)

License: Apache License 2.0

JavaScript 24.12% TypeScript 75.88%

better-node-gtts's Introduction

better-node-gtts

This is a better version of node-gtts (Unofficial API)

How to install

npm install better-node-gtts

How to use

1. Save audio file

var gtts = require("better-node-gtts").default;
var filepath = "./i-love-you.wav";

gtts.save(filepath, "I love you")
  .then(() => {
    console.log("save done");
  });

2. Pipe directly to router response

Example with ExpressJS Router

var express = require("express");
var router = express.Router();
var gtts = require("better-node-gtts").default;

router.get("/speech", function (req, res) {
  res.set({ "Content-Type": "audio/mpeg" });
  gtts.stream(req.query.text).pipe(res);
});

3. Create a standalone server

var gtts = require("better-node-gtts").default;
gtts.createServer(8668);

4. Command line usage

# create file: helllo-world.wav
better-node-gtts en Hello World

# create server listen port 8668
# (in English by default)
better-node-gtts serve 8668 en

API for standalone server

GET /?text={your-text}

  • stream audio of speech with default language

GET /?text={your-text}?lang={lang}

  • stream audio of speech with specific language

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.