Giter Site home page Giter Site logo

gmm_baseline's Introduction

GMM_baseline

未来杯语音赛道说话人识别的baseline,用的是传统的UBM-GMM模型。

更新


更新1

训练集里面有的语音可能只有wav文件头,这样的语音提取特征保存的文件是一个空文件,无法读取。现在我已经在utils.py文件里面添加了remove函数,并且在train ubm之前调用remove来删除这些空文件。

aishell2数据集有一些文件只有wav文件头,大小大概为44k,请先删除这些文件以免训练出错。

注意,千万不要用完整的aishell2来训练这个模型,太耗时间了,推荐使用刚开始的那个100说话人的aishell2的子集来训练,大概需要一天的时间训练ubm


更新2

添加了新的特征plp,在说话人识别里面非常常用。


更新3

把特征提取部分和训练模型部分分成了两个不同的文件,特征提取在preprocess.py里面,模型训练部分还是在gmm_ubm.py文件里面。

另外写了一个shell脚本,只需要修改里面的一些文件路径和训练参数就可以傻瓜式训练模型了,需要修改的地方我都已经注明了。

修改完成之后nohup bash run.sh &就可以在后台训练打分了。


依赖项

软件

python版本推荐3.7.2

相关的库pip install -r requirements.txt

sidekit==1.2.2
numpy
pandas
matplotlib
scipy
tqdm
librosa

注意

如果sidekit安装了之后无法import,需要找到sidekit安装的地方,改一下__init__.py文件,这个文件里面的38到42行,如果你只训练gmm-ubm的话,所有的选项都设置为False

如果你想使用svm,请先安装libsvm库,然后把__init__.py里面的相应选项设置为True,最后在sidekitlibsvm文件夹里面新建一个链接指向svm库的libsvm.so.2

最新版的sidekit,神经网络部分已经换成了Pytorchbackend,但是1.2.2还是Theano,如果你想在sidekit里面使用神经网络,请安装最新版。

Ps:最新版的sidekit,也就是1.3.1我没有测试过,可能有bug,因为我使用1.2.9版本的时候发现过bug,后来回退到了稳定的1.2.2版本。

另外,sidekit包还提供了生成DET Curve的方法,但是可能会失败,具体原因我也没有找到。总之如果大家经过上面的修改之后还是不能导入sidekit的话,请修改bosaris文件夹里面的detplot.py的第39行,matplotlib.use('PDF'), 可以改成matplotlib.use('Qt5Agg')

主要脚本

preprocess.py文件主要是特征提取已经路径的读取,具体用法看run.sh脚本。

gmm_ubm.py这个脚本包含了训练ubm,自适应得到注册人的gmm,以及计算注册的gmm对所有攻击语音的打分的函数。脚本的用法如下。 测试了512 mixture的GMM对于20+delta+double delta的mfcc的拟合,最好分数高达有0.78。

usage: gmm_ubm.py [-h] [--feat_type {mfcc,fb,plp}] [--delta]
                  [--distribNum DISTRIBNUM] [--num_thread NUM_THREAD]
                  [--extract] [--train] [--adaptation] [--score]
                  name

script for GMM-UBM adaptation

positional arguments:
  name                  model name

optional arguments:
  -h, --help            show this help message and exit
  --feat_type {mfcc,fb,plp}
                        feature type (default : "plp")
  --delta               using delta information of feature
  --distribNum DISTRIBNUM
                        distribution number (default : 512)
  --num_thread NUM_THREAD
                        threads number (default : 20)
  --train               train the ubm model
  --adaptation          adaptation for speaker model
  --score               compute the eer

utils.py这个脚本包含了一些文件的预处理例如idmap,ndx和key,关于这些文件的详细信息,请参考sidekit的官方文档sidekit。另外还包含了一个根据比赛的积分规则打分的函数,--score选项用来打分并将打分的结果保存在result文件夹里面。

python utils.py -h
usage: utils.py [-h] [--enroll ENROLL] [--dev DEV] [--test TEST]
                [--score SCORE]

some utils for preprocess and score

optional arguments:
  -h, --help       show this help message and exit
  --enroll ENROLL  enrollment csv path
  --dev DEV        annotation csv path
  --test TEST      test csv path
  --score SCORE    calculate the score

说明

这个项目是打算作为本次比赛的baseline。训练的语音是比赛官方提供的aishell2的子集,包含了100人的语音,开发集也是官方提供的数据。 本次比赛需要验证不同信道的说话人的语音,UBM-GMM对于这种条件适应性较差,当然如果用ZT-norm重新整理得分的话效果应该更好,但是总的来说注册语音的信道和测试信道不匹配的问题还是很严重。 这种条件下,我相信i-vector+PLDA是一个更好的选择来解决这个问题。

感谢

如果这个repository对你有帮助麻烦请star:-D。

联系

Email : [email protected]

gmm_baseline's People

Contributors

zengchang233 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.