I am trying to get a Raspberry Pi to work without a screen. However I want Text To Speech functions. I have installed festival and gotten the USB sound device to be default. Everything works except when the NodeJS script is run with sudo, or if it is run at startup (which I imagine would be with sudo as well) the audio never plays.
var say = require('say');
var express = require('express');
var app = express();
var sys = require('sys');
var exec = require('child_process').exec;
function puts(error, stdout, stderr) { sys.puts(stdout) }
function speak(text) {
say.speak(text, 'Alex', 0.8);
//exec("echo " + text + " | festival --tts", puts); //another attempt
}
app.get('/say', function(request, response) {
speak(request.query.text);
response.send({"state":"I have spoken: " + request.query.text});
});
I have put this into a file called "server.js" and the way I get this to run at boot is to modify the /etc/rc.local file to include
node /path/to/server.js
But when it is run in this manner, or with sudo, the Text To Speech library does not work.
NodeJS Version: 0.10.29