initial changes for major tts revamp

This commit is contained in:
Dave Horton
2020-03-08 09:45:06 +00:00
parent cb3024b872
commit 480817264d
10 changed files with 632 additions and 52 deletions

View File

@@ -1,4 +1,5 @@
const Emitter = require('events');
const fs = require('fs');
const {CallDirection, TaskPreconditions, CallStatus, TaskName} = require('../utils/constants');
const moment = require('moment');
const assert = require('assert');
@@ -40,6 +41,8 @@ class CallSession extends Emitter {
this.stackIdx = 0;
this.callGone = false;
this.tmpFiles = new Set();
sessionTracker.add(this.callSid, this);
}
@@ -99,6 +102,12 @@ class CallSession extends Emitter {
get speechSynthesisVoice() {
return this.application.speech_synthesis_voice;
}
/**
* default language to use for speech synthesis if not provided in the app
*/
get speechSynthesisLanguage() {
return this.application.speech_synthesis_language;
}
/**
* default vendor to use for speech recognition if not provided in the app
@@ -172,6 +181,10 @@ class CallSession extends Emitter {
sessionTracker.remove(this.callSid);
}
trackTmpFile(path) {
this.tmpFiles.add(path);
}
normalizeUrl(url, method, auth) {
const hook = {
url,
@@ -492,6 +505,17 @@ class CallSession extends Emitter {
this.logger.error(err, 'CallSession:_clearResources error');
}
}
// remove any temporary tts files that were created (audio is still cached in redis)
for (const path of this.tmpFiles) {
fs.unlink(path, (err) => {
if (err) {
return this.logger.error(err, `CallSession:_clearResources Error deleting tmp file ${path}`);
}
this.logger.debug(`CallSession:_clearResources successfully deleted ${path}`);
});
}
this.tmpFiles.clear();
}
/**