Beispiel #1
0
    def get_num_speakers(self, ivecs, min_speakers=2, max_speakers=6):
        """ Obtain number of speakers from pretrained model.

            :param ivecs: input i-vectors
            :type ivecs: numpy.array
            :param min_speakers: minimal number of speakers from model
            :type min_speakers: int
            :param max_speakers: maximal number of speakers from model
            :type max_speakers: int
            :returns: estimated number of speakers and KMeans centroid
            :rtype: tuple
        """
        avg, centroids_list = [], []
        features = []
        for num_speakers in range(min_speakers, max_speakers + 1):
            sklearnkmeans = sklearnKMeans(n_clusters=num_speakers).fit(ivecs)
            centroids = KMeans(sklearnkmeans.cluster_centers_, num_speakers,
                               self.plda).fit(ivecs)
            centroids_list.append(centroids)
            scores = self.s_norm(centroids,
                                 centroids)[np.tril_indices(num_speakers, -1)]
            features.append(Normalization.get_features(scores))
        num_speakers = np.argmax(
            np.sum(self.model.test(features, prob=True), axis=0))
        # raw_input('ENTER')
        return num_speakers + min_speakers, centroids_list[num_speakers]
Beispiel #2
0
 def get_num_speakers(self, ivecs, min_speakers=2, max_speakers=6):
     avg, centroids_list = [], []
     features = []
     for num_speakers in range(min_speakers, max_speakers + 1):
         sklearnkmeans = sklearnKMeans(n_clusters=num_speakers).fit(ivecs)
         centroids = KMeans(sklearnkmeans.cluster_centers_, num_speakers,
                            self.plda).fit(ivecs)
         centroids_list.append(centroids)
         scores = self.s_norm(centroids,
                              centroids)[np.tril_indices(num_speakers, -1)]
         features.append(Normalization.get_features(scores))
     num_speakers = np.argmax(
         np.sum(self.model.test(features, prob=True), axis=0))
     # raw_input('ENTER')
     return num_speakers + min_speakers, centroids_list[num_speakers]