Skip to content
Snippets Groups Projects
Commit 81872dac authored by Guoguo Chen's avatar Guoguo Chen
Browse files

Add function GetPhonesForPdfs()

git-svn-id: https://svn.code.sf.net/p/kaldi/code/trunk@906 5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
parent 94165f7f
No related branches found
No related tags found
No related merge requests found
// hmm/transition-model.cc
// Copyright 2009-2012 Microsoft Corporation Daniel Povey
// Copyright 2009-2012 Microsoft Corporation Daniel Povey, Johns Hopkins
// University Guoguo Chen
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......@@ -556,5 +557,26 @@ bool GetPdfsForPhones(const TransitionModel &trans_model,
return true;
}
bool GetPhonesForPdfs(const TransitionModel &trans_model,
const std::vector<int32> &pdfs,
std::vector<int32> *phones) {
KALDI_ASSERT(IsSortedAndUniq(pdfs));
KALDI_ASSERT(phones != NULL);
phones->clear();
for (int32 tstate = 1; tstate <= trans_model.NumTransitionStates(); tstate++) {
if (std::binary_search(pdfs.begin(), pdfs.end(),
trans_model.TransitionStateToPdf(tstate)))
phones->push_back(trans_model.TransitionStateToPhone(tstate));
}
SortAndUniq(phones);
for (int32 tstate = 1; tstate <= trans_model.NumTransitionStates(); tstate++)
if (std::binary_search(phones->begin(), phones->end(),
trans_model.TransitionStateToPhone(tstate))
&& !std::binary_search(pdfs.begin(), pdfs.end(),
trans_model.TransitionStateToPdf(tstate)))
return false;
return true;
}
} // End namespace kaldi
......@@ -287,7 +287,11 @@ bool GetPdfsForPhones(const TransitionModel &trans_model,
const std::vector<int32> &phones,
std::vector<int32> *pdfs);
/// Works out which phones might correspond to the given pdfs. Similar to the
/// above GetPdfsForPhones(, ,)
bool GetPhonesForPdfs(const TransitionModel &trans_model,
const std::vector<int32> &pdfs,
std::vector<int32> *phones);
/// @}
} // end namespace kaldi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment