MidSpike / google-translate-tts

Create TTS audio streams using the Google Translate API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

google-translate-tts

Installation

npm i github:MidSpike/google-translate-tts

Usage

const fs = require('node:fs');

const { GoogleTranslateTTS } = require('google-translate-tts');

async function main() {
    // creates an instance of a GoogleTranslateTTS
    const gt_tts = new GoogleTranslateTTS({
        language: 'en-us',
        text: 'Hello world!',
    });

    // creates a readable stream from the GoogleTranslateTTS instance
    const gt_tts_stream = await gt_tts.stream();

    // saves the readable stream to an mp3 file
    gt_tts_stream.pipe(fs.createWriteStream('./test.mp3'));
}

main();

Legal

Copyright MIT License

About

Create TTS audio streams using the Google Translate API

License:MIT License


Languages

Language:JavaScript 100.0%