TristouNet: Triplet Loss for Speaker Turn Embedding

09/14/2016 ∙ by Hervé Bredin, et al. ∙ 0

TristouNet is a neural network architecture based on Long Short-Term Memory recurrent networks, meant to project speech sequences into a fixed-dimensional euclidean space. Thanks to the triplet loss paradigm used for training, the resulting sequence embeddings can be compared directly with the euclidean distance, for speaker comparison purposes. Experiments on short (between 500ms and 5s) speech turn comparison and speaker change detection show that TristouNet brings significant improvements over the current state-of-the-art techniques for both tasks.



There are no comments yet.


page 4

Code Repositories


TristouNet: Triplet Loss for Speaker Turn Embedding

view repo
This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

Given a speech sequence  and a claimed identity , speaker verification aims at accepting or rejecting the identity claim. It is a supervised binary classification task usually addressed by comparing the test speech sequence  to the enrollement sequence  uttered by the speaker  whose identity is claimed. Speaker identification is the task of determining which speaker (from a predefined set of speakers ) has uttered the sequence . It is a supervised multiclass classification task addressed by looking for the enrollement sequence  the most similar to the test speech sequence . Speaker diarization is the task of partitioning an audio stream into homogeneous temporal segments according to the identity of the speaker. It is broadly addressed as the series of three steps: speech activity detection, speaker change detection (i.e. finding boundaries between any two different speakers), and speech turn clustering.

Whether we address speaker verification, speaker identification, or speaker diarization, it all boils down to finding the best pair (, ) of representation function and comparison function with the following ideal property. Given a speech sequence  uttered by a given speaker, any speech sequence  uttered by the same speaker should be closer to than any speech sequence  uttered by a different one:


Judging from the organization of the

NIST i-vector Machine Learning Challenge


, the i-vector approach 

[2] has become the de facto standard for as far as speaker recognition is concerned. Hence, given a common i-vector implementation, the objective for participants to this challenge is to design the best comparison function . In this paper, we address the dual problem: choosing as the euclidean distance, we want to find a representation function that has the property described in Equation 1

. Practically, based on a carefully designed loss function, we propose to train a speech sequence embedding based on recurrent neural networks to get closer to this optimal function


The i-vector approach has also become the state-of-the-art for speaker diarization [3]. However, due to its sensitivity to sequence duration [4], it is only used once short speech turns have been clustered into larger groups using Bayesian Information Criterion (BIC) [5] or Gaussian divergence [6]. These two techniques are still commonly used for short (i.e. shorter than 5 seconds) speech turn segmentation and clustering. In this paper, we show that the proposed embedding outperforms both approaches and leads to better speaker change detection results.

2 Related work

Using the triplet loss [7, 8]

to train euclidean embeddings has been recently and successfully applied to face recognition and clustering in 


. We use the triplet loss and triplet sampling strategy they proposed. Going with the euclidean distance and unitary embeddings was also inspired by it. The main difference lies in the choice of the neural network architecture used for the embedding. While convolutional neural networks are particularly adapted to (multi-dimensional) image processing and were used in 

[9], we went with recurrent neural networks (more precisely, bi-directional long short-term memory networks, BiLSTM) that are particularly adapted to sequence modeling [10] and were first used for speech processing in [11].

The idea of using deep neural networks to learn a representation function adapted to speaker recognition is not novel [12, 13]. Back in 1998, Konig et al.

trained a multilayer perceptron (MLP) where the input consists of cepstral coefficients extracted from a sequence of frames, and the output layer has one output per speaker in the training set 


. The activations of (bottleneck) hidden layers are then used as the representation function for later speaker recognition experiments using (back then, state-of-the-art) Gaussian Mixture Models (GMM). The main limitations for this kind of approaches is summarized nicely by

Yella et al. in their recent paper [13]: “we hypothesize that the hidden layers of a network trained in this fashion should transform spectral features into a space more conducive to speaker discrimination.”. In other words, we are not quite sure of the efficiency of this internal representation as it is not the one being optimized during training – these approaches still require a carefully designed comparison function (based on GMMs for [12]

or Hidden Markov Models for 

[13]). Our approach is different in that the representation function is the one being optimized with respect to the fixed euclidean distance .

That being said, [13] is very similar to our work in that their neural network is given pairs of sequences as input, and is trained using binary cross-entropy loss to decide whether the two sequences are from the same speaker or from two different speakers. With pairs of 500ms speech sequences, they report a 35% error rate on this task. As depicted in Figure 1, the main difference with our approach lies in the fact the we use triplets of sequences (instead of pairs) and optimize the shared embedding directly thanks to the triplet loss (in place of the intermediate binary cross-entropy loss).

