Python re-implementation of the spectral clustering algorithm in the paper "Speaker Diarization with LSTM"
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Regenerate docs, and upload Jan 27, 2019
resources Add tutorial and image to Jan 18, 2019
spectralcluster Add the _get_refinement_operator method to make code cleaner Jan 20, 2019
tests Rename cluster() method to predict() to align with sklearn and tensor… Jan 19, 2019
.coveragerc Activate codecov Jan 29, 2019
.gitignore Activate codecov Jan 29, 2019
.travis.yml Activate codecov Jan 29, 2019
LICENSE Update LICENSE Jan 19, 2019 Add codecov badge to Jan 29, 2019 Prepare to PyPI release Jan 18, 2019
requirements.txt Rename sklearn to scikit-learn in requirements.txt Jan 19, 2019 Rename Jan 27, 2019 Correct the way to run coverage to append to result Jan 29, 2019 New release 0.0.7 Jan 27, 2019

Spectral Clustering Build Status PyPI Version Python Versions codecov Documentation


This is a Python re-implementation of the spectral clustering algorithm in the paper Speaker Diarization with LSTM.



This is not the original implementation used by the paper.

Specifically, in this implementation, we use the K-Means from scikit-learn, which does NOT support customized distance measure like cosine distance.


  • numpy
  • scipy
  • scikit-learn


Install the package by:

pip3 install spectralcluster


python3 -m pip install spectralcluster


Simply use the predict() method of class SpectralClusterer to perform spectral clustering:

from spectralcluster import SpectralClusterer

clusterer = SpectralClusterer(

labels = clusterer.predict(X)

The input X is a numpy array of shape (n_samples, n_features), and the returned labels is a numpy array of shape (n_samples,).

For the complete list of parameters of the clusterer, see spectralcluster/


Our paper is cited as:

  title={Speaker diarization with lstm},
  author={Wang, Quan and Downey, Carlton and Wan, Li and Mansfield, Philip Andrew and Moreno, Ignacio Lopz},
  booktitle={2018 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},


Our new speaker diarization systems are now fully supervised, powered by uis-rnn. Check this Google AI Blog.

To learn more about speaker diarization, here is a curated list of resources: awesome-diarization.