Add sam as speech synth

This commit is contained in:
2021-07-03 17:09:19 +02:00
parent a27d68ec92
commit 43d7f60a7a
4 changed files with 57 additions and 3 deletions

20
tts/sam/index.js Normal file
View File

@@ -0,0 +1,20 @@
const BaseEngine = require('../BaseEngine')
const Sam = require('sam-js');
const wavefile = require('wavefile');
const fs = require('fs');
module.exports = class extends BaseEngine {
constructor() {
super('sam', 'Software Automatic Mouth', 'wav')
}
getDefaultVoice() {
return 'en';
}
async getSpeechFile(text, filepath, voice = this.getDefaultVoice(), params = {}) {
let sam = new samjs();
const buf = sam.buf8(text);
const file = new wavefile.WaveFile();
file.fromScratch(1, 22050, 8, buf);
fs.writeFileSync(filepath, file.toBuffer());
}
}