115 using namespace kaldi;
119 "Perform PLDA scoring for speaker diarization. The input reco2utt\n" 120 "should be of the form <recording-id> <seg1> <seg2> ... <segN> and\n" 121 "there should be one iVector for each segment. PLDA scoring is\n" 122 "performed between all pairs of iVectors in a recording and outputs\n" 123 "an archive of score matrices, one for each recording-id. The rows\n" 124 "and columns of the the matrix correspond the sorted order of the\n" 126 "Usage: ivector-plda-scoring-dense [options] <plda> <reco2utt>" 127 " <ivectors-rspecifier> <scores-wspecifier>\n" 129 " ivector-plda-scoring-dense plda reco2utt scp:ivectors.scp" 130 " ark:scores.ark ark,t:ivectors.1.ark\n";
137 po.Register(
"target-energy", &target_energy,
138 "Reduce dimensionality of i-vectors using a recording-dependent" 139 " PCA such that this fraction of the total energy remains.");
144 if (po.NumArgs() != 4) {
149 std::string plda_rxfilename = po.GetArg(1),
150 reco2utt_rspecifier = po.GetArg(2),
151 ivector_rspecifier = po.GetArg(3),
152 scores_wspecifier = po.GetArg(4);
160 int32 num_reco_err = 0,
162 for (; !reco2utt_reader.Done(); reco2utt_reader.Next()) {
163 Plda this_plda(plda);
164 std::string reco = reco2utt_reader.Key();
166 std::vector<std::string> uttlist = reco2utt_reader.Value();
167 std::vector<Vector<BaseFloat> > ivectors;
169 for (
size_t i = 0;
i < uttlist.size();
i++) {
170 std::string utt = uttlist[
i];
172 if (!ivector_reader.HasKey(utt)) {
173 KALDI_ERR <<
"No iVector present in input for utterance " << utt;
177 ivectors.push_back(ivector);
179 if (ivectors.size() == 0) {
180 KALDI_WARN <<
"Not producing output for recording " << reco
181 <<
" since no segments had iVectors";
188 scores(ivectors.size(), ivectors.size());
190 for (
size_t i = 0;
i < ivectors.size();
i++) {
191 ivector_mat.
Row(
i).CopyFromVec(ivectors[
i]);
193 if (
EstPca(ivector_mat, target_energy, reco, &pca_transform)) {
195 ApplyPca(ivector_mat, pca_transform, &ivector_mat_pca);
208 for (int32
i = 0;
i < ivector_mat_plda.NumRows();
i++) {
209 for (int32
j = 0;
j < ivector_mat_plda.NumRows();
j++) {
211 ivector_mat_plda.Row(
i)), 1.0,
215 scores_writer.Write(reco, scores);
219 KALDI_LOG <<
"Processed " << num_reco_done <<
" recordings, " 220 << num_reco_err <<
" had errors.";
221 return (num_reco_done != 0 ? 0 : 1 );
222 }
catch(
const std::exception &e) {
223 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
A templated class for writing objects to an archive or script file; see The Table concept...
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
Allows random access to a collection of objects in an archive or script file; see The Table concept...
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const].
bool EstPca(const Matrix< BaseFloat > &ivector_mat, BaseFloat target_energy, const std::string &reco, Matrix< BaseFloat > *mat)
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
void Register(OptionsItf *opts)
void TransformIvectors(const Matrix< BaseFloat > &ivectors_in, const PldaConfig &plda_config, const Plda &plda, Matrix< BaseFloat > *ivectors_out)
A class representing a vector.
#define KALDI_ASSERT(cond)
void ApplyPca(const Matrix< BaseFloat > &ivectors_in, const Matrix< BaseFloat > &pca_mat, Matrix< BaseFloat > *ivectors_out)