Skip to content

Instantly share code, notes, and snippets.

@trahloff
Last active April 20, 2016 14:34
Show Gist options
  • Save trahloff/c02a36a244d2b5ed406aa3fb5e51596e to your computer and use it in GitHub Desktop.
Save trahloff/c02a36a244d2b5ed406aa3fb5e51596e to your computer and use it in GitHub Desktop.
temp
// client
function tts(text) {
var url = 'http://localhost:8080/nlc/synthesize';
var req = {
method: 'POST',
url: url,
responseType: 'blob',
data: {
"text": text
},
headers: {
'Content-Type': 'application/json',
}
}
$http(req).then(function(response) {
console.log(response);
audio.pause();
audio.src = URL.createObjectURL(response.data);
audio.play();
})
};
//server:
app.post('/nlc/synthesize', function(req, res, next) {
if (req.body.text == "When shall we meet again?") {
var transcript = textToSpeech.synthesize({
voice: 'en-US_AllisonVoice',
text: "In thunder, darkness or in rain. When the hurlyburly's done, when the batlle's lost, and won."
});
transcript.pipe(res);
} else {
var text = req.body.text;
var deviceId = "node-red";
dlg.classify(deviceId, text, function(err, result) {
console.log(result);
var transcript = textToSpeech.synthesize({
voice: 'en-US_AllisonVoice',
text: result
});
transcript.pipe(res);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment