Add voice processing settings and a speak-time bypass
This commit is contained in:
+38
-1
@@ -484,7 +484,14 @@ export function startWebUi(deps: WebUiDeps): WebUiHandle {
|
||||
app.post(
|
||||
"/api/preferences",
|
||||
wrap(async (req, res) => {
|
||||
const { visibleGuilds, tts, audio, favourites, media: mediaPrefs } = req.body ?? {};
|
||||
const {
|
||||
visibleGuilds,
|
||||
tts,
|
||||
audio,
|
||||
voice: voicePrefs,
|
||||
favourites,
|
||||
media: mediaPrefs
|
||||
} = req.body ?? {};
|
||||
|
||||
if (visibleGuilds !== undefined && visibleGuilds !== null && !Array.isArray(visibleGuilds)) {
|
||||
throw new HttpError(400, "visibleGuilds must be an array of guild IDs or null");
|
||||
@@ -549,8 +556,24 @@ export function startWebUi(deps: WebUiDeps): WebUiHandle {
|
||||
deps.audio.setDuckEnabled(patch.audio.duck);
|
||||
}
|
||||
|
||||
if (voicePrefs !== undefined) {
|
||||
patch.voice = {
|
||||
noiseSuppression: voicePrefs?.noiseSuppression === true,
|
||||
echoCancellation: voicePrefs?.echoCancellation === true,
|
||||
automaticGainControl: voicePrefs?.automaticGainControl === true,
|
||||
noiseCancellation: voicePrefs?.noiseCancellation === true,
|
||||
bypassWhileSpeaking: voicePrefs?.bypassWhileSpeaking !== false
|
||||
};
|
||||
}
|
||||
|
||||
const updated = deps.preferences.update(patch);
|
||||
if (mediaPrefs !== undefined) deps.media.applyTunables();
|
||||
if (voicePrefs !== undefined) {
|
||||
const core = deps.getCore();
|
||||
if (core && deps.isCoreConnected()) {
|
||||
void core.voiceProcessing(patch.voice).catch(() => undefined);
|
||||
}
|
||||
}
|
||||
res.json({ ok: true, result: updated });
|
||||
})
|
||||
);
|
||||
@@ -655,6 +678,20 @@ export function startWebUi(deps: WebUiDeps): WebUiHandle {
|
||||
|
||||
const result = await pacedVoice(() => requireCore().voiceJoin(channelId, mute));
|
||||
deps.getPuppet()?.appendAction({ type: "voice", action: "join", channelId, mute });
|
||||
|
||||
// The core joins with processing off; put the user's resting state back.
|
||||
const resting = deps.preferences.get().voice;
|
||||
if (deps.isCoreConnected()) {
|
||||
void requireCore()
|
||||
.voiceProcessing({
|
||||
noiseSuppression: resting.noiseSuppression,
|
||||
echoCancellation: resting.echoCancellation,
|
||||
automaticGainControl: resting.automaticGainControl,
|
||||
noiseCancellation: resting.noiseCancellation
|
||||
})
|
||||
.catch(() => undefined);
|
||||
}
|
||||
|
||||
res.json({ ok: true, result });
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user