say.js icon indicating copy to clipboard operation
say.js copied to clipboard

Speech Queuing? Return references to speech objects?

Open tlhunter opened this issue 9 years ago • 4 comments

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.

tlhunter avatar Feb 15 '16 09:02 tlhunter

Maybe something like the queue package can be reused.

derhuerst avatar Feb 15 '16 10:02 derhuerst

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]);
}

tlhunter avatar Nov 05 '17 02:11 tlhunter

It's brand new so it's pretty spaghetti right now, but I made this https://github.com/Arlodotexe/async-sayjs

Arlodotexe avatar Apr 18 '18 07:04 Arlodotexe

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.

SimpleCookie avatar Jul 27 '20 16:07 SimpleCookie