This commit is contained in:
raluca-elena 2014-07-31 23:53:18 -07:00
Родитель ce2f6b970b
Коммит da8b652cb5
2 изменённых файлов: 37 добавлений и 1 удалений

34
slave/speakerServer.js Normal file
Просмотреть файл

@ -0,0 +1,34 @@
var http = require("http");
var url = require("url");
var express = require('express');
var getRawBody = require('raw-body');
var cors = require('cors');
var request = require("superagent");
var argv = process.argv;
var app = express();
var port = argv[2];
//handle put
app.use(function (req, res, next) {
getRawBody(req, {
length: req.headers['content-length'],
limit: '1mb',
encoding: 'utf8'
}, function (err, string) {
if (err)
return next(err);
req.text = string;
next();
})
});
app.use(cors());
app.put("/", function(req, res, next) {
var text = req.text;
console.log("PUT /, text is : ", text);
require('child_process').spawn('node', ["textToSpeechServer.js", text]);
res.send("text processed is " + text);
});
app.listen(port);

Просмотреть файл

@ -1,5 +1,7 @@
var argv = process.argv;
console.log("text to process ***************", argv[2]);
var spawn = require('child_process').spawn,
echo = spawn('echo', ['just what do you think you are doing Dave?']),
echo = spawn('echo', [argv[2]]),
festival = spawn('festival', ['--tts']);
echo.stdout.on('data', function (data) {