Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

500-1000ms delay to start speaking? #92

Open
Wizek opened this issue Sep 2, 2019 · 4 comments
Open

500-1000ms delay to start speaking? #92

Wizek opened this issue Sep 2, 2019 · 4 comments

Comments

@Wizek
Copy link

Wizek commented Sep 2, 2019

Is this normal and known current behavior of say.js? Or am I running into a buggy edgecase? say.speak function calls seem to have a 0.5-1 second delay between invocation and start of speech. Even when the speech rate is set to something high, e.g. 2.5. I'm on Windows 10 and using the David built in voice if that matters.

Other ways of invoking the tts, e.g. TTSReader seem to have much less delay, around 100-200ms. And I've also seen even quicker response times through other means, but I currently don't recall exactly what they were.

@Wizek
Copy link
Author

Wizek commented Sep 2, 2019

Ok, I think I've found the reason for this!

I've just came across that on Windows the invocation seems to be through powershell.

This can explain the delay. Here, open a powershell and contrast these two commands:

  • PowerShell -Command "Add-Type -AssemblyName System.Speech; `$x = New-Object System.Speech.Synthesis.SpeechSynthesizer; `$x.Rate = 10; `$x.Speak('Hello...')"
  • Add-Type -AssemblyName System.Speech; $x = New-Object System.Speech.Synthesis.SpeechSynthesizer; $x.Rate = 10; $x.Speak('Hello...')

For me, the latter runs & speaks & exits much more rapidly, and the former one does so with about a 0.5-1s delay, just as I observed with Say.js.

Where can we go from here?

  • Try to find out why starting PS takes this long (perhaps its only on my system? Doesn't make sense that a CLI console should take long to start) and try to reduce it.
  • Find an invocation option that is different and quicker than PS. Possibly a small tool written in C/C++/C# or similar. If no tool exists, we can write one in the aforementioned languages. Or is there such a thing as FFI for node.js? With a Foreign Function Interface we could more directly make a sys call perhaps.
  • If all else fails, maybe we can have a persistent powershell.exe running hot in the background, and execute the latter command inside it. Might not even be hard with some stdio weaving. Or would there be a better way?

@chenvan
Copy link

chenvan commented Nov 21, 2021

why not change to ActiveXObject. It does not delay the speaking

var winax = require('winax')

var voiceObj = new ActiveXObject("Sapi.SpVoice")
voiceObj.speak("你好")

@Wizek
Copy link
Author

Wizek commented Nov 23, 2021

Thank you for that idea @chenvan, I shall try it!

@Aida-Enna
Copy link

Aida-Enna commented Jan 19, 2022

Any updates on this?

EDIT: Oh wow, I got here from a different repo and didn't even notice I was on a different one. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants