Skip to content
All projects

Health

Respiratory Sound Classifier

A model that listens to a few seconds of breathing or coughing and predicts which of five respiratory conditions it sounds like. It reuses Google's YAMNet audio model to understand the sound and trains a small network on top.

Gets 87% of held-out clips right across five classes while training a network of only about 68 thousand parameters.

87% of held-out clips classified correctly across five conditions
Each condition leaves a different pattern in the sound
COPD and healthy lungs are the easiest to tell apart

01 / 0387% of held-out clips classified correctly across five conditions

Overview

Doctors learn a lot from how someone breathes, but a stethoscope is only useful when a trained ear is listening. This project explores whether a model can pick up the same patterns from a short recording, as a starting point for low-cost screening tools.

It uses the balanced ICBHI respiratory sound dataset with five labels: Bronchial, asthma, COPD, healthy and pneumonia. Each clip goes through YAMNet, a model Google trained on millions of everyday sounds, which turns it into 1024 numbers that describe what it hears. A small PyTorch network then learns to map those numbers to a condition.

The result is a research prototype, not a diagnostic device. A Colab notebook walks through the whole pipeline: loading the data, extracting features, training, and plotting how well it does.

Features

  • Classify a breathing or cough recording into one of five respiratory conditions
  • See confidence scores for every class, not just the top guess
  • Retrain the classifier end to end with one script or the Colab notebook
  • Inspect results with a confusion matrix, per-class report and learning curves
  • Run predictions on new audio through a small inference module

Challenges

  • The dataset is small, so a large model memorizes it. Training on frozen YAMNet embeddings with a compact network, batch normalization and 60% dropout kept validation accuracy close to training accuracy.
  • Classes are uneven, so the loss uses balanced class weights and label smoothing, and the train and validation split is stratified so every condition shows up in both.
  • Recordings vary in length, while the model expects a fixed window. Every clip is resampled to 16 kHz and padded or trimmed to the same 4.35 seconds used in training, both when training and at prediction time.
  • An earlier version used PANNs features at 4096 dimensions. Switching to YAMNet's 1024-dimensional embeddings made the model smaller and less prone to overfitting.