Commit 2701a100 authored by Chris Lord's avatar Chris Lord

Use espeak to vocalise output

Speaks synchronously due to node crashing with async process completion.
parent 3e423405
Pipeline #3342143 pending
var concat = require('concat-stream');
var ChildProcess = require('child_process');
var Fs = require('fs');
var Mic = require('mic');
var Path = require('path');
......@@ -81,14 +82,41 @@ function createEvent(type) {
};
}
function say(text) {
// XXX The async version segfaults on command complete
ChildProcess.execFileSync('espeak', ['-m', text]);
}
function createContext(skill) {
return {
fail: e => {
console.error('Event failed', e);
},
succeed: o => {
console.log('Event succeeded', o);
if (o && o.response.outputSpeech.shouldEndSession) {
console.log('Event succeeded');
if (!o) {
return;
}
console.log('Output:', o);
var speech = o.response.outputSpeech;
if (speech) {
switch (speech.type) {
case 'SSML':
say(speech.ssml);
break;
case 'PlainText':
say(speech.text);
break;
default:
console.warn('Unrecognised speech type: ' + speech.type);
}
}
if (o.response.shouldEndSession) {
endSession(skill);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment