db.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:voiceid 作者: sih4sing5hong5 项目源码 文件源码
def match_voice(self, wave_file, identifier, gender):
        """Match the voice (wave file) versus the gmm model of
        'identifier' in db.

        :type wave_file: string
        :param wave_file: wave file extracted from the wave

        :type identifier: string
        :param identifier: the speaker in the wave

        :type gender: char F, M or U
        :param gender: the gender of the speaker (optional)"""

        wave_basename = os.path.splitext(wave_file)[0]
        try:
#            print "match_voice"
#            print (wave_basename, identifier + '.gmm',
#                          gender, self.get_path())
            fm.wav_vs_gmm(wave_basename, identifier + '.gmm',
                         gender, self.get_path())
#             print "after wav_vs_gmm"

            cls = {}
            sr.manage_ident(wave_basename,
                      gender + '.' + identifier + '.gmm', cls)

        except  DivisionByZero: #ValueError, e:
            print "ValueError in MATCH_VOICE"
            print "tring to fix... ", #(wave_basename, identifier + '.gmm',
                     # gender, self.get_path())
            raise e         
            fm._train_init(wave_basename)
            fm._train_map(wave_basename)
            fm.diarization(wave_basename)

            fm.wav_vs_gmm(wave_basename, identifier + '.gmm',
                     gender, self.get_path())
            cls = {}
            sr.manage_ident(wave_basename,
                      gender + '.' + identifier + '.gmm', cls)


        spkrs = {}
        for clust in cls:
            spkrs.update(cls[clust].speakers)
        return spkrs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号