John Messinger

Is it a trumpet?

A CNN that classifies brass instruments from log-mel spectrograms, built to test whether a model trained only on B-flat trumpet can recognize a C trumpet.

Status
Concluded. Concluded.
Built with
Python, Convolutional neural networks, Log-mel spectrograms

The problem

A B-flat trumpet and a C trumpet are close relatives. The C is a little shorter and a little brighter. A trumpet player hears them as the same instrument family with a different color.

That makes them a good test of what an audio classifier actually learns. If a model trained only on B-flat trumpet recognizes a C trumpet as a trumpet, it learned something about timbre. If it does not, it probably learned a fingerprint of its training recordings.

What I built

A convolutional neural network that classifies brass instruments from log-mel spectrograms, the time-frequency images that approximate how the ear spreads sound across pitch. It was a four-way classification, so chance is 25%.

The training set held only B-flat trumpet for the trumpet class. I also tested it on my own recordings of the offstage fanfare from Beethoven’s Leonore Overture No. 3.

What I found

Held-out test accuracy was 61.0%, against a 25% chance baseline.

The more interesting result was the gap between validation and test accuracy. The model did much better on validation data than on the test set. Validation and training came from the same sample libraries; the test set did not. That gap is domain shift: the model learned features of the recording setup alongside features of the instrument.

So the honest answer to the title is: partly. The model learned enough timbre to beat chance by a wide margin on unfamiliar audio, and enough of its recording environment to lose a lot of accuracy outside it.


All projects