say.js
say.js copied to clipboard
Speech Queuing? Return references to speech objects?
As it is, many bits of text can be fired off at the same time, and they all talk in parallel. See the existing examples/osx-*.js
files.
Queue: Queue up audio to be spoken and play them all sequentially. As items are played and finished their callbacks will fire. We'd need a way to flush the queue as well. Having callbacks on a per-text basis might not be as useful as, perhaps, an EventEmitter approach.
Playback Handles:
We keep allowing the user to manage all of this. We'd need a way to return a reference to the audio being spoken so that the user can cancel it, much like var x = setTimeout(); clearTimeout(x);
works.
Either way, we will need to massively rewrite how say works, including all consumer facing API's.
Maybe something like the queue
package can be reused.
Now that Node v8 is LTS and we've got async/await everywhere we should promisify the methods. We can then perform our "speech queueing" like this:
for (let i = 0; i < sentences.length; i++) {
await say.speak(sentence[i]);
}
It's brand new so it's pretty spaghetti right now, but I made this https://github.com/Arlodotexe/async-sayjs
It's brand new so it's pretty spaghetti right now, but I made this https://github.com/Arlodotexe/async-sayjs
Seems good although it doesn't work. It's "almost" synchronous (btw you mixed up sync and async in your readme I guess). synchronous should wait for the previous "speak" to finish while asynchronous should just speak em in parallel.