defano / wyldcard

A clone of Apple's HyperCard and HyperTalk scripting language.
https://github.com/defano/wyldcard/wiki
MIT License
122 stars 11 forks source link

First call to speak() is delayed #39

Open defano opened 6 years ago

defano commented 6 years ago

First text spoken via text-to-speech is delayed several seconds; subsequent calls to speak have no noticeable delay.

Jimw338 commented 5 years ago

Okay defano, I think you'll have to make me a contributor :) I added a dummy call to "getSpeechPlaybackManager()" at the beginning of the WyldCard startup function. This might work.. There doesn't seem to be a "big" delay between anything put in the log depending on whether this fix is there or not (the MaryTTS framework logs a LOT), but perhaps it's something in the marytts framework that isn't logged, or something that's set up by the call to "mary.setVoice" and "mary.setStreamingAudio", or "mary.process".

Anyway, this stops the delay at least on my system (OSX 10.14.4, early 2015 3.1 i7, java 1.8.0_201).

WyldCard.java:111

private void startup() {

    // [jw 3/13/19]
    // FIX: (Issue #39) The first call to speech is delayed, I presume because the SpeechPlaybackManager object hasn't been created yet.
    // So we call getSpeechPlaybackManager with a dummy var to make it "ready to go"
    SpeechPlaybackManager temp = getSpeechPlaybackManager();

Without the pre-initialization, the timing (in millisconds) of the speak() command is follows:

213  - start speak
(call to speechPlaybackManager.speak)
227  (+14) end SpeakCmd

With the pre-initialization, the times are as:

PRE-INIT

876  - start speak
(call to speechPlaybackManager.speak)
877  (+1) end SpeakCmd

Where the call to "speechPlaybackManager.speak" us in between So there's about 1/7 second difference between the two (on my system) - just barely enough to hear I guess.

defano commented 5 years ago

Hi Jim,

I see the same behavior as you now. When I first opened this issue there was a very noticeable, very annoying delay. Not milliseconds, but several (maybe even 10) seconds. Not sure what changed. Perhaps a Java update? macOS Mohave?

That being said, I'd love to have you as a contributor. Send me a pull request and you'll forever be ensconced in the git history log. There are several good articles that describe the process if you're new to git, like this one: http://archaeogeek.github.io/foss4gukdontbeafraid/fixes/pullrequest.html

By the way, I'm working on support for importing HyperCard stacks... should be ready soonish.