Luca448 commited on
Commit
eb8f0cc
·
1 Parent(s): 358b863

Fix: Clear preload queue correctly on speed change and skip (BUILD 1.5.24)

Browse files
Files changed (2) hide show
  1. index.html +1 -1
  2. src/services/tts-service.js +7 -19
index.html CHANGED
@@ -51,7 +51,7 @@
51
  </head>
52
  <body class="dark-theme in-chat-view">
53
 
54
- <div id="live-version-badge" style="position: fixed; top: 50px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-secondary); opacity: 0.6; z-index: 99999; pointer-events: none; font-weight: 500; font-family: monospace; letter-spacing: 1px; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);">BUILD 1.5.23</div>
55
 
56
  <!-- SVG Filters for Liquid Glass Refraction -->
57
  <svg width="0" height="0" style="position: absolute; pointer-events: none;">
 
51
  </head>
52
  <body class="dark-theme in-chat-view">
53
 
54
+ <div id="live-version-badge" style="position: fixed; top: 50px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-secondary); opacity: 0.6; z-index: 99999; pointer-events: none; font-weight: 500; font-family: monospace; letter-spacing: 1px; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);">BUILD 1.5.24</div>
55
 
56
  <!-- SVG Filters for Liquid Glass Refraction -->
57
  <svg width="0" height="0" style="position: absolute; pointer-events: none;">
src/services/tts-service.js CHANGED
@@ -162,12 +162,11 @@ class TTSService {
162
  return;
163
  }
164
 
165
- // Clear queue and queue current + next chunks sequentially
166
  this.preloadQueue = [];
167
- this.queuePreload(this.currentChunkIndex);
168
- this.queuePreload(this.currentChunkIndex + 1);
169
- this.queuePreload(this.currentChunkIndex + 2);
170
- this.queuePreload(this.currentChunkIndex + 3);
171
 
172
  const url = this.audioUrls[this.currentChunkIndex];
173
  if (url && url !== 'loading') {
@@ -260,20 +259,9 @@ class TTSService {
260
  setRate(newRate) {
261
  this.rate = newRate;
262
  this.audio.playbackRate = this.rate;
263
- // Note: To apply rate to preloading, we'd need to re-fetch, but typically
264
- // changing rate clears the preloaded URLs. For simplicity, we just clear them!
265
- if (this.audioUrls) {
266
- for (let i = this.currentChunkIndex + 1; i < this.audioUrls.length; i++) {
267
- if (this.audioUrls[i] && this.audioUrls[i] !== 'loading') {
268
- URL.revokeObjectURL(this.audioUrls[i]);
269
- this.audioUrls[i] = null;
270
- }
271
- }
272
- }
273
- // Re-trigger preload for next chunks sequentially
274
- this.preloadQueue = [];
275
- this.queuePreload(this.currentChunkIndex + 1);
276
- this.queuePreload(this.currentChunkIndex + 2);
277
  this.notifyState();
278
  }
279
 
 
162
  return;
163
  }
164
 
165
+ // Clear queue and queue ALL remaining chunks sequentially
166
  this.preloadQueue = [];
167
+ for (let i = this.currentChunkIndex; i < this.chunks.length; i++) {
168
+ this.queuePreload(i);
169
+ }
 
170
 
171
  const url = this.audioUrls[this.currentChunkIndex];
172
  if (url && url !== 'loading') {
 
259
  setRate(newRate) {
260
  this.rate = newRate;
261
  this.audio.playbackRate = this.rate;
262
+ // We do NOT need to clear the preload queue or revoke URLs,
263
+ // because the backend ignores rate and always generates 1.0x audio.
264
+ // The browser's HTML5 Audio playbackRate handles the speedup dynamically!
 
 
 
 
 
 
 
 
 
 
 
265
  this.notifyState();
266
  }
267