diff --git a/src/audio/webrtc_ns2/Kconfig b/src/audio/webrtc_ns2/Kconfig index b3e7b50bb197..b88edbcbc193 100644 --- a/src/audio/webrtc_ns2/Kconfig +++ b/src/audio/webrtc_ns2/Kconfig @@ -11,9 +11,9 @@ config COMP_WEBRTC_NS2 (music, babble, keyboard) than the classic spectral Wiener filter (COMP_WEBRTC_NS). - The module is single-input, single-output and internally emits a - per-frame VAD probability (0.0–1.0) via NOTIFIER_ID_VAD, making it - a combined denoiser and activity detector. + The module is single-input, single-output and also computes a + per-frame VAD probability (0.0–1.0), making it a combined denoiser + and activity detector. Requirements: - Floating-point unit (FPU=y on ACE30/PTL; soft-float also works @@ -49,13 +49,15 @@ config WEBRTC_NS2_CHANNELS_MAX channel. Set to 1 for pure mono capture pipelines. config WEBRTC_NS2_VAD_NOTIFY - bool "Emit NOTIFIER_ID_VAD event from RNNoise VAD probability" + bool "Make a VAD decision from the RNNoise VAD probability" default y help RNNoise returns a per-frame speech probability in [0.0, 1.0]. When - this option is enabled the module broadcasts a NOTIFIER_ID_VAD event - (speech=1 / silence=0) using a configurable threshold, providing a + this option is enabled the module turns it into a speech=1 / + silence=0 decision using a configurable threshold, providing a combined denoiser + VAD without running a separate webrtc_vad module. + Delivering the decision to other components is not implemented + yet: the module only logs changes at debug level. config WEBRTC_NS2_VAD_THRESHOLD_PCT int "VAD threshold as percentage of max probability (0-100)" diff --git a/src/audio/webrtc_ns2/README.md b/src/audio/webrtc_ns2/README.md index 4060834c6691..4bc586d8317a 100644 --- a/src/audio/webrtc_ns2/README.md +++ b/src/audio/webrtc_ns2/README.md @@ -7,7 +7,7 @@ Wraps Xiph's [RNNoise](https://github.com/xiph/rnnoise) — a recurrent neural n ## Features - **Deep Learning Suppression**: Uses a hybrid DSP + deep recurrent neural network structure (GRU) for suppressing non-stationary noise (such as keyboard clicks, speech babble, or music). -- **VAD Output**: Calculates speech probability per frame and broadcasts binary voice activity events via `NOTIFIER_ID_VAD`. +- **VAD Output**: Calculates speech probability per frame and turns it into a binary voice activity decision. Delivering it to other components is not implemented yet: the module only logs changes at debug level. - **Locked Rate (48 kHz)**: Runs exclusively at **48000 Hz** (requires an ASRC upstream if the DAI runs at another rate). - **10 ms Process Window**: Accumulates pipeline periods to process complete 480-sample mono frames. - **Float Scaled**: normalizes standard SOF float pipelines to the internal full-scale float representation ($\pm 32768.0$) used during training. @@ -41,11 +41,11 @@ graph TD Backend -->|Scale back to ±1.0| Core Core -->|Interleaved output| OutBuf[Output Audio Buffer] - VAD -->|Yes: 1 / No: 0| Notifier[NOTIFIER_ID_VAD Event] + VAD -->|Yes: 1 / No: 0| Log[Debug log of state changes] ``` ### Components -- `webrtc_ns2.c`: Handles format conversions, period packing, and the VAD event notifier. +- `webrtc_ns2.c`: Handles format conversions, period packing, and the VAD decision. - `webrtc_ns2-rnn.c`: Real RNNoise library integration backend. - `webrtc_ns2-stub.c`: Pass-through stub that always outputs `1.0` VAD probability. - `webrtc_ns2.cmake`: Controls downloading the `rnnoise` Git repository and building its files. @@ -79,7 +79,7 @@ Requires `west update` to retrieve `modules/audio/rnnoise` (SHA `70f1d256`). | `CONFIG_COMP_WEBRTC_NS2` | n | y / m / n | Enable RNNoise module | | `CONFIG_COMP_WEBRTC_NS2_STUB` | y | y / n | Use pass-through stub | | `CONFIG_WEBRTC_NS2_CHANNELS_MAX` | 2 | 1 - 8 | Maximum channels supported | -| `CONFIG_WEBRTC_NS2_VAD_NOTIFY` | y | y / n | Emit NOTIFIER_ID_VAD events | +| `CONFIG_WEBRTC_NS2_VAD_NOTIFY` | y | y / n | Make a VAD decision (logged only for now) | | `CONFIG_WEBRTC_NS2_VAD_THRESHOLD_PCT` | 50 | 0 - 100 | VAD speech threshold percentage | --- diff --git a/src/audio/webrtc_ns2/webrtc_ns2.c b/src/audio/webrtc_ns2/webrtc_ns2.c index cc857df4f2c4..f57874bda750 100644 --- a/src/audio/webrtc_ns2/webrtc_ns2.c +++ b/src/audio/webrtc_ns2/webrtc_ns2.c @@ -11,8 +11,9 @@ // accumulated until a full frame is ready. // // As a bonus, the per-frame VAD probability returned by RNNoise is -// compared against a configurable threshold and a NOTIFIER_ID_VAD event -// is fired, making this a drop-in combined denoiser + voice detector. +// compared against a configurable threshold. Delivering the decision to +// other components is not implemented yet: the module only logs changes +// at debug level. #include #include diff --git a/src/audio/webrtc_ns2/webrtc_ns2.h b/src/audio/webrtc_ns2/webrtc_ns2.h index 3ff41e778f6d..653e4cc6802f 100644 --- a/src/audio/webrtc_ns2/webrtc_ns2.h +++ b/src/audio/webrtc_ns2/webrtc_ns2.h @@ -8,7 +8,7 @@ * at 48 kHz in 480-sample (10 ms) mono frames. One RNNoise instance is * allocated per channel and processes channel audio independently. * - * In addition to denoising, the module broadcasts a NOTIFIER_ID_VAD event + * In addition to denoising, the module makes a voice activity decision * from the per-frame speech probability returned by rnnoise_process_frame(). */ #ifndef __SOF_AUDIO_WEBRTC_NS2_H__ diff --git a/src/audio/webrtc_vad/Kconfig b/src/audio/webrtc_vad/Kconfig index 44a548257ca9..daf11f9d4af9 100644 --- a/src/audio/webrtc_vad/Kconfig +++ b/src/audio/webrtc_vad/Kconfig @@ -7,9 +7,10 @@ config COMP_WEBRTC_VAD Select to include the WebRTC Voice Activity Detection module. It wraps the libfvad library (a standalone pure-C extraction of the WebRTC GMM VAD) behind the SOF module interface. The module - inspects each 10/20/30 ms PCM frame and annotates it as speech or - non-speech via a NOTIFIER_ID_VAD notifier event, leaving the audio - stream unmodified (pass-through). + inspects each 10/20/30 ms PCM frame and classifies it as speech or + non-speech, leaving the audio stream unmodified (pass-through). + Delivering the decision to other components is not implemented + yet: the module only logs state changes at debug level. libfvad supports 8, 16, 32 and 48 kHz; it resamples to 8 kHz internally. The GMM classifier operates in Q15 fixed-point and diff --git a/src/audio/webrtc_vad/README.md b/src/audio/webrtc_vad/README.md index 4bb3a01d2fd3..90e5a834f3a4 100644 --- a/src/audio/webrtc_vad/README.md +++ b/src/audio/webrtc_vad/README.md @@ -8,7 +8,7 @@ Wraps [libfvad](https://github.com/dpirch/libfvad) — a standalone, pure-C, BSD - **GMM Classifier**: Uses Gaussian Mixture Models (GMM) for robust speech vs. noise classification. - **Pass-through Data Flow**: Does not modify PCM audio; passes it through untouched. -- **Notifier Integration**: Broadcasts binary speech/silence decisions (`1` or `0`) via SOF's `NOTIFIER_ID_VAD` event channel. +- **Speech/Silence Decision**: Makes a binary speech/silence decision (`1` or `0`) per frame. Delivering it to other components is not implemented yet: the module only logs state changes at debug level. - **Low Power & Fixed-Point**: Operates entirely in Q15 fixed-point; requires no floating-point hardware (FPU). - **Flexible Frame Sizes**: Supports 10 ms, 20 ms, and 30 ms classification frame windows. - **Multichannel Support**: Classifies channel-0 and copies remaining channels. @@ -18,7 +18,7 @@ Wraps [libfvad](https://github.com/dpirch/libfvad) — a standalone, pure-C, BSD ## Architecture & Data Flow -The following Mermaid diagram outlines how audio data flows through the pipeline and how the classification events are broadcast to other modules: +The following Mermaid diagram outlines how audio data flows through the pipeline and where the classification is made: ```mermaid graph TD @@ -31,9 +31,8 @@ graph TD RingBuf -->|10/20/30 ms Block| Backend[webrtc_vad-fvad.c Backend] Backend -->|libfvad GMM Classify| Decision{Speech Detected?} - %% Notifications - Decision -->|Yes: 1 / No: 0| Notifier[NOTIFIER_ID_VAD Event] - Notifier -->|.subscribe| SubscribedModules[e.g., webrtc_ns2, Host, KWD] + %% Decision (delivery to consumers not implemented yet) + Decision -->|Yes: 1 / No: 0| Log[Debug log of state changes] ``` ### Components @@ -85,7 +84,7 @@ The module functions as a simple 1-in / 1-out effect widget. Connect it directly DAI Copier (Mic) ---> [ webrtc-vad ] ---> [ webrtc-ns ] ---> Host Copier ``` -In this routing model, `webrtc-vad` runs first. Any downstream module or host application subscribing to the `NOTIFIER_ID_VAD` event will receive real-time classification changes instantly without querying the module adapter. +In this routing model, `webrtc-vad` runs first and classifies the audio before noise suppression. --- diff --git a/src/audio/webrtc_vad/webrtc_vad-stub.c b/src/audio/webrtc_vad/webrtc_vad-stub.c index 278fb3545a6a..ff6263167f47 100644 --- a/src/audio/webrtc_vad/webrtc_vad-stub.c +++ b/src/audio/webrtc_vad/webrtc_vad-stub.c @@ -7,7 +7,7 @@ // This lets the SOF module glue (init/prepare/process/reset/free, the LLEXT // manifest and topology wiring) be built and exercised in CI without pulling // in libfvad. The stub always reports SPEECH (decision = 1) so audio flow -// and notifier events can be validated end-to-end. The real libfvad backend +// and the classification path can be validated end-to-end. The real libfvad backend // lives in webrtc_vad-fvad.c and provides the same webrtc_vad_backend symbol. #include diff --git a/src/audio/webrtc_vad/webrtc_vad.c b/src/audio/webrtc_vad/webrtc_vad.c index 7f2fdb8b9f62..07a2d05a995b 100644 --- a/src/audio/webrtc_vad/webrtc_vad.c +++ b/src/audio/webrtc_vad/webrtc_vad.c @@ -10,9 +10,10 @@ // // The module is a pass-through PCM effect: audio flows from source to sink // unmodified. On each complete VAD frame (10/20/30 ms at the configured -// rate), the module classifies channel-0 audio and broadcasts the binary -// speech/non-speech decision via NOTIFIER_ID_VAD so that downstream -// consumers (keyword detection gating, host-side VAD) can react. +// rate), the module classifies channel-0 audio into a binary +// speech/non-speech decision. Delivering the decision to consumers (keyword +// detection gating, host-side VAD) is not implemented yet: the module only +// logs state changes at debug level. // // Because the WebRTC VAD requires a fixed 10 ms frame size which may differ // from the SOF pipeline period, the module accumulates incoming S16 samples @@ -208,8 +209,8 @@ static void webrtc_vad_accumulate(struct webrtc_vad_comp_data *cd, * webrtc_vad_classify_pending() - Drain the accumulator, classifying full frames. * @mod: Pointer to the processing module. * - * For each complete VAD frame accumulated, calls the backend and fires a - * NOTIFIER_ID_VAD event with the binary decision. + * For each complete VAD frame accumulated, calls the backend and logs + * changes of the binary decision. */ static void webrtc_vad_classify_pending(struct processing_module *mod) { diff --git a/src/audio/webrtc_vad/webrtc_vad.h b/src/audio/webrtc_vad/webrtc_vad.h index ab51e70209c3..f3b811a47029 100644 --- a/src/audio/webrtc_vad/webrtc_vad.h +++ b/src/audio/webrtc_vad/webrtc_vad.h @@ -6,8 +6,8 @@ * * Wraps libfvad — a standalone pure-C BSD-3 port of the WebRTC GMM VAD — * behind the SOF module_interface. The module inspects each incoming PCM - * frame and emits a binary speech/non-speech decision as a SOF notifier - * event, leaving the audio data stream unmodified (pass-through). + * frame and makes a binary speech/non-speech decision, leaving the audio + * data stream unmodified (pass-through). * * The actual VAD work is delegated to a pluggable backend so the SOF glue * can be validated with a dependency-free stub (webrtc_vad-stub.c) before @@ -23,7 +23,7 @@ /* Maximum accumulation buffer: 30 ms at 48 kHz, one channel of int16. */ #define WEBRTC_VAD_MAX_FRAME_SAMPLES (30 * 48) -/* VAD decision values emitted via notifier. */ +/* VAD decision values. */ #define WEBRTC_VAD_SILENCE 0 #define WEBRTC_VAD_SPEECH 1 diff --git a/src/include/sof/lib/notifier.h b/src/include/sof/lib/notifier.h index ee11cdf9ac07..90584ee33c09 100644 --- a/src/include/sof/lib/notifier.h +++ b/src/include/sof/lib/notifier.h @@ -25,7 +25,6 @@ enum notify_id { NOTIFIER_ID_DMA_COPY, /* struct dma_cb_data* */ NOTIFIER_ID_DMA_IRQ, /* struct dma_chan_data * */ NOTIFIER_ID_MIC_PRIVACY_STATE_CHANGE, /* struct mic_privacy_settings * */ - NOTIFIER_ID_VAD, /* int * (WEBRTC_VAD_SPEECH / WEBRTC_VAD_SILENCE) */ NOTIFIER_ID_COUNT }; diff --git a/src/kernel/ipc/ipc3/dai.c b/src/kernel/ipc/ipc3/dai.c index 5b0efff590da..723151fd9a78 100644 --- a/src/kernel/ipc/ipc3/dai.c +++ b/src/kernel/ipc/ipc3/dai.c @@ -399,9 +399,6 @@ void dai_dma_release(struct dai_data *dd, struct comp_dev *dev) /* put the allocated DMA channel first */ #ifdef CONFIG_ZEPHYR_NATIVE_DRIVERS if (dd->chan_index >= 0) { - /* remove callback */ - notifier_unregister(dev, &dd->dma->chan[dd->chan_index], - NOTIFIER_ID_DMA_COPY); dma_release_channel(dd->dma->z_dev, dd->chan_index); dd->chan_index = -EINVAL; } diff --git a/tools/topology/topology2/development/cavs-nocodec-webrtc-ns.conf b/tools/topology/topology2/development/cavs-nocodec-webrtc-ns.conf index 017a9b7a2c30..d9d0c7b330f9 100644 --- a/tools/topology/topology2/development/cavs-nocodec-webrtc-ns.conf +++ b/tools/topology/topology2/development/cavs-nocodec-webrtc-ns.conf @@ -10,7 +10,7 @@ # # SSP0 RX ──────(3)──> VAD + NS ──(4)──> PCM0 capture # -# The VAD module fires NOTIFIER_ID_VAD events; the NS module removes +# The VAD module classifies speech/silence; the NS module removes # stationary background noise. Both run on the same capture pipeline. # # Board: any cAVS/ACE platform with a nocodec SSP loopback fixture. diff --git a/tools/topology/topology2/include/components/webrtc-ns2.conf b/tools/topology/topology2/include/components/webrtc-ns2.conf index 522da50b6c7f..31037bc34071 100644 --- a/tools/topology/topology2/include/components/webrtc-ns2.conf +++ b/tools/topology/topology2/include/components/webrtc-ns2.conf @@ -3,7 +3,7 @@ # # RNNoise deep-learning noise suppressor widget (floating-point, 48 kHz). # Single input, single output. Processes 480-sample (10 ms) frames. -# Also emits a per-frame VAD probability as a NOTIFIER_ID_VAD event. +# Also computes a per-frame VAD probability. # # IMPORTANT: pipeline sample rate MUST be 48000 Hz. Insert an ASRC # upstream if the DAI runs at a different rate. diff --git a/tools/topology/topology2/include/components/webrtc-vad.conf b/tools/topology/topology2/include/components/webrtc-vad.conf index 908a19dc3062..0e5027ec762e 100644 --- a/tools/topology/topology2/include/components/webrtc-vad.conf +++ b/tools/topology/topology2/include/components/webrtc-vad.conf @@ -2,8 +2,8 @@ # Common widget webrtc-vad # # WebRTC libfvad Voice Activity Detector widget. Single input, single output. -# Passes PCM audio through while broadcasting a NOTIFIER_ID_VAD event each -# 10/20/30 ms frame with speech/silence classification. +# Passes PCM audio through while classifying each 10/20/30 ms frame as +# speech or silence. # # Usage: # Object.Widget.webrtc-vad."N" {