fix: speed controls local playbackRate only, TTS generation always uses speed 1
Some checks failed
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled

Speed buttons now set audio.playbackRate directly (on load and on change)
instead of passing the speed to Kokoro. The TTS generation request always
sends speed:1 so the cached audio is at normal pitch/tempo and the browser
handles tempo adjustment locally.
This commit is contained in:
Admin
2026-03-02 18:50:46 +05:00
parent 1536c7dad1
commit 1c547519e8

View File

@@ -2704,6 +2704,7 @@ const chapterTmpl = `
b.classList.toggle('text-zinc-300', !active);
});
try { localStorage.setItem(LS_SPEED, btn.dataset.speed); } catch(_) {}
if (audio.src) audio.playbackRate = parseFloat(btn.dataset.speed);
}
window.selectSpeed = selectSpeed;
(function loadSettings() {
@@ -2841,7 +2842,7 @@ const chapterTmpl = `
fetch('/ui/audio/' + SLUG + '/' + chapterN, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ voice: voiceSel.value, speed: getSpeed() }),
body: JSON.stringify({ voice: voiceSel.value, speed: 1 }),
signal: ctrl.signal
})
.then(function (res) {
@@ -2928,6 +2929,7 @@ const chapterTmpl = `
if (stale()) return;
if (autoplay) audio.autoplay = true;
audio.src = url; audio.load();
audio.playbackRate = getSpeed();
registerMediaSession();
});
}