Text-To-Speach für Linux hinzugefügt

This commit is contained in:
Robert Richter 2019-04-04 13:45:55 +02:00
parent 44096c32cc
commit bfed361bec

View File

@ -139,7 +139,9 @@ module.exports = function(io, sql, async, app_cfg) {
// Abschluss
tts_text = tts_text + '. Ende der Durchsage!';
// Sprachansage als mp3 erstellen
if (process.platform === "win32") {
switch (process.platform) {
//if (process.platform === "win32") {
case 'win32':
// Powershell
var proc = require('child_process');
var commands = [
@ -171,8 +173,38 @@ module.exports = function(io, sql, async, app_cfg) {
callback && callback(mp3_url);
});
childD.stdin.end();
} else {
sql.db_log('Fehler-TTS', 'OS ist nicht Windows');
break;
case 'linux':
// bash
var proc = require('child_process');
var commands = [
// TTS-Schnittstelle SVOX PicoTTS
'-c', `
pico2wave --lang=de-DE --wave=` + wav_tts + ` \"` + tts_text + `\"
ffmpeg -nostats -hide_banner -loglevel 0 -y -i ` + wav_tts + ` -vn -ar 44100 -ac 2 -ab 128k -f mp3 ` + mp3_tmp + `
ffmpeg -nostats -hide_banner -loglevel 0 -y -i \"concat:` + mp3_bell + `|` + mp3_tmp + `\" -acodec copy ` + mp3_tts + `
rm ` + wav_tts + `
rm ` + mp3_tmp
];
var options = {
shell: true
};
console.log(commands);
var childD = proc.spawn('/bin/sh', commands);
childD.stdin.setEncoding('ascii');
childD.stderr.setEncoding('ascii');
childD.stderr.on('data', function(data) {
sql.db_log('Fehler-TTS', data);
callback && callback(null);
});
childD.on('exit', function() {
callback && callback(mp3_url);
});
childD.stdin.end();
break;
// } else {
default:
sql.db_log('Fehler-TTS', 'TTS für dieses Server-Betriebssystem nicht verfügbar');
callback && callback(null);
};
});