Search code examples
javascriptjqueryespeak

Speak.js – only one command is executed


I'm currently fooling around with speak.js: http://www.syntensity.com/static/espeak.html

Apparently the script only allows for one speak command to be executed, if I do like this:

speak("1");
speak("2");

... only "2" is read out.

Does anybody know how to troubleshoot a problem like this?

If you want to fiddle around: http://jsfiddle.net/timkl/YgWdh/


Solution

  • What's happening is that both are being executed but the first gets trampled by the second. Look at this revision of your fiddle: http://jsfiddle.net/YgWdh/4/.

    It uses a setTimeout to make sure the second line waits a bit before executing. But I don't see any API docs so I don't know how to make the second call wait only long enough for the first to finish.