Skip to content

Commit

Permalink
Merge pull request #81 from nullabork/betabot
Browse files Browse the repository at this point in the history
Betabot
  • Loading branch information
zenril committed Mar 19, 2020
2 parents 1875e0c + af59808 commit d5b7685
Show file tree
Hide file tree
Showing 19 changed files with 384 additions and 218 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ state.json
/config/*.server
/config/ohshit*
talkbot.code-workspace
samples
1 change: 0 additions & 1 deletion amazon.json

This file was deleted.

66 changes: 66 additions & 0 deletions bin/create-samples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*jshint esversion: 9 */
require('module-alias/register');

/* make voice samples with `node create-samples.js` */
(async () => {

const tts = require("@services/TextToSpeechService.js"),
delay = require("delay"),
prism = require("prism-media"),
lame = require("lame"),
fs = require("fs"),
msg = "You are hearing me talk";

process.on('uncaughtException', console.log);

await tts.setupProviders();

var dir = './samples';

if (!fs.existsSync(dir)){
fs.mkdirSync(dir);
}

for ( let provider_name in tts.providers ) {

console.log(provider_name);

let provider = tts.getService(provider_name);

for ( let voice of provider.getVoices() ) {

let sample_file = `${dir}/${voice.voice}.mp3`;

// rewrite this using await when we finally implement async/await for getAudioContent and buildRequest
let request = provider.buildRequest(msg, {
name: voice.voice
});

console.log(`Saving ${sample_file}`);

provider.getAudioContent(request, (err, audio) => {

if ( err ) {
console.log(err);
return;
}

let decoder = new prism.opus.Decoder(48000, 1, 960);
let encoder = new lame.Encoder({
channels: 1,
bitDepth: 16,
sampleRate: 48000,

bitRate: 128,
outSampleRate: 48000,
mode: lame.STEREO
});
let stm = fs.createWriteStream(sample_file);

audio.pipe(decoder).pipe(encoder).pipe(stm);
});

await delay(10000);
}
}
})();
File renamed without changes.
2 changes: 1 addition & 1 deletion google.json

Large diffs are not rendered by default.

Loading

0 comments on commit d5b7685

Please sign in to comment.