Spaces:
Running
Running
Stabilize loopback prompt timing
Browse files
app.js
CHANGED
|
@@ -113,7 +113,8 @@ const WEBGPU_ONLY_REASONS = new Map([
|
|
| 113 |
const DEFAULT_VAD_SILENCE_MS = 480;
|
| 114 |
const MIN_VAD_SILENCE_MS = 200;
|
| 115 |
const MAX_VAD_SILENCE_MS = 800;
|
| 116 |
-
const DEFAULT_LOOPBACK_SPEED = 1.
|
|
|
|
| 117 |
const MIC_START_TIMEOUT_MS = 15000;
|
| 118 |
const WEBGPU_ADAPTER_TIMEOUT_MS = 5000;
|
| 119 |
const DEFAULT_TTS_CHUNKING = Object.freeze({
|
|
@@ -2276,6 +2277,13 @@ function feedLoopbackAudio(audio, sampleRate) {
|
|
| 2276 |
}, delayMs);
|
| 2277 |
delayMs += (chunk.length / sampleRate) * 1000;
|
| 2278 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2279 |
for (let offset = 0; offset < samples.length; offset += chunkSize) {
|
| 2280 |
const chunk = samples.slice(offset, Math.min(offset + chunkSize, samples.length));
|
| 2281 |
postChunk(chunk);
|
|
|
|
| 113 |
const DEFAULT_VAD_SILENCE_MS = 480;
|
| 114 |
const MIN_VAD_SILENCE_MS = 200;
|
| 115 |
const MAX_VAD_SILENCE_MS = 800;
|
| 116 |
+
const DEFAULT_LOOPBACK_SPEED = 1.0;
|
| 117 |
+
const DEFAULT_LOOPBACK_PREROLL_MS = 180;
|
| 118 |
const MIC_START_TIMEOUT_MS = 15000;
|
| 119 |
const WEBGPU_ADAPTER_TIMEOUT_MS = 5000;
|
| 120 |
const DEFAULT_TTS_CHUNKING = Object.freeze({
|
|
|
|
| 2277 |
}, delayMs);
|
| 2278 |
delayMs += (chunk.length / sampleRate) * 1000;
|
| 2279 |
};
|
| 2280 |
+
const prerollSamples = Math.ceil((sampleRate * DEFAULT_LOOPBACK_PREROLL_MS) / 1000);
|
| 2281 |
+
if (prerollSamples > 0) {
|
| 2282 |
+
if (state.activeBenchmark) state.activeBenchmark.loopbackPrerollMs = DEFAULT_LOOPBACK_PREROLL_MS;
|
| 2283 |
+
for (let offset = 0; offset < prerollSamples; offset += chunkSize) {
|
| 2284 |
+
postChunk(new Float32Array(Math.min(chunkSize, prerollSamples - offset)));
|
| 2285 |
+
}
|
| 2286 |
+
}
|
| 2287 |
for (let offset = 0; offset < samples.length; offset += chunkSize) {
|
| 2288 |
const chunk = samples.slice(offset, Math.min(offset + chunkSize, samples.length));
|
| 2289 |
postChunk(chunk);
|