Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So .... I think I found it:</p> <pre><code>setTimeout(function(){meSpeak.play(speechArr[0],1,playNext)},pauseArr[0]); recurseLoop++; function playNext() { if (recurseLoop &lt; len) { setTimeout(function(){meSpeak.play(speechArr[recurseLoop],1,playNext)},pauseArr[recurseLoop]); recurseLoop++; } } </code></pre> <p>logs for me the sequence:</p> <pre><code>timeout to 0 Testing Word playing "Testing Word" timeout to 1 Another playing "Again " timeout to 2 Again playing "Blah" timeout to 3 Blah playing undefined Speak: Can't play, not an Array, or ArrayBuffer, or base64-String: [object Undefined] ended </code></pre> <p>Please mind the "recurseLoop++;" just after the timeout!</p> <p>This effects to</p> <ul> <li>setTimeout to play speechArr[0], increment recurseLoop (now 1)</li> <li>call to playNext() after speechArr[0], recurseLoop === 1</li> <li>call setTimeout</li> <li>increment recurseLoop (recurseLoop === 2)</li> <li>timeout comes back plays speechArr[2]</li> <li>call to playNext(), recurseLoop === 2</li> <li>call setTimeout</li> <li>increment recurseLoop (recurseLoop === 3)</li> <li>timeout comes back plays speechArr[3]</li> </ul> <p>Changing your code to increment just at the very beginning of "playNext()" solves the issue:</p> <pre><code>setTimeout(function(){meSpeak.play(speechArr[0],1,playNext)},pauseArr[0]); function playNext() { if (++recurseLoop &lt; len) { setTimeout(function(){meSpeak.play(speechArr[recurseLoop],1,playNext)},pauseArr[recurseLoop]); } } </code></pre> <p>This logs to the following sequence:</p> <pre><code>timeout to 0 Testing Word playing "Testing Word" timeout to 1 Another playing "Another " timeout to 2 Again playing "Again " timeout to 3 Blah playing "Blah" ended </code></pre> <p>(I was so mesmerized by the <em>undefined</em> value that looked like a bug in mespeak.js or in addressing meSpeak.speak() that I totally missed this skipping in the iteration at first – see the other try on this.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload