-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update the plda codes * update the plda code to run.sh * update readme * reformat code * fix lint error * fix lint error * update vox plda recipe * update vox plda recipe * Delete __init__.py --------- Co-authored-by: wangshuai <[email protected]>
- Loading branch information
1 parent
2d52982
commit 0473c9c
Showing
25 changed files
with
715 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2023 Shuai Wang ([email protected]) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
exp_dir= | ||
trials="trials trials_tgl trials_yue" | ||
data=data | ||
aug_plda_data=0 | ||
|
||
stage=-1 | ||
stop_stage=-1 | ||
|
||
. tools/parse_options.sh | ||
. path.sh | ||
|
||
if [ $aug_plda_data = 0 ];then | ||
sre_plda_data=sre | ||
else | ||
sre_plda_data=sre_aug | ||
fi | ||
|
||
if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then | ||
echo "train the plda model ..." | ||
python wespeaker/bin/train_plda.py \ | ||
--exp_dir ${exp_dir} \ | ||
--scp_path ${exp_dir}/embeddings/${sre_plda_data}/xvector.scp \ | ||
--utt2spk ${data}/${sre_plda_data}/utt2spk \ | ||
--indim 256 \ | ||
--iter 10 | ||
echo "plda training finished" | ||
fi | ||
|
||
if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then | ||
echo "adapt the plda model ..." | ||
python wespeaker/bin/adapt_plda.py \ | ||
-mo ${exp_dir}/plda \ | ||
-ma ${exp_dir}/plda_adapt \ | ||
-ad ${exp_dir}/embeddings/sre16_major/xvector.scp \ | ||
-ws 0.75 \ | ||
-as 0.25 | ||
echo "plda adapted finished" | ||
fi | ||
|
||
if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then | ||
echo "apply plda scoring ..." | ||
mkdir -p ${exp_dir}/scores | ||
trials_dir=${data}/trials | ||
for x in $trials; do | ||
echo "scoring on " $x | ||
python wespeaker/bin/eval_plda.py \ | ||
--enroll_scp_path ${exp_dir}/embeddings/sre16_eval_enroll/xvector.scp \ | ||
--test_scp_path ${exp_dir}/embeddings/sre16_eval_test/xvector.scp \ | ||
--indomain_scp ${exp_dir}/embeddings/sre16_major/xvector.scp \ | ||
--utt2spk data/sre16_eval_enroll/utt2spk \ | ||
--trial ${trials_dir}/${x} \ | ||
--score_path ${exp_dir}/scores/${x}.pldascore \ | ||
--model_path ${exp_dir}/plda_adapt | ||
done | ||
fi | ||
|
||
if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then | ||
echo "compute metrics (EER/minDCF) ..." | ||
scores_dir=${exp_dir}/scores | ||
for x in $trials; do | ||
python wespeaker/bin/compute_metrics.py \ | ||
--p_target 0.01 \ | ||
--c_fa 1 \ | ||
--c_miss 1 \ | ||
${scores_dir}/${x}.pldascore \ | ||
2>&1 | tee -a ${scores_dir}/sre16_plda_result | ||
|
||
echo "compute DET curve ..." | ||
python wespeaker/bin/compute_det.py \ | ||
${scores_dir}/${x}.pldascore | ||
done | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Copyright (c) 2023 Brno University of Technology | ||
# Shuai Wang ([email protected]) | ||
# | ||
# Python implementation of Kaldi unsupervised PLDA adaptation | ||
# ( https://github.com/kaldi-asr/kaldi/blob/master/src/ivector/plda.cc#L613 ) | ||
# by Daniel Povey. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
import argparse | ||
|
||
from wespeaker.utils.plda.two_cov_plda import TwoCovPLDA | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--adp_scp', '-ad', | ||
type=str, | ||
required=True, | ||
help='Data for unlabeled adaptation.') | ||
parser.add_argument('--across_class_scale', '-as', | ||
type=float, | ||
help='Scaling factor for across class covariance.', | ||
default=0.5) | ||
parser.add_argument('--within_class_scale', '-ws', | ||
type=float, | ||
help='Scaling factor for withn class covariance.', | ||
default=0.5) | ||
parser.add_argument('--mdl_org', '-mo', | ||
type=str, | ||
required=True, | ||
help='Original PLDA mdl.') | ||
parser.add_argument('--mdl_adp', '-ma', | ||
type=str, | ||
required=True, | ||
help='Adapted PLDA mdl.') | ||
parser.add_argument('--mdl_format', '-mf', | ||
type=str, | ||
default='wespeaker', | ||
help='Format of the model wespeaker/kaldi') | ||
|
||
args = parser.parse_args() | ||
|
||
kaldi_format = True if args.mdl_format == 'kaldi' else False | ||
plda = TwoCovPLDA.load_model(args.mdl_org, kaldi_format) | ||
adapt_plda = plda.adapt(args.adp_scp, args.across_class_scale, | ||
args.within_class_scale) | ||
adapt_plda.save_model(args.mdl_adp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.