-
-
Noise Supression
-
- {isLoading &&
}
-
-
-
- Enable AI noise suppression! Make some noise—like becoming an air conditioner, or a vending machine fan—while speaking. Your friends will hear nothing but your beautiful voice ✨
-
-
;
-}
-
-export default definePlugin({
- name: "AI Noise Suppression",
- description: "Uses an open-source AI model (RNNoise) to remove background noise from your microphone",
- authors: [Devs.Vap],
- settings,
- enabledByDefault: true,
-
- patches: [
- {
- // Pass microphone stream to RNNoise
- find: "window.webkitAudioContext",
- replacement: {
- match: /(?<=\i\.acquire=function\((\i)\)\{return )navigator\.mediaDevices\.getUserMedia\(\1\)(?=\})/,
- replace: "$&.then(stream => $self.connectRnnoise(stream, $1.audio))"
- },
- },
- {
- // Noise suppression button in call modal
- find: "renderNoiseCancellation()",
- replacement: {
- match: /(?<=(\i)\.jsxs?.{0,70}children:\[)(?=\i\?\i\.renderNoiseCancellation\(\))/,
- replace: (_, react) => `${react}.jsx($self.NoiseSupressionButton, {}),`
- },
- },
- {
- // Give noise suppression component a "shouldShow" prop
- find: "Masks.PANEL_BUTTON",
- replacement: {
- match: /(?<==(\i)\.tooltipForceOpen.{0,100})(?=tooltipClassName:)/,
- replace: (_, props) => `shouldShow: ${props}.shouldShow,`
- }
- },
- {
- // Noise suppression option in voice settings
- find: "Messages.USER_SETTINGS_NOISE_CANCELLATION_KRISP",
- replacement: [{
- match: /(?<=(\i)=\i\?\i\.KRISP:\i.{1,20}?;)/,
- replace: (_, option) => `if ($self.isEnabled()) ${option} = ${JSON.stringify(RNNOISE_OPTION)};`,
- }, {
- match: /(?=\i&&(\i)\.push\(\{name:(?:\i\.){1,2}Messages.USER_SETTINGS_NOISE_CANCELLATION_KRISP)/,
- replace: (_, options) => `${options}.push({ name: "AI (RNNoise)", value: "${RNNOISE_OPTION}" });`,
- }, {
- match: /(?<=onChange:function\((\i)\)\{)(?=(?:\i\.){1,2}setNoiseCancellation)/,
- replace: (_, option) => `$self.setEnabled(${option}.value === ${JSON.stringify(RNNOISE_OPTION)});`,
- }],
- },
- ],
-
- setEnabled,
- isEnabled: () => settings.store.isEnabled,
- async connectRnnoise(stream: MediaStream, isAudio: boolean): Promise