A Model You Can Hear: Audio Identification with Playable Prototypes

Machine learning techniques have proved useful for classifying and analyzing audio content. However, recent methods typically rely on abstract and high-dimensional representations that are difficult to interpret. Inspired by transformation-invariant approaches developed for image and 3D data, we propose an audio identification model based on learnable spectral prototypes. Equipped with dedicated transformation networks, these prototypes can be used to cluster and classify input audio samples from large collections of sounds. Our model can be trained with or without supervision and reaches state-of-the-art results for speaker and instrument identification, while remaining easily interpretable. The code is available at: https://github.com/romainloiseau/a-model-you-can-hear


INTRODUCTION
The emergence of deep learning approaches dedicated to audio analysis has led to significant performance improvements [1,2]. Although these methods take sound excerpts as input, they typically rely on high-dimensional latent spaces, making the interpretation of their decisions difficult and limiting the insights gained on the considered data. Furthermore, such methods typically require large corpora of annotated sounds for supervision. We take a different approach, inspired by the recent Deep Transformation-Invariant (DTI) clustering [3] framework which learns prototypes in input space to analyze images or 3D point clouds [4]. Each prototype is associated with a set of transformations (e.g. rotations or morphological transformations) learned in the manner of Spatial Transfor-  mation Networks [5]. The DTI clustering model optimizes a reconstruction loss and associates each input with the prototype that provides the best reconstruction. We propose adapting this approach to the audio domain. The prototypes become log-scaled, Mel-frequency spectrograms, and their associated learnable transformations correspond to plausible sound alterations. We also introduce an additional loss based on cross-entropy in the supervised setting, which we demonstrate can boost the classification accuracy while preserving some interpretability.

RELATED WORK
Audio Classification. Musical instrument and speaker identification are two of the standard tasks used to benchmark audio classification models. Although early musical instrument identification methods focused on distinguish- Figure 2: Method overview. Given an input sound, we predict for each prototype a gain, a pitch shift, as well as low and high frequency filters at each timestamp to generate the output. Prototypes and transformations are learned jointly using a reconstruction loss in either a supervised or unsupervised setting.
ing individual tones achieve appreciable precision, support vector machines operating on spectro-temporal sound representations can reach almost perfect accuracy. Similarly to supervised classification of instruments that play individual notes that could be considered solved [9,10], speaker identification is mostly handled by convolutional and/or recurrent neural networks [11], which achieve almost perfect performances [12]. However, these models rely on complex and abstract latent representations that are not easily interpretable and cannot be visualized as spectrograms or heard in the audio domain.

Prototype-Based Methods.
Auto-Encoders [13,14] learn a compact latent representation of an input sample and are trained using a reconstruction loss. Using regularizations and constraints, the latent space can be adjusted for various tasks, such as classification [15]. However, the learned features remain largely non-interpretable and abstract. Inspired by the literature on images [16], the authors of [17] propose to generate prototypes in the latent space and analyze their similarity to the encoded input samples using a frequency-dependent measure. Although the latent prototypes can be decoded into input space, their role in class prediction remains obfuscated, as all similarities are mixed with a learned linear layer.

Transformation-Invariant Modeling.
Deep transformation-invariant clustering [3] learns explicit prototypes in input space. Each prototype is equipped with dedicated transformation networks, allowing a small set of prototypes to faithfully represent a collection of samples. The resulting models can be used for downstream tasks such as classification [3], few-shot segmentation [4], and even multi-object instance discovery [18]. Jaderberg et al. [5] also proposes learning differentiable transformations in the input space, and feed the transformed data to a classification network. We propose to extend these ideas to the audio domain by learning prototypical log-Mel spectrograms along with adapted transformations.

METHOD
We consider a set of N audio clips x 1 , · · · , x N ∈ R F ×T , each characterized by their log-Mel spectrogram with T time steps and a spectral resolution of F bins. The samples are annotated with class labels y 1 , · · · , y N ∈ Y with Y a given class set {1, · · · , K}. Our goal is to learn an interpretable model that can perform classification and clustering for the audio sample collection x 1 , · · · , x N . Our model is based on prototypical spectrograms equipped with spectral transformation networks, which we present in Sec. 3.1. We propose an unsupervised training scheme in Sec. 3.2, and a supervised setting in Sec. 3.3. Finally, we provide details on parameterization and training of the model in Sec. 3.4.

Sound Reconstruction Model
Our model consists of K prototypes P k ∈ R F directly interpretable in the spectral domain, each equipped with a set of dedicated transformation networks (See Figure 2). Both prototypes and networks are jointly trained to reconstruct input samples. We can then use the reconstruction error as a measure of the compatibility between a sample and a given prototype.

