Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- 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 |
-
//
|
| 260 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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) {
|