1

I've been working on continues speech recognition for a month and I found hmmlearn package. I could create my phoneme models with _model = hmm.GMMHMM(...) and _model.fit(...). But when I want to use _model.score(_extracted_test_features) for test samples, I got this error:

.format(self.covariance_type)) ValueError: 'diag' mixture covars must be non-negative

Here is my code:

    def Main():
        # ---
        _phoneme_files_dir = './database_info/phonemes/phoneme_files/'
        _phoneme_dataset_dir = './database_info/phonemes/extracted_features/'
        _phoneme_models_dir = './database_info/phonemes/models/'
        _phoneme_test = '/home/ali/speech_recognition/database/database_english/timit/data/lisa/data/timit/raw/TIMIT/TEST/DR1/FAKS0/SA1.wav'
        # ---
        _phoneme_test_features = ExtractFeatures(_phoneme_test, 9640, 11240)
        _phoneme_models, _phoneme_models_list_loaded = LoadModels(_phoneme_models_dir)
        print("Getting models has successfully done")
        # ---
        _score_list = {}
        for _model_label in _phoneme_models.keys():
            _model = _phoneme_models[_model_label][0]
            _score = _model.score(_phoneme_test_features)
            _score_list[_model_label] = _score
        _predict = max(_score_list, key=_score_list.get)
        print("predict result phoneme is ", _phoneme_models_list_loaded[_predict])

Anyone knows about this error? I've found some solution but they were for a few years ago and after that hmmlearn package got some updates and fixed them.

Ali Esmailpor
  • 1,209
  • 3
  • 11
  • 22
  • So... are the variances negative? Also, do you perform any discriminative training? If you don't, they really shouldn't. – dedObed Aug 01 '19 at 09:43
  • I trained and saved all phonemes. Here I just load models. Did you mean that? – Ali Esmailpor Aug 01 '19 at 09:48
  • No. I mean whether you looked at the estimated covariances, whether their diagonal entries are actually negative. And whether you trained simply in a generative fashion, i.e. optimizing maximum likelihood, or if you went for some discriminitave criterion like MMI or MPE. – dedObed Aug 01 '19 at 10:07

1 Answers1

1

Usually it means some phoneme has not enough data during training and your model didn't train properly. You need many many samples > 100 to train, with just couple samples it will not work.

You can print the model values to check which are negative.

It is better to use specialized toolkit like kaldi or espnet for speech training, HMMlearn is not the right tool, it is not properly implemented for speech.

Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87