Spectral Transformations Model.
Even a single instrument or speaker cannot be meaningfully characterized by a single sound. In fact, they are typically capable of producing a rich and varied set of sounds. We propose equipping each prototype with a set of transformation networks that learn to change specific characteristics of the prototype, such as its amplitude and pitch, so that it can faithfully approximate a wide variety of samples. This also allows the prototypes to learn more subtle audio attributes, such as timbre or intonations.
Transformation networks associated to each prototype P k take as input an audio sample x ∈ R F ×T as input and predicts a spectral transformation for each time step t in [1, T ]. For each prototype k, we propose a set of transformations specifically designed for the audio domain, illustrated in Figure 3: • Amplification. Given an audio sample x, we predict a gain G k (x) ∈ R T for all time step t. The transformation T gain g (m) adds the gain g to all frequencies of a log-Mel spectrogram m ∈ R F .
• Pitch Shifting. We map an audio sample x to a pitch shift S k (x) ∈ R T for all time step t. The transformation T pitch s (m) shifts the log-Mel spectrogram m ∈ R F by s. We use linear interpolation for handling non-integer shifts.
• High-and Low-Frequency Filter. Given an audio sample x, we define for each time t an affine low-frequency filter L k (x)[t] ∈ R F by predicting its slope and cutoff frequency. Similarly, we predict a high-frequency filter These transformations can be written as follows for a log-Mel spectrogram m ∈ R F and a mel-frequency f ∈ [1, F ]: T high with Φ(f, s) = A log 10 1 + s 10 f /A − 1 the melaware pitch shifting, with A = 2595 [19]. Our transformations have links with moment matching methods [20,21]. In fact, modulating the amplitude, pitch, and spectral support of spectrograms is similar to matching the moment of zeroth order (amplitude gain), first order (pitch shift), and second order (frequency filters).
Reconstruction Model. For each prototype k and each time step t, we successively apply the gain, pitch shift, lowpass, and high-pass transformations in this specific order. The resulting reconstruction R k (x) of an input sound x by a prototype P k is defined as follows: where R k (x)[t] denotes the t-th timestamp of the reconstruction, and • denotes the composition of transformations. Note that the chosen transformations are constrained and limited on purpose, as we want each prototype to represent a restricted and consistent set of audio samples.
We measure the quality of the reconstruction R k (x) of an input sample x by the k-th prototype as the spectrotemporal average of their 2 distance: Note that since this function is differentiable and continuous, it can be used as a loss function to train prototypes and transformation networks as defined in the next sections.

Unsupervised Training
We propose an unsupervised learning scheme in which we do not have access to labels y 1 , · · · , y N during training.
Our goal is to cluster the samples x 1 , · · · , x N into meaningful groups of sounds that can be well approximated by the same prototype spectrogram and its associated transformations. We can train our model by minimizing the following loss: This loss is the sum of the reconstruction errors with optimal cluster assignment and is a classical clustering objective used by K-means-based methods.

Supervised Training
In the supervised setting, each prototype and associated transformation networks are dedicated to a class and trained to reconstruct the samples from this class only.
Once trained, the model predicts for an input x the class of the prototype with the best reconstruction. To promote better class discrimination, we propose a dual reconstruction-prediction objective. We associate each input x with a probabilistic class prediction defined as the softmax of the negative reconstruction error between prototypes. For an input x of label y, we define the prediction loss L ce : where β is a learnable parameter. This loss encourages each prototype to specialize in reconstructing the samples of its associated class. To train our network, we use a weighted sum of both losses: with λ ce an hyperparameter set to 0.01.

Parameterization and Training Details
Architecture. We implement the functions G k , S k , L k and H k as U-Net style neural networks [23] operating on SOL [6,7] LibriSpeech [8]   the log-Mel spectrograms x ∈ R T ×F . To save parameters, all networks share the same encoder, defined as a sequence of 2-dimensional spectro-temporal convolutions and pooling operations. This encoder produces a sequence of feature maps z 0 , · · · , z R with decreasing temporal and spectral resolutions T /2 r × F/2 r . The spectral dimension of these maps is then collapsed using learned pooling operations:z r is of resolution T /2 r . Each decoder is then defined as a sequence of 1-dimensional temporal convolutions and unpooling operations. The spectral maps z 0 , · · · ,z R are used through skip-connections in the decoders. The prototypes P 1 , · · · , P K and the inverse temperature β are directly trainable parameters of the model.

Curriculum Learning.
We ensure the stability of our model by gradually increasing its complexity along the training procedure. First, we learn the raw prototypes without any transformation. Once the training loss does not decrease for 10 straight epochs, we add the gain transformation. We then add the pitch shift and spectral filters successively following the same procedure. Implementation details. We use the ADAM [24] optimizer with a learning rate of 10 −4 , and a weight decay of 10 −6 for the transformation networks and 0 for β and the prototypes. Our model has 545k parameters with K = 128 prototypes. For comparison, the reconstruction model proposed by Zinemanas et al. [17]

