vomebook commited on
Commit
fe7441b
·
1 Parent(s): 67018f7

fix(tts): long-poll all batch jobs concurrently so finished clips are seen at once

Browse files
Files changed (2) hide show
  1. static/index.html +1 -1
  2. static/tts-client.js +8 -8
static/index.html CHANGED
@@ -158,7 +158,7 @@
158
  </section>
159
 
160
  <script>if ("serviceWorker" in navigator) { navigator.serviceWorker.register("/sw.js", { scope: "/" }); }</script>
161
- <script src="/static/tts-client.js?v=clips-7"></script>
162
  <script src="/static/app.js?v=phrases-3"></script>
163
  </body>
164
  </html>
 
158
  </section>
159
 
160
  <script>if ("serviceWorker" in navigator) { navigator.serviceWorker.register("/sw.js", { scope: "/" }); }</script>
161
+ <script src="/static/tts-client.js?v=clips-8"></script>
162
  <script src="/static/app.js?v=phrases-3"></script>
163
  </body>
164
  </html>
static/tts-client.js CHANGED
@@ -830,16 +830,16 @@ if (typeof document !== "undefined") window.CCRDSpeech = (() => {
830
  const epoch = value.seekEpoch;
831
  clearTimeout(value.timer); value.pumpEpoch = epoch;
832
  try {
 
 
 
 
833
  const current = value.jobs.get(value.batch.start);
834
- if (current) await update(value, current);
835
- if (!live(value) || epoch !== value.seekEpoch) return;
836
- advance(value); // Never wait for speculative work before playing a part.
837
- if (!live(value) || !value.wantsPlay) return;
838
- for (const job of Array.from(value.jobs.values())) if (job.batch.start !== current?.batch.start) {
839
  await update(value, job);
840
- if (!live(value) || epoch !== value.seekEpoch) return;
841
- advance(value);
842
- }
843
  } finally {
844
  if (epoch === value.seekEpoch) {
845
  value.pumpEpoch = null;
 
830
  const epoch = value.seekEpoch;
831
  clearTimeout(value.timer); value.pumpEpoch = epoch;
832
  try {
833
+ // Jobs are long-polled concurrently. Polled one after another, the next
834
+ // batch (queued behind this one on the single worker) held each round for
835
+ // its full 8 s wait, so this batch's finished clips were seen up to 9 s
836
+ // late (2026-10-20 cold CW:0: clips 2 and 3 arrived together, 4.9 s late).
837
  const current = value.jobs.get(value.batch.start);
838
+ const jobs = [current, ...Array.from(value.jobs.values()).filter(job => job !== current)].filter(Boolean);
839
+ await Promise.all(jobs.map(async job => {
 
 
 
840
  await update(value, job);
841
+ if (live(value) && epoch === value.seekEpoch) advance(value); // Never wait for speculative work.
842
+ }));
 
843
  } finally {
844
  if (epoch === value.seekEpoch) {
845
  value.pumpEpoch = null;