CRNNEventDetector<T>
Models & Types · AiDotNet.Audio.Classification
CRNN (Convolutional Recurrent Neural Network) model for Sound Event Detection.
Inheritance: NeuralNetworkBase<T> → AudioNeuralNetworkBase<T> → AudioClassifierBase<T> → CRNNEventDetector<T>
Implements: IAudioEventDetector<T>
For Beginners
CRNN is like a two-stage sound detective:
Stage 1 (CNN): Looks at short moments of the spectrogram and identifies spectral patterns. “This frequency pattern looks like a door slam” or “These harmonics look like speech.”
Stage 2 (RNN): Reads those patterns over time like a story. “The door slam pattern appeared briefly at 2.3 seconds and ended at 2.5 seconds.”
Together, they can tell you WHAT sounds happened and WHEN they happened.
Usage:
How It Works
CRNN for SED (Cakir et al., 2017) is the standard baseline architecture for the DCASE Sound Event Detection challenge. It combines CNN layers for spectral feature extraction with bidirectional GRU/LSTM layers for temporal modeling, producing frame-level event probabilities. Despite its simplicity compared to Transformer-based models, CRNN remains competitive and is widely used as a strong baseline.
Architecture:
- CNN blocks: 3 convolutional blocks (64/128/256 channels) with batch normalization,
ReLU activation, and frequency-axis pooling. Extracts local spectro-temporal features.
- RNN layers: 2 bidirectional GRU layers (128 hidden units each) that model
temporal dependencies across frames. Bidirectional processing captures both past and future context.
- Classification head: Frame-level linear projection with sigmoid activation
for multi-label detection (multiple events can occur simultaneously).
Constructors
| Constructor | Summary |
|---|---|
CRNNEventDetector(NeuralNetworkArchitecture<T> architecture, CRNNEventDetectorOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer) |
Creates a CRNNEventDetector for native training mode with the default objective. |
CRNNEventDetector(NeuralNetworkArchitecture<T> architecture, CRNNEventDetectorOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) |
Creates a CRNN SED model for native training mode. |
CRNNEventDetector(NeuralNetworkArchitecture<T> architecture, string modelPath, CRNNEventDetectorOptions options) |
Creates a CRNNEventDetector for native training mode with the default objective. |
Properties
| Property | Summary |
|---|---|
IReadOnlyList<string> EventLabels { get; } |
|
IReadOnlyList<string> SupportedEvents { get; } |
|
double TimeResolution { get; } |
Methods
| Method | Summary |
|---|---|
AudioEventResult<T> Detect(Tensor<T> audio) |
|
AudioEventResult<T> Detect(Tensor<T> audio, T threshold) |
|
AudioEventResult<T> DetectSpecific(Tensor<T> audio, IReadOnlyList<string> eventTypes) |
|
AudioEventResult<T> DetectSpecific(Tensor<T> audio, IReadOnlyList<string> eventTypes, T threshold) |
|
IStreamingEventDetectionSession<T> StartStreamingSession() |
|
IStreamingEventDetectionSession<T> StartStreamingSession(int sampleRate, T threshold) |
|
ModelMetadata<T> GetModelMetadata() |
|
Task<AudioEventResult<T>> DetectAsync(Tensor<T> audio, CancellationToken cancellationToken) |
|
Tensor<T> GetEventProbabilities(Tensor<T> audio) |
Fields
| Field | Summary |
|---|---|
string[] AudioSetLabels |
AudioSet-527 standard event labels. |