tardis-bot/voice-test.js

19 lines
527 B
JavaScript

const tts = require('google-tts-api');
const fetch = require('node-fetch');
const fs = require('fs');
const buffer = require('buffer');
async function generateVoice(string) {
const url = tts.getAudioUrl(string, {lang: "en-us"});
console.log("Generated url: " + url);
const data = await fetch(url);
const contents = await data.arrayBuffer();
const buf = Buffer.from(contents);
fs.writeFileSync('speak.mp3', buf);
}
async function test() {
const url = await generateVoice("Hi there bud");
}
test();