EXPERIMENTS
We evaluate our approach in both supervised and unsupervised settings and on two datasets.
Datasets. We consider the following datasets: • SOL [6,7]. This dataset contains 24 450 samples of individual notes played with various playing techniques by 33 different instruments and sampled at 44.1kHz. We evaluate instrument classification.
• Librispeech [8]. This 1000-hour corpus contains English speech sampled at 16kHz. We selected the 128 predominant speakers from the train-clean-360 set. We evaluate the classification of speaker. For both datasets, we randomly selected 70% of the clips for training, 10% for validation, and 20% for testing. We always use as many prototypes as the number of classes in the dataset.

Metrics.
To assess the quality of classification models, we report the following metrics: • Overall Accuracy (OA). Percentage of input samples correctly classified by our model, i.e., best reconstructed by the prototype assigned to their true class.
• Average Accuracy (AA). Average of the classwise accuracy, computed across classes without weights.
• Reconstruction error (L rec ). To assess the quality of the reconstruction, we also report the reconstruction error L rec .
Methods trained in the unsupervised setting cluster the Bassoon Horn Violin Contrabass Accordion Figure 4: Learned Meaningful Prototypes. Comparison between the average spectrogram from one class (left), and the prototypes learned in the supervised setting without (middle) and with (right) cross-entropy loss. Our model can learn spectral representations that are crisper and more discriminative than a simple average. audio samples instead of classifying them. We associate each cluster with the majority class of its assigned training samples. We can then predict for each test sample the class of its best-fitting cluster, allowing us to compute all the classification metrics.
Baselines. To put the performance of our method in context, we trained different baselines: • Classification. We trained a temporal convolutional network to classify log-Mel spectrograms. We supervise this network with the cross-entropy on the labels. This network, which does not provide a reconstruction error, is called Direct Classification. We also evaluated the AP-Net [17] approach on our datasets. However, this method is limited in its interpretability, as it relies on latent prototypes and uses a fully connected layer to classify samples based on their similarity to the prototypes.
• Clustering. We trained a two-dimensional convolutional autoencoder without skip-connections to reconstruct log-Mel spectrograms. We supervised this network with the 2 norm between the input and the reconstruction. We then use K-means [22] on the innermost feature maps to cluster the samples. We also use K-means directly on the predicted similarities between feature maps and APNet prototypes [17]. Note this last approach requires to first train APNet in a supervised setting.

Quantitative Results
Reconstruction. As can be seen in Table 1, each successive addition of a transformation decreases the reconstruction error L rec and improves the accuracy of classification. This shows that the curriculum training scheme allows our model to learn insightful and complementary spectral transformations. Supervised with the cross-entropy loss, our model reaches high accuracy, at the cost of a slightly higher reconstruction error. In fact, the additional objective not only encourages the reconstruction models R k to provide a good reconstruction for the samples of their assigned class, but also a worse reconstruction for other classes. Finally, we see that while adding frequency-filters yields better reconstruction, they hurt classification per-formance on SOL [6,7] in the unsupervised setting. We hypothesize that the filters makes the transformation too expressive, reducing the specificities of the prototypes.
Clustering. As shown in Table 2, our method performs well compared to the baselines. For SOL, our method is affected by the class imbalance between samples, but still produces competitive results. In particular, note that our approach does not need any labels during training, in contrast to the APNet-based approach [17]. For Lib-riSpeech, our method produces convincing clustering results for speaker identification.
Classification. As shown in Table 3, our method reaches almost perfect precision for both datasets. While AP-Net [17] reaches better reconstruction scores, this method learns powerful transformations in an abstract latent space. This leads to a model that is more expressive but less interpretable. In contrast, we restrict the scope of the spectral transformations so that a prototype relates in a meaningful way to the samples that it reconstructs well. Yet, our model is still capable of producing faithful reconstructions, which would be suitable for audio generation tasks.

Interpretability
As shown in Figure 5, our model learns to reconstruct complex input samples (e.g. different notes, techniques, or voices) by automatically adjusting the amplitude, pitch, and spectral support of spectral prototypes. As seen on Figure 4 and Figure 1, these prototypes capture rich spectral characteristics such as timbre, and can be interpreted as an "acoustical fingerprint". Furthermore, as the prototypes are given in the spectral domain, they can be easily played and analyzed. Audio examples featuring the learned prototypes are provided in the supplementary materials.
In Figure 6, we represent the reconstruction of sounds played by various instrument with different prototypes. While the reconstructions are clearly more faithful when using the instruments' dedicated prototype, this opens the perspective for further MIR application such as interpretable timbre transfer.

CONCLUSION
We presented a novel approach to audio understanding by representing large collections of audio clips with few spectral prototypes equipped with learned transformation networks. Our model produces concise, expressive, and interpretable representations of raw audio excerpts that can be used to obtain state-of-the-art results for audio classification and clustering tasks.
Acknowledgements. This work was supported in part by ANR project READY3D ANR-19-CE23-0007 and was granted access to the HPC resources of IDRIS under the allocation 2022-AD011012096R1 made by GENCI. We thank Theo Deprelle, Nicolas Gonthier, Tom Monnier and Yannis Siglidis for inspiring discussions and feedbacks.