Skip to content

Commit

Permalink
espeak options: -s 130
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Mar 18, 2016
1 parent 0b583b7 commit b750299
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require('./array-includes-shim');

var Camera = require('./camera');
var Player = require('./player');
var Speaker = require('./speaker');
Expand Down
19 changes: 19 additions & 0 deletions lib/speaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ Speaker.prototype.say = function(phrase) {
this.emit('timeupdate', this.currentTime);
}, 100);

// Apply some reasonable defaults...
Object.keys(espeak.options).forEach(key => {
if (!args.includes(key)) {
args.push(key, espeak.options[key]);
}
});

state.process = cp.spawn('espeak', args);

if (this.debug) {
Expand Down Expand Up @@ -203,4 +210,16 @@ Speaker.prototype.stop = function() {
return this;
};


var espeak = {
options: {
// Words per minute defaults to 160.
// Tweaking this to 130 makes the output speed
// much easier to hear and follow.
'-s': 130,
}
};

espeak.keys = Object.keys(espeak.options);

module.exports = Speaker;
16 changes: 13 additions & 3 deletions test/unit/speaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ exports['av.Speaker'] = {
test.equal(speaker.isSpeaking, true);
test.equal(this.spawn.callCount, 1);
test.equal(this.spawn.lastCall.args[0], 'espeak');
test.deepEqual(this.spawn.lastCall.args[1], ['0']);
test.deepEqual(this.spawn.lastCall.args[1], [ '0', '-s', 130 ]);
test.done();
},

Expand All @@ -101,7 +101,7 @@ exports['av.Speaker'] = {
test.equal(speaker.isSpeaking, true);
test.equal(this.spawn.callCount, 1);
test.equal(this.spawn.lastCall.args[0], 'espeak');
test.deepEqual(this.spawn.lastCall.args[1], ['hello']);
test.deepEqual(this.spawn.lastCall.args[1], ['hello', '-s', 130]);
test.done();
},

Expand All @@ -114,7 +114,7 @@ exports['av.Speaker'] = {
test.equal(speaker.isSpeaking, true);
test.equal(this.spawn.callCount, 1);
test.equal(this.spawn.lastCall.args[0], 'espeak');
test.deepEqual(this.spawn.lastCall.args[1], [message]);
test.deepEqual(this.spawn.lastCall.args[1], [message, '-s', 130]);
test.done();
},

Expand Down Expand Up @@ -262,4 +262,14 @@ exports['av.Speaker'] = {
});
speaker.stop();
},

reasonableEspeakOptions: function(test) {
test.expect(1);
this.clock = this.sandbox.useFakeTimers();
var speaker = new av.Speaker();
speaker.say('Hi!');

test.deepEqual(this.spawn.lastCall.args[1], [ 'Hi!', '-s', 130 ]);
test.done();
},
};

0 comments on commit b750299

Please sign in to comment.