Recently, LSTMs have been particularly successful for automatic speech recognition [14]. They have also been applied recently to speaker adaptation for acoustic modelling [15, 16]. However, to the best of our knowledge, it is the first time they are used for an actual speaker comparison task, and a fortiori for speaker turn embedding.

3 Triplet loss for sequence embedding

Figure 1: Triplet loss training

Figure 1 summarizes the main idea behind triplet loss embeddings. During training, the triplet sampling module generates triplets where

are features extracted from a sequence (called

anchor) of a given speaker, are from another sequence (called positive) from the same speaker, and are from a sequence (called negative) from a different speaker. Then, all three feature vectors (or sequences of vectors, in our case) are passed through the neural network embedding . Finally, the triplet loss [9] minimizes the distance between the embeddings of the anchor and positive, and maximizing the distance between the anchor and negative.

3.1 Triplet loss

Let be the set of all possible triplets in the training set. The triplet loss is motivated by the Equation 1 introduced earlier, and tries to achieve an even better separation between positive and negative pairs by adding a safety margin . For any triplet , we want where


More precisely, the loss that we try to minimize is defined as


3.2 Triplet sampling strategy

As discussed thoroughly in [9], it is not efficient nor effective to generate all possible triplets. Instead, one should focus on triplets that violate the constraint . Any other triplet would not contribute to the loss and would only make training slower. Though we do plan to test other triplet sampling strategies in the future, we chose to go with the one called “hard negative” in [9].

More precisely, after each epoch, we repeat the following sampling process. First, we start by randomly sampling

 sequences from each of the  speakers of the training set. This leads to a total of anchor-positive pairs. Then, for each of those pairs, we randomly choose one negative out of all negative candidates, such that the resulting triplet  has the following properties: .

3.3 TristouNet sequence embedding

Figure 2: TristouNet architecture

Figure 2 depicts the topology of TristouNet111triplet loss for speaker turn neural network (colloquial French for gloomy) , the neural network we propose for sequence embedding. Two Long Short-Term Memory (LSTM) recurrent networks [10] (with units each) both take the feature sequence as input. The first LSTM processes the sequence in chronological order, while the second goes backward. Average pooling is applied to their respective sequence of outputs. This leads to two -dimensional output vectors which are then concatenated into one -dimensional vector. Returning only the average output has one advantage: projecting variable-length input sequences into a fixed-dimension space. However, in this paper, we only used fixed-length input sequences in order to evaluate how well the approach performs depending on the duration. Two fully connected layers (with and units respectively) are then stacked. The final output is -normalized, constraining the final embedding to live on the -dimensional unit hypersphere.

4 Experiments

4.1 Dataset

The ETAPE TV subset contains 29 hours of TV broadcast (18h for training, 5.5h for development and 5.5h for test) from three French TV channels with news, debates, and entertainment [17]. Fine “who speaks when” annotations were obtained on a subset of the training and development set using the following two-steps process: automatic forced alignement of the manual speech transcription followed by manual boundaries adjustment by trained phoneticians. Overall, this leads to a training set of 13.8h containing different speakers, and a development set of 4.2h containing 61 speakers (out of which 18 are also in the training set). Due to coarser annotations, the test set is not used in this paper.

4.2 Implementation details

Feature extraction. 35-dimensional acoustic features are extracted every 20ms on a 32ms window using Yaafe toolkit [18]: 11 Mel-Frequency Cepstral Coefficients (MFCC), their first and second derivatives, and the first and second derivatives of the energy. Both BIC and Gaussian divergence baselines rely on the same set of features (without derivatives, because it leads to better performance).


We use Keras 

[19]deep learning library for training TristouNet. The number of outputs is set to 16 for every layer (i.e. ). In particular, means that the sequence embeddings live on the 16-dimensional unit hypersphere. We use activation function for every layer as well. Every model (one for each sequence duration 500ms, 1s, 2s and 5s) is trained for 50 epochs, using margin as proposed in the original paper [9]

, and the RMSProp optimizer 

[20] with learning rate. Finally, the triplet sampling uses random sequences per speaker, for a total of 143520 triplets per epoch.

Reproducible research. provides Python code to reproduce the experiments.

4.3 “same/different” toy experiment

This first set of experiments aims at evaluating the intrinsic quality of the learned embedding.

