Add voice processing settings and a speak-time bypass
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user