Skip to content

Commit c74b412

Browse files
Merge pull request #67 from hyperion-ml/lachesis
Lachesis
2 parents 8395315 + 307129f commit c74b412

File tree

63 files changed

+312
-1703
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+312
-1703
lines changed

.gitignore

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ tests/data_out/*
2929

3030
# developer environments
3131
#.idea
32-
tools/anaconda/anaconda3.5
33-
tools/anaconda/anaconda3
34-
tools/anaconda/apex
35-
tools/ibm_art/adversarial-robustness-toolbox/
36-
tools/cudnn/cudnn-*
37-
tools/kaldi/kaldi
38-
tools/nccl/nccl_*
32+
tools/anaconda3.5
33+
tools/anaconda3
34+
tools/apex
35+
tools/adversarial-robustness-toolbox
36+
tools/cudnn-*
37+
tools/kaldi
38+
tools/nccl_*
3939
tools/path.sh
40+
tools/sph2pipe_*
4041

4142
rirs_noises.zip
4243
RIRS_NOISES

README.md

Lines changed: 130 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,140 @@
22

33
Speaker recognition toolkit
44

5-
## Cloning the repo
5+
## Installation Instructions
66

7-
- To clone the repo execute
7+
### Prerequisites
8+
9+
We use anaconda or miniconda, though you should be able to make it work in other python distributions
10+
To start, you should create a new enviroment and install pytorch>=1.6, e.g.:
11+
```
12+
conda create --name ${your_env} python=3.8
13+
conda activate ${your_env}
14+
conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=10.2 -c pytorch
15+
```
16+
17+
### Installing Hyperion
18+
19+
- First, clone the repo:
820
```bash
921
git clone https://github.com/hyperion-ml/hyperion.git
1022
```
1123

12-
## Dependencies:
13-
- Anaconda3.5:
14-
- Make a link to your anaconda installation in the tools directory:
15-
```bash
16-
cd hyperion/tools/anaconda
17-
ln -s <your-anaconda-3.5> anaconda3.5
18-
```
19-
- or follow instructions in hyperion/tools/anaconda/full_install.sh to install anaconda from scratch
20-
- Kaldi speech recognition toolkit
21-
- Make link to an existing kaldi installation
22-
```bash
23-
cd hyperion/tools/kaldi
24-
ln -s <your-kaldi> kaldi
25-
```
26-
- or follow instructions in hyperion/tools/anaconda/install_kaldi.sh to install kaldi from scratch
27-
28-
- CuDNN: tensorflow and pytorch will need some version of cudnn
29-
- Make a link to some existing cudnn version that matches the requirements of your tf or pytorch, e.g.:
30-
```bash
31-
cd hyperion/tools/cudnn
32-
#cudnn v7.4 for cuda 9.0 needed by pytorch 1.0
33-
ln -s /home/janto/usr/local/cudnn-9.0-v7.4 cudnn-9.0-v7.4
34-
```
35-
- In the CLSP grid: you can use some preinstalled versions of anaconda and kaldi in the grid to avoid each person having its own.
36-
- To create links to preinstalled kaldi, anaconda and cudnn, run:
37-
```bash
38-
cd hyperion/
39-
./make_clsp_links.sh
40-
```
41-
- The anaconda that you will link with this has several environments:
42-
- base: numpy, h5py, pandas, etc.
43-
- tensorflow1.8g_cpu: tensorflow 1.8 for cpu
44-
- tensorflow1.8g_gpu: tensorflow 1.8 for gpu
45-
- pytorch1.0_cuda9.0: pytorch 1.0 with cuda 9.0
24+
- You can choolse to install hyperion in the environment
25+
```bash
26+
cd hyperion
27+
pip install -e .
28+
```
29+
30+
- Or add the hyperion toolkit to the PYTHONPATH envirnoment variable
31+
This option will allow you to share the same environment if you are working with several hyperion branches
32+
at the same time, while installing it requires to have an enviroment per branch.
33+
For this, you need to install the requirements
34+
```bash
35+
cd hyperion
36+
pip install -r requirements.txt
37+
```
38+
Then add these lines to your `~/.bashrc` or to each script that uses hyperion
39+
```bash
40+
HYP_ROOT= #substitute this by your hyperion location
41+
export PYTHONPATH=${HYP_ROOT}:$PYTHONPATH
42+
export PATH=${HYP_ROOT}/bin:$PATH
43+
```
44+
45+
## Recipes
46+
47+
There are recipes for several tasks in the `./egs` directory.
48+
49+
### Prerequistes to run the recipes
50+
51+
These recipes require some extra tools (e.g. sph2pipe), which need to be installed first:
52+
```bash
53+
./install_egs_requirements.sh
54+
```
55+
56+
Most recipes do not require Kaldi, only the older ones using Kaldi x-vectors,
57+
so we do not install it by default. If you are going to need it install it
58+
yourself. Then make a link in `./tools` to your kaldi installation
59+
```bash
60+
cd tools
61+
ln -s ${your_kaldi_path} kaldi
62+
cd -
63+
```
64+
65+
Finally configure the python and environment name that you intend to use to run the recipes.
66+
For that run
67+
```bash
68+
./prepare_egs_paths.sh
69+
```
70+
This script will ask for the path to your anaconda installation and enviromentment name.
71+
It will also detect if hyperion is already installed in the environment,
72+
otherwise it will add hyperion to your python path.
73+
This will create the file
74+
```
75+
tools/path.sh
76+
```
77+
which sets all the enviroment variables required to run the recipes.
78+
This has been tested only on JHU computer grids, so you may need to
79+
modify this file manually to adapt it to your grid.
80+
81+
## Recipes structure
82+
83+
The structure of the recipes is very similar to Kaldi, so if should be
84+
familiar for most people.
85+
Data preparation is also similar to Kaldi. Each dataset has
86+
a directory with files like
87+
```
88+
wav.scp
89+
utt2spk
90+
spk2utt
91+
...
92+
```
93+
94+
### Running the recipes
95+
96+
Contrary to other toolkits, the recipes do not contain a single `run.sh` script
97+
to run all the steps of the recipe.
98+
Since some recipes have many steps and most times you don't want to run all of then
99+
from the beginning, we have split the recipe in several run scripts.
100+
The scripts have a number indicating the order in the sequence.
101+
For example,
102+
```bash
103+
run_001_prepare_data.sh
104+
run_002_compute_vad.sh
105+
run_010_prepare_audios_to_train_xvector.sh
106+
run_011_train_xvector.sh
107+
run_030_extract_xvectors.sh
108+
run_040_evaluate_plda_backend.sh
109+
```
110+
will evaluate the recipe with the default configuration.
111+
The default configuration is in the file `default_config.sh`
112+
113+
We also include extra configurations, which may change
114+
the hyperparamters of the recipe. For example:
115+
- Acoustic features
116+
- Type of the x-vector neural netwok
117+
- Hyper-parameters of the models
118+
- etc.
119+
120+
Extra configs are in the `global_conf` directory of the recipe.
121+
Then you can run the recipe with the alternate config as:
122+
```bash
123+
run_001_prepare_data.sh --config-file global_conf/alternative_conf.sh
124+
run_002_compute_vad.sh --config-file global_conf/alternative_conf.sh
125+
run_010_prepare_audios_to_train_xvector.sh --config-file global_conf/alternative_conf.sh
126+
run_011_train_xvector.sh --config-file global_conf/alternative_conf.sh
127+
run_030_extract_xvectors.sh --config-file global_conf/alternative_conf.sh
128+
run_040_evaluate_plda_backend.sh --config-file global_conf/alternative_conf.sh
129+
```
130+
Note that many alternative configus share hyperparameters with the default configs.
131+
That means that you may not need to rerun all the steps to evaluate a new configuration.
132+
It mast cases you just need to re-run the steps from the neural network training to the end.
133+
134+
135+
## Citing
136+
137+
Each recipe README.md file contains the bibtex to the works that should be cited if you
138+
use that recipe in your research
46139

47140
## Directory structure:
48141
- The directory structure of the repo looks like this:
@@ -53,14 +146,10 @@ hyperion/hyperion
53146
hyperion/resources
54147
hyperion/tests
55148
hyperion/tools
56-
hyperion/tools/anaconda
57-
hyperion/tools/cudnn
58-
hyperion/tools/kaldi
59-
hyperion/tools/keras
60149
```
61150
- Directories:
62151
- hyperion: python classes with utilities for speaker and language recognition
63-
- egs: recipes for sevareal tasks: SRE18, voices, ...
152+
- egs: recipes for sevaral tasks: VoxCeleb, SRE18/19/20, voices, ...
64153
- tools: contains external repos and tools like kaldi, python, cudnn, etc.
65154
- tests: unit tests for the classes in hyperion
66155
- resources: data files required by unittest or recipes

apps.txt

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
11
apply-mvn-select-frames.py
2-
ark2hyp.py
3-
arkvad2nist.py
42
compute-energy-vad.py
5-
compute-gmm-post.py
63
compute-mfcc-feats.py
74
copy-feats.py
8-
eval-2class-performance.py
95
eval-cos-1vs1.py
10-
eval-elbo-ubm.py
11-
eval-linear-gbe.py
126
eval-linear-gbe-up.py
7+
eval-linear-gbe.py
138
eval-linear-svmc.py
149
eval-logistic-regression.py
1510
eval-plda-1vs1.py
1611
eval-plda-nvs1.py
17-
eval-q-scoring-homo-gbe.py
18-
eval-score-norm.py
19-
h5vad2nist.py
20-
init-ubm.py
2112
make-babble-noise-audio-files.py
2213
merge-h5-files.py
2314
pack-audio-files.py
@@ -26,27 +17,42 @@ plot-vector-hist.py
2617
plot-vector-tsne.py
2718
preprocess-audio-files.py
2819
rttm-to-bin-vad.py
29-
scores2lre_format.py
3020
segments-to-bin-vad.py
3121
torch-adv-finetune-xvec-from-wav.py
22+
torch-adv-finetune-xvec.py
3223
torch-compute-mfcc-feats.py
3324
torch-eval-vae.py
25+
torch-eval-xvec-cosine-scoring-from-adv-test-wav-wavegan.py
26+
torch-eval-xvec-cosine-scoring-from-adv-test-wav.py
27+
torch-eval-xvec-cosine-scoring-from-art-test-wav.py
28+
torch-eval-xvec-cosine-scoring-from-test-wav.py
29+
torch-eval-xvec-cosine-scoring-from-transfer-adv-test-wav.py
30+
torch-eval-xvec-cosine-scoring-from-transfer-art-test-wav.py
31+
torch-eval-xvec-logits-from-wav.py
32+
torch-extract-xvectors-from-wav-with-rttm.py
3433
torch-extract-xvectors-from-wav.py
34+
torch-extract-xvectors-slidwin-from-wav.py
35+
torch-extract-xvectors-slidwin.py
36+
torch-extract-xvectors-vae-preproc.py
3537
torch-extract-xvectors.py
3638
torch-finetune-xvec-dfr-from-wav.py
3739
torch-finetune-xvec-dfr.py
3840
torch-finetune-xvec-from-wav.py
3941
torch-finetune-xvec.py
40-
torch-madry-adv-finetune-xvec.py
42+
torch-generate-adv-attacks-xvector-classif.py
43+
torch-generate-adv-attacks-xvector-verif.py
4144
torch-train-conformer-enc-v1-vq-dvae.py
4245
torch-train-conformer-enc-v1-vq-vae.py
4346
torch-train-dc1d-ae.py
4447
torch-train-dc1d-dvae.py
4548
torch-train-dc1d-vae.py
4649
torch-train-dc2d-dvae.py
4750
torch-train-dc2d-vae.py
51+
torch-train-dvae.py
4852
torch-train-efficientnet-xvec-from-wav.py
4953
torch-train-efficientnet-xvec.py
54+
torch-train-resnet-xvec-from-wav.py
55+
torch-train-resnet-xvec.py
5056
torch-train-resnet1d-dvae.py
5157
torch-train-resnet1d-vae.py
5258
torch-train-resnet1d-vq-dvae.py
@@ -55,8 +61,7 @@ torch-train-resnet2d-dvae.py
5561
torch-train-resnet2d-vae.py
5662
torch-train-resnet2d-vq-dvae.py
5763
torch-train-resnet2d-vq-vae.py
58-
torch-train-resnet-xvec-from-wav.py
59-
torch-train-resnet-xvec.py
64+
torch-train-spinenet-xvec-from-wav.py
6065
torch-train-tdnn-xvec-from-wav.py
6166
torch-train-tdnn-xvec.py
6267
torch-train-transformer-enc-v1-dvae.py
@@ -65,18 +70,19 @@ torch-train-transformer-enc-v1-vq-dvae.py
6570
torch-train-transformer-enc-v1-vq-vae.py
6671
torch-train-transformer-xvec-v1-from-wav.py
6772
torch-train-transformer-xvec-v1.py
68-
torch-train-xvector.py
69-
train-cw.py
73+
torch-train-vae.py
74+
torch-train-vq-dvae.py
75+
torch-train-vq-vae.py
76+
torch-train-xvec-from-wav.py
7077
train-cw-up.py
78+
train-cw.py
7179
train-gaussianizer.py
7280
train-lda.py
73-
train-linear-gbe.py
7481
train-linear-gbe-up.py
82+
train-linear-gbe.py
7583
train-linear-svmc.py
7684
train-logistic-regression.py
7785
train-mvn.py
7886
train-nda.py
7987
train-pca.py
8088
train-plda.py
81-
train-q-scoring-homo-gbe.py
82-
vectors2scores.py

egs/chime5_spkdet/v1/path.sh

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,4 @@
22
export HYP_ROOT=$(readlink -f `pwd -P`/../../..)
33
export TOOLS_ROOT=$HYP_ROOT/tools
44

5-
export KALDI_ROOT=$TOOLS_ROOT/kaldi/kaldi
6-
export PATH=$PWD/utils/:$KALDI_ROOT/tools/openfst/bin:$KALDI_ROOT/tools/sph2pipe_v2.5:$PWD:$PATH
7-
[ ! -f $KALDI_ROOT/tools/config/common_path.sh ] && echo >&2 "The standard file $KALDI_ROOT/tools/config/common_path.sh is not present -> Exit!" && exit 1
8-
. $KALDI_ROOT/tools/config/common_path.sh
9-
export LC_ALL=C
10-
11-
#Anaconda env
12-
CONDA_ROOT=$TOOLS_ROOT/anaconda/anaconda3
13-
if [ -f "$CONDA_ROOT/etc/profile.d/conda.sh" ]; then
14-
#for conda version >=4.4 do
15-
. $CONDA_ROOT/etc/profile.d/conda.sh
16-
conda activate
17-
else
18-
#for conda version <4.4 do
19-
PATH=$CONDA_ROOT/bin:$PATH
20-
fi
21-
22-
if [ "$(hostname --domain)" == "cm.gemini" ];then
23-
module load ffmpeg
24-
HYP_ENV="pytorch1.6_cuda10.1"
25-
module load cuda10.1/toolkit/10.1.105
26-
module load cudnn/7.6.3_cuda10.1
27-
else
28-
#CUDA_ROOT=/home/janto/usr/local/cuda-10.1
29-
CUDA_ROOT=/usr/local/cuda
30-
LD_LIBRARY_PATH=$CUDA_ROOT/lib64:$LD_LIBRARY_PATH
31-
LD_LIBRARY_PATH=$CUDA_ROOT/lib:$LD_LIBRARY_PATH
32-
if [ ! -d $CUDA_ROOT/lib64 ]; then
33-
LD_LIBRARY_PATH=$HOME/cuda/lib64:$LD_LIBRARY_PATH
34-
fi
35-
36-
HYP_ENV="pytorch1.6_cuda10.2"
37-
# #CuDNN env
38-
# CUDNN_ROOT=$TOOLS_ROOT/cudnn/cudnn-10.1-v7.6
39-
# LD_LIBRARY_PATH=$CUDNN_ROOT/lib64:$LD_LIBRARY_PATH
40-
# LIBRARY_PATH=$CUDNN_ROOT/lib64:$LIBRARY_PATH
41-
# CPATH=$CUDNN_ROOT/include:$CPATH
42-
fi
43-
44-
export LRU_CACHE_CAPACITY=1 #this will avoid crazy ram memory when using pytorch with cpu, it controls cache of MKLDNN
45-
export HDF5_USE_FILE_LOCKING=FALSE
46-
47-
export MPLBACKEND="agg"
48-
export PATH=$HYP_ROOT/hyperion/bin:$CUDA_ROOT/bin:$PATH
49-
export PYTHONPATH=$HYP_ROOT:$PYTHONPATH
50-
export LD_LIBRARY_PATH
51-
export LC_ALL=C
52-
53-
wait_file() {
54-
local file="$1"; shift
55-
local wait_seconds="${2:-30}"; shift # 10 seconds as default timeout
56-
for((i=0; i<$wait_seconds; i++)); do
57-
[ -f $file ] && return 1
58-
sleep 1s
59-
done
60-
return 0
61-
}
62-
63-
export -f wait_file
5+
. $TOOLS_ROOT/path.sh

0 commit comments

Comments
 (0)