This commit is contained in:
2021-04-05 15:50:51 +02:00
parent 9c5959aca7
commit 9050e4b6ed
5 changed files with 288 additions and 0 deletions

19
voice-test.js Normal file
View File

@@ -0,0 +1,19 @@
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();