-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from nullabork/betabot
Betabot
- Loading branch information
Showing
19 changed files
with
384 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ state.json | |
/config/*.server | ||
/config/ohshit* | ||
talkbot.code-workspace | ||
samples |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.