Add voice processing settings and a speak-time bypass

This commit is contained in:
Fisto
2026-09-21 18:23:40 +02:00
parent 17d4339ea3
commit 63083c54ec
10 changed files with 230 additions and 9 deletions
+36
View File
@@ -1788,6 +1788,37 @@ async function refreshAudio() {
await refreshSpeech();
}
/* Discord voice processing gates (Settings -> TTS panel). */
function fillVoiceGates(voice) {
const gates = voice ?? {};
for (const [id, key] of [
["#vp-echo", "echoCancellation"],
["#vp-agc", "automaticGainControl"],
["#vp-nc", "noiseCancellation"],
["#vp-bypass", "bypassWhileSpeaking"]
]) {
const box = $(id);
if (box) box.checked = gates[key] === true;
}
}
async function saveVoiceGates() {
const voice = {
noiseSuppression: false,
echoCancellation: $("#vp-echo").checked,
automaticGainControl: $("#vp-agc").checked,
noiseCancellation: $("#vp-nc").checked,
bypassWhileSpeaking: $("#vp-bypass").checked
};
try {
const prefs = await VK.api.post("/api/preferences", { voice });
fillVoiceGates(prefs.voice ?? voice);
} catch (error) {
toast(`voice processing save failed: ${error.message}`, "error");
}
}
/* Speech settings (server-side preferences). */
async function refreshSpeech() {
@@ -1815,6 +1846,7 @@ async function refreshSpeech() {
try {
const prefs = await VK.api.get("/api/preferences");
state.speech = prefs.tts ?? { provider: null, language: null, voice: null, speed: null, pitch: null };
fillVoiceGates(prefs.voice);
} catch {
// preferences are optional
}
@@ -2728,6 +2760,10 @@ function init() {
$("#transcript-refresh").addEventListener("click", () => void refreshTranscript());
$("#transcript-start").addEventListener("click", () => void setCapture(true));
$("#transcript-stop").addEventListener("click", () => void setCapture(false));
for (const id of ["#vp-echo", "#vp-agc", "#vp-nc", "#vp-bypass"]) {
$(id)?.addEventListener("change", () => void saveVoiceGates());
}
$("#tts-duck").addEventListener("click", async () => {
const on = !$("#tts-duck").classList.contains("vk-chip-on");
try {
+9
View File
@@ -139,6 +139,15 @@
duck on voice
</button>
<span class="vk-chip vk-chip-on">queue lines</span>
<div class="vk-voice-gates" title="Discord's microphone processing. Leave off so TTS is not gated or ramped in.">
<span class="vk-micro-label">voice processing</span>
<label class="vk-tts-check"><input id="vp-echo" type="checkbox" /> echo cancellation</label>
<label class="vk-tts-check"><input id="vp-agc" type="checkbox" /> auto gain</label>
<label class="vk-tts-check"><input id="vp-nc" type="checkbox" /> noise cancellation</label>
<label class="vk-tts-check" title="Turn every gate off while a TTS line plays, then restore the states above">
<input id="vp-bypass" type="checkbox" /> off while speaking
</label>
</div>
<div class="vk-tts-speed">
<label class="vk-tts-slider" title="Speech rate; 1.0x is the engine's natural rate">
<span class="vk-micro-label">speed</span>