picotts
Version:
PicoTTS wrapper. PicoTTS is being used by Android and it's extremely lightweight and fast yet produces very natural voices.
23 lines (17 loc) • 590 B
JavaScript
var fs = require('fs'),
exec = require('child_process').exec
var commandTmpl = 'pico2wave -l "{{lang}}" -w {{file}} "{{text}}" && aplay {{file}}'
function getTmpFile() {
var random = Math.random().toString(36).slice(2),
path = '/tmp/' + random + '.wav'
return (!fs.existsSync(path)) ? path : getTmpFile()
}
function say(text, lang, cb) {
var file = getTmpFile(),
command = commandTmpl.replace('{{lang}}', lang).replace('{{text}}', text).replace(/\{\{file\}\}/g, file)
exec(command, function(err) {
cb && cb(err)
fs.unlink(file)
})
}
module.exports = exports = {say: say}