Protocol. 100 sequences are extracted randomly for each of the 61 speakers in the ETAPE development set. The “same/different” experiment consists in a binary classification task: given any two of those sequences, decide whether they were uttered by the same speaker, or two different speakers. This is achieved by thresholding the computed distance between sequences. We compare several approaches: Gaussian divergence [6], Bayesian Information Criterion [5], and the proposed embedding with euclidean distance.

Evaluation metric. Two types of errors exist: a false positive

is triggered when two sequences from two different speakers are incorrectly classified as uttered by the same speaker, and a

false negative is when two sequences from the same speaker are classified as uttered by two different speakers. The higher (resp. lower) the decision threshold is, the higher the false negative (resp. positive) rate is (FNR, FPR). We report the equal error rate (EER), i.e. the value of FPR and FNR when they are equal.

Figure 3: Distribution of distances between pairs of same speaker (green) and different speaker (red) 2s-sequence embeddings. This is based on every combinations of 100 random sequences of all speakers of the development set, every 10 training epochs.
Figure 4: Top: triplet loss on the training set for the 2s sequence embedding after each epoch. Bottom: equal error rate obtained on the “same/different” experiment on the development set after each epoch.

Training. Figures 3 and 4 illustrate how the intrinsic quality of the embedding (of 2s sequences) improves over time, during training. Figure 3 clearly shows how the discriminative power of the embedding improves every 10 epochs: same and different speaker(s) distance distributions are progressively separating until convergence and no further significant improvement is observed.

Figure 5: Results of the “same/different” experiment for varying sequence duration. Embeddings are obtained after 50 epochs.

Results. Figure 5 summarizes the results. As expected, embeddings of longer sequences get better performance: EER decreases from for 500ms sequences down to for 5s sequences. Most importantly, our approach significantly outperforms the commonly used approaches (BIC and Gaussian divergence), bringing an absolute (or relative ) EER decrease for 2s sequence comparison. Note how the 500ms embedding is almost as good as the (four times longer) 2s BIC baseline approach.

4.4 Speaker change detection

Speaker change detection consists in finding the boundaries between speech turns of two different speakers. It is often used as a first step before speech turns clustering in speaker diarization approaches.

Protocol. For each files in the ETAPE development set, we compute the distance between two (left and right) 2s sliding windows, every 100ms. Peak detection is then applied to the resulting 1-dimensional signal by looking for local maxima within 1s context. A final thresholding step removes small peaks and only keeps large ones as speaker changes.

Evaluation metric. Given the set of reference speech turns, and the set of hypothesized segments, coverage is:


where is the duration of segment and is the intersection of segments and . Purity is the dual metric where the role of and are interchanged. Over-segmentation (i.e. detecting too many speaker changes) would result in high purity but low coverage, while missing lots of speaker changes would decrease purity – which is critical for subsequent speech turn agglomerative clustering.

Figure 6: Performance of speaker change detection on ETAPE development set. These curves are obtained by varying the value of the final threshold.

Results. Figure 6 summarizes the results obtained when varying the value of the final threshold. Embedding-based speaker change detection clearly outperforms both BIC- and divergence-based approaches. Though it does not improve the best achievable purity (it gets vs. for divergence), embedding-based speaker change detection does improve coverage significantly. For instance, at purity, coverage is while BIC- and divergence-based approaches are stuck at . In other words, it means that hypothesized speech turns are longer on average, with the same level of purity.

5 Perspective

The impact of this major improvement on the overall performance of a complete speaker diarization system (including speech activity detection and speech turn clustering) has yet to be quantified. It would also be a valuable experiment to evaluate how it generalizes to variable-length sequences (this is already supported, only not tested yet); as well as its application to speaker recognition. Furthermore, possible future work would be to investigate the use of deeper or wider neural network architectures. Replacing the triplet loss by the center loss recently proposed for face recognition [21] might also be a promising research direction.

