fix(voice): stabilize deepfilter input and enforce legacy AGC constraints
This commit is contained in:
parent
3cc12c8b48
commit
d387d85dac
|
|
@ -139,6 +139,15 @@ const buildMicConstraints = (devices: TDeviceSettings): MediaTrackConstraints =>
|
|||
legacy.googEchoCancellation = true;
|
||||
legacy.googAutoGainControl = true;
|
||||
legacy.googTypingNoiseDetection = true;
|
||||
} else {
|
||||
// Chromium variants can still honor legacy goog* constraints.
|
||||
// Mirror our intended DSP state explicitly to avoid implicit AGC.
|
||||
const legacy = constraints as unknown as Record<string, unknown>;
|
||||
legacy.googHighpassFilter = false;
|
||||
legacy.googNoiseSuppression = !!constraints.noiseSuppression;
|
||||
legacy.googEchoCancellation = !!constraints.echoCancellation;
|
||||
legacy.googAutoGainControl = !!constraints.autoGainControl;
|
||||
legacy.googTypingNoiseDetection = false;
|
||||
}
|
||||
|
||||
return constraints;
|
||||
|
|
@ -410,6 +419,7 @@ const VoiceProvider = memo(({ children }: TVoiceProviderProps) => {
|
|||
const dest = ctx.createMediaStreamDestination();
|
||||
|
||||
let current: AudioNode = source;
|
||||
let preGainNode: GainNode | undefined;
|
||||
let deepFilterNode: AudioWorkletNode | undefined;
|
||||
let deepFilterCore: DeepFilterNet3Core | undefined;
|
||||
let rnnoiseNode: AudioWorkletNode | undefined;
|
||||
|
|
@ -420,6 +430,7 @@ const VoiceProvider = memo(({ children }: TVoiceProviderProps) => {
|
|||
gateNode?.disconnect();
|
||||
rnnoiseNode?.disconnect();
|
||||
deepFilterNode?.disconnect();
|
||||
preGainNode?.disconnect();
|
||||
source.disconnect();
|
||||
dest.disconnect();
|
||||
deepFilterCore?.destroy?.();
|
||||
|
|
@ -438,6 +449,13 @@ const VoiceProvider = memo(({ children }: TVoiceProviderProps) => {
|
|||
|
||||
try {
|
||||
if (useDeepFilterNet) {
|
||||
// Mild pre-gain helps keep quiet speech above the model floor
|
||||
// without aggressively boosting background noise.
|
||||
preGainNode = ctx.createGain();
|
||||
preGainNode.gain.value = 1.35;
|
||||
current.connect(preGainNode);
|
||||
current = preGainNode;
|
||||
|
||||
const deepFilterSuppression = sensitivityToDeepFilterLevel(
|
||||
devices.voiceSensitivity ?? 70
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue