Speech & Audio AI Lab

Interactive labs for speech recognition, speech synthesis, and audio in general: in-browser DSP experiments, algorithms, datasets, and a learning path, without storing any recording.

43experiments

Sound event detection

Audio Event Detection

Detect audio events over time by tracking frame energy and determining their onset and offset, then compare with an external event model.

Advanced

Educational content in the form of a scientific draft that needs expert review before being adopted as an academic reference. No experimental result that was not actually run is shown here.

Prerequisites

  • Python with numpy
  • Synthetic signals or licensed clips

Tools

  • audio-classification
  • voice-activity-detection
  • spectrogram-explorer

Implementation Steps

  1. Slice the signal into frames
  2. Compute the energy or a spectral feature for each frame
  3. Apply a threshold and a median filter to smooth the decision
  4. Extract event intervals (onset and offset)
  5. Compare the intervals with manual labeling
  6. Compute precision and recall with a time tolerance
  7. Compare with a trained event model if available

Code

JavaScript / PythonImplemented and Tested
import numpy as np
from scipy.signal import medfilt
sr = 8000
rng = np.random.default_rng(2)
x = 0.02 * rng.standard_normal(4 * sr)
for a, b in ((sr, sr + 2000), (3 * sr, 3 * sr + 4000)):
    x[a:b] += 0.6 * rng.standard_normal(b - a)
n = 200
e = (x[:len(x) // n * n].reshape(-1, n) ** 2).mean(axis=1)
d = medfilt((e > 5 * np.median(e)).astype(float), 5) > 0
edges = np.flatnonzero(np.diff(np.r_[0, d, 0]))
print([(float(s * n / sr), float(t * n / sr)) for s, t in zip(edges[::2], edges[1::2])])

Expected Results

The two synthetic event intervals are expected to be extracted to within frame-boundary approximation, with accuracy declining at higher noise.

These are educational expectations and not experimental results actually measured.

Project Tests

  • Compare the extracted boundaries with the known boundaries
  • Change the median filter size and observe its effect
  • Test overlapping events and monitor the errors

References

  1. Kong et al.. PANNs: Large-Scale Pretrained Audio Neural Networks for Audio Pattern Recognition. arXiv (2019). DOI
  2. Gemmeke et al.. Audio Set: An ontology and human-labeled dataset for audio events (2017). Source
  3. Google. YAMNet (Google, Kaggle Models). Kaggle Models. Source

Audio processing in the experiments takes place inside your browser. Audio, texts, and conversations are not saved on the server. Privacy Policy