Acknowledgement This work was supported by ANR through the ODESSA and MetaDaTV projects. Thanks to “LSTM guru” Grégory Gelly for fruitful discussions.


  • [1] C. Greenberg, D. Bansé, G. Doddington, D. Garcia-Romero, J. Godfrey, T. Kinnunen, A. Martin, A. McCree, M. Przybocki, and D. Reynolds, “The NIST 2014 Speaker Recognition i-vector Machine Learning Challenge,” in Odyssey 2014, The Speaker and Language Recognition Workshop, Joensuu, Finland, June 2014.
  • [2] N. Dehak, P. Kenny, R. Dehak, P. Dumouchel, and P. Ouellet, “Front-end factor analysis for speaker verification,” Trans. Audio, Speech and Lang. Proc., vol. 19, no. 4, pp. 788–798, May 2011.
  • [3] G. Dupuy, S. Meignier, P. Deleglise, and Esteve Y., “Recent Improvements on ILP-based Clustering for Broadcast News Speaker Diarization,” in Odyssey 2014, The Speaker and Language Recognition Workshop, Joensuu, Finland, June 2014.
  • [4] A. Sarkar, D. Matrouf, P.M. Bousquet, and J.F. Bonastre, “Study of the Effect of I-vector Modeling on Short and Mismatch Utterance Duration for Speaker Verification,” in Thirteenth Annual Conference of the International Speech Communication Association, 2012.
  • [5] S. Chen and P. Gopalakrishnan, “Speaker, Environment and Channel Change Detection and Clustering via the Bayesian Information Criterion,” in DARPA Broadcast News Transcription and Understanding Workshop, Virginia, USA, 1998.
  • [6] C. Barras, X. Zhu, S. Meignier, and J.-L. Gauvain, “Multi-Stage Speaker Diarization of Broadcast News,” IEEE Transactions on Audio, Speech and Language Processing, vol. 14, no. 5, pp. 1505–1512, 2006.
  • [7] J. Wang, Y. Song, T. Leung, C. Rosenberg, J. Wang, J. Philbin, B. Chen, and Y. Wu,

    “Learning Fine-Grained Image Similarity with Deep Ranking,”


    Proceedings of the 2014 IEEE Conference on Computer Vision and Pattern Recognition

    , Washington, DC, USA, 2014, CVPR ’14, pp. 1386–1393.
  • [8] E. Hoffer and N. Ailon, “Deep Metric Learning Using Triplet Network,” in Third International Workshop on Similarity-Based Pattern Recognition, October 2015, pp. 84–92.
  • [9] F. Schroff, D. Kalenichenko, and J. Philbin, “FaceNet: a Unified Embedding for Face Recognition and Clustering,” in Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2015, pp. 815–823.
  • [10] S. Hochreiter and J. Schmidhuber, “Long Short-Term Memory,” Neural Comput., vol. 9, no. 8, pp. 1735–1780, Nov. 1997.
  • [11] A. Graves and J. Schmidhuber, “Framewise Phoneme Classification with Bidirectional LSTM and other Neural Network Architectures,” Neural Networks, vol. 18, no. 5–6, pp. 602 – 610, 2005, {IJCNN} 2005.
  • [12] Y. Konig, L. Heck, M. Weintraub, K. Sonmez, and Esum R., “Nonlinear Discriminant Feature Extraction For Robust Text-Independent Speaker Recognition,” in RLA2C-ESCA Speaker Recognition and its Commercial and Forensic Applications, 1998, pp. 72–75.
  • [13] S.H. Yella, A. Stolcke, and M. Slaney, “Artificial neural network features for speaker diarization,” in IEEE Spoken Language Technology workshop, Dec. 2014.
  • [14] A. Graves, A. Mohamed, and G. Hinton, “Speech Recognition with Deep Recurrent Neural Networks,” in 2013 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2013.
  • [15] Y. Miao and F. Metze, “On Speaker Adaptation of Long Short-Term Memory Recurrent Neural Networks,” in Sixteenth Annual Conference of the International Speech Communication Association, 2015.
  • [16] T. Tan, Y. Qian, D. Yu, S. Kundu, L. Lu, K. C. Sim, X. Xiao, and Y. Zhang, “Speaker-aware Training of LSTM-RNNS for Acoustic Modelling,” in 2016 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), March 2016, pp. 5280–5284.
  • [17] G. Gravier, G. Adda, N. Paulson, M. Carré, A. Giraudel, and O. Galibert, “The ETAPE Corpus for the Evaluation of Speech-based TV Content Processing in the French Language,” in LREC - Eighth international conference on Language Resources and Evaluation, Turkey, 2012, p. na.
  • [18] B. Mathieu, S. Essid, T. Fillon, J. Prado, and G. Richard, “YAAFE, an Easy to Use and Efficient Audio Feature Extraction Software,” in Proceedings of the 11th International Society for Music Information Retrieval Conference, Utrecht, The Netherlands, August 9-13 2010, pp. 441–446.
  • [19] F. Chollet, “Keras deep learning library,”, 2016.
  • [20] T. Tieleman and G. Hinton, “Lecture 6.5 - RMSProp,” Tech. Rep., COURSERA: Neural Networks for Machine Learning, 2012.
  • [21] Y. Wen, K. Zhang, Z. Li, and Y. Qiao, “A Discriminative Feature Learning Approach for Deep Face Recognition,” in European Conference on Computer Vision (ECCV), 2016.