Skip to content

Commit

Permalink
fix web demo
Browse files Browse the repository at this point in the history
  • Loading branch information
albho committed Aug 20, 2024
1 parent 01ee8ed commit efebeea
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions demo/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
const audioBuffer = [];
let streamSource;

async function playStream() {
function playStream() {
if (isPlayingStream) return;

if (audioBuffer.length === 0) {
Expand All @@ -251,7 +251,7 @@

streamSource.onended = async () => {
isPlayingStream = false;
await playStream();
playStream();
};

streamSource.start();
Expand Down Expand Up @@ -298,8 +298,8 @@
const time = curSecs + newSecs;
streamSecondsDisplayEl.innerText = time.toFixed(3);
audioBuffer.push(createBuffer(wordPcm));
if (numIterations === 1) {
await playStream();
if (numIterations === 1 || !isPlayingStream) {
playStream();
}
numIterations++;
}
Expand Down

0 comments on commit efebeea

Please sign in to comment.