shreyask commited on
Commit
d1343a6
·
verified ·
1 Parent(s): 2a9118c

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. src/worker.ts +6 -2
src/worker.ts CHANGED
@@ -256,8 +256,12 @@ async function generateChunk(
256
  console.warn(`[KittenTTS] Model produced NaN audio — this model may not be compatible with ${currentDevice.toUpperCase()}`);
257
  }
258
 
259
- // Trim trailing silence (matching Python: audio[..., :-5000])
260
- return audioData.slice(0, Math.max(0, audioData.length - 5000));
 
 
 
 
261
  }
262
 
263
  async function generate(text: string, voice: string, speed: number) {
 
256
  console.warn(`[KittenTTS] Model produced NaN audio — this model may not be compatible with ${currentDevice.toUpperCase()}`);
257
  }
258
 
259
+ // Python trims audio[..., :-5000] but this can cut real audio on short clips.
260
+ // Only trim if audio is long enough (>1 second = 24000 samples)
261
+ if (audioData.length > 24000) {
262
+ return audioData.slice(0, audioData.length - 5000);
263
+ }
264
+ return audioData;
265
  }
266
 
267
  async function generate(text: string, voice: string, speed: number) {