Skip to content

rnn noise supression#72

Open
thinkter wants to merge 2 commits into
ACM-VIT:mainfrom
thinkter:supression
Open

rnn noise supression#72
thinkter wants to merge 2 commits into
ACM-VIT:mainfrom
thinkter:supression

Conversation

@thinkter

Copy link
Copy Markdown
Contributor

No description provided.

@vercel

vercel Bot commented May 19, 2026

Copy link
Copy Markdown

@thinkter is attempting to deploy a commit to the Outreach - ACM Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps

greptile-apps Bot commented May 19, 2026

Copy link
Copy Markdown

Greptile Summary

Adds RNNoise-based noise suppression to the meeting audio path using @sapphi-red/web-noise-suppressor. A new API route serves the WASM and AudioWorklet files from node_modules, and a new rnnoise.ts library wraps the microphone track in an AudioContext processing graph, exposing a PublishedAudioSession that is threaded through every audio-producer creation and replacement site.

  • rnnoise.ts: Module-level WASM/module promise caching, idempotent cleanup with a cleanedUp guard, and graceful per-error fallback — permanently disabling only on NotSupportedError/InvalidStateError while resetting caches for transient failures.
  • useMeetMedia.ts / useMeetSocket.ts: PublishedAudioSession lifecycle is carefully managed across mute-toggle, device-switch, producer recovery, and transport-close code paths, with pendingAudioSession locals ensuring cleanup even on error.
  • route.ts: Serves WASM/worklet assets with a dual-path fallback (app vs. workspace-root node_modules) and long-lived immutable caching; two minor robustness gaps noted (prototype-property bypass and missing error catch).

Confidence Score: 5/5

Safe to merge; the noise suppression integration is well-structured, cleanup paths are consistently guarded, and the only gaps are in the asset-serving route where certain edge-case requests return a 500 instead of a 404.

The core session lifecycle in rnnoise.ts and all the hook integration sites handle both happy-path and error cases correctly. The two issues in route.ts are robustness nits that do not affect the audio pipeline at all.

apps/web/src/app/api/rnnoise/[asset]/route.ts — the asset-name guard and the missing error catch are worth fixing before this route is exposed in production.

Important Files Changed

Filename Overview
apps/web/src/app/api/rnnoise/[asset]/route.ts New route serving WASM/worklet assets from node_modules; has two robustness gaps: in operator on the asset map matches prototype properties (unintended 500 vs 404), and missing try/catch around the file read can leak filesystem paths in errors.
apps/web/src/app/lib/rnnoise.ts New RNNoise integration library; clean lifecycle with idempotent cleanup, module-level WASM caching with proper promise memoization, and graceful fallback to raw audio on transient vs permanent errors.
apps/web/src/app/hooks/useMeetMedia.ts Threads PublishedAudioSession through all audio producer creation, replacement, and cleanup paths; cleanup is correctly guarded in both success and error branches including the device-switch and mute-toggle flows.
apps/web/src/app/hooks/useMeetSocket.ts Adds session creation on initial join produce call and cleanup on all producer-close paths (forced close, transport close, server-side close events).
apps/web/src/app/hooks/useMeetRefs.ts Adds publishedAudioSessionRef to the shared refs object; straightforward change with no issues.

Sequence Diagram

sequenceDiagram
    participant Hook as useMeetMedia/useMeetSocket
    participant Lib as rnnoise.ts
    participant API as /api/rnnoise/[asset]
    participant AC as AudioContext (browser)
    participant MS as mediasoup Transport

    Hook->>Lib: createPublishedAudioSession(inputTrack)
    Lib->>API: fetch rnnoiseWorklet.js + rnnoise.wasm
    API-->>Lib: worklet JS / WASM binary
    Lib->>AC: "new AudioContext({ sampleRate: 48000 })"
    Lib->>AC: audioWorklet.addModule(workletURL)
    Lib->>AC: createMediaStreamSource(inputTrack)
    Lib->>AC: "new RnnoiseWorkletNode(ctx, { wasmBinary })"
    Lib->>AC: createMediaStreamDestination()
    AC-->>Lib: outputTrack (processed audio)
    Lib-->>Hook: "PublishedAudioSession { inputTrack, outputTrack, cleanup }"
    Hook->>MS: "transport.produce({ track: outputTrack })"
    MS-->>Hook: audioProducer
    Note over Hook,Lib: On cleanup / transport close
    Hook->>Lib: cleanupPublishedAudioSession(session)
    Lib->>AC: source.disconnect(), node.disconnect(), node.destroy()
    Lib->>AC: outputTrack.stop(), audioContext.close()
Loading

Reviews (2): Last reviewed commit: "fixes" | Re-trigger Greptile

Comment thread apps/web/src/app/lib/rnnoise.ts
Comment thread apps/web/src/app/lib/rnnoise.ts
Comment thread apps/web/src/app/api/rnnoise/[asset]/route.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant