javascript - HTML5 audio: trying to make a queue -


i working on text-to-speech generator using javascript , html5 audio elements. idea transform string of ipa (international phonetic alphabet) sound. in function talk(), take string , split it. put corresponding sounds queue, try play playq(q) function.

but function doesn't seem work. can make play first sound. q[0].play; working, rest of playq(q) function not.

i'm thinking either because of q.shift() method, have tried q[1:], or because of recursivity.

function talk(){     var queue = []     var str = document.ipatts.phonetic.value     var letters = str.split("")     (x in letters) {         queue.push(document.getelementbyid(letters[x]))     }     playq(queue); }  function playq(q){     q[0].play();     var z = q.shift();     q[0].onended = function() {playq(z)}; } 

nevermind! got work using

var z = [] (x in q) {     if (x > 0) {         z.push(q[x])     } } 

in stead of var z = q.shift();


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -