feat(voice): configurable user voice-recognition time (bargeInMs, default 700ms)
Expose the barge-in sustained-speech threshold as a dashboard bot setting "유저 음성 인식 시간" (ms). Server clamps 0..5000, persists via state_store, and the bot reads it each report round-trip; WSAI_BARGE_IN_MS/700 stays the fallback default. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -180,8 +180,13 @@ let listsByGuild = {}; // guildId -> {whitelistUsers, blacklistUsers,
|
||||
let botSettings = { bargeIn: true }; // behaviour toggles from the dashboard
|
||||
// Barge-in only fires when the Discord "speaking" (green ring) stays on for at
|
||||
// least this long — a brief blip (keyboard click, cough) shouldn't cut the bot
|
||||
// off, but a genuine ~0.7s of speech should. Tunable via WSAI_BARGE_IN_MS.
|
||||
// off, but a genuine ~0.7s of speech should. The dashboard's "유저 음성 인식 시간"
|
||||
// (botSettings.bargeInMs) wins when set; WSAI_BARGE_IN_MS / 700 is the fallback.
|
||||
const BARGE_IN_MS = Number(process.env.WSAI_BARGE_IN_MS || 700);
|
||||
function bargeInMs() {
|
||||
const v = Number(botSettings.bargeInMs);
|
||||
return Number.isFinite(v) && v >= 0 ? v : BARGE_IN_MS;
|
||||
}
|
||||
const bargeTimers = new Map(); // userId -> pending stop timer
|
||||
|
||||
// Attach the bot's audio player (so it can speak) to a fresh connection.
|
||||
@@ -214,7 +219,7 @@ function setupReceiver(connection) {
|
||||
bargeTimers.set(userId, setTimeout(() => {
|
||||
bargeTimers.delete(userId);
|
||||
try { voicePlayer.stop(true); } catch {}
|
||||
}, BARGE_IN_MS));
|
||||
}, bargeInMs()));
|
||||
}
|
||||
activeSubs.add(userId);
|
||||
if (!perUser.has(userId)) perUser.set(userId, { opusPackets: 0, pcmFrames: 0 });
|
||||
|
||||
Reference in New Issue
Block a user