27 using namespace kaldi;
31 "Modify GMM-based model to boost (by a certain factor) all\n" 32 "probabilities associated with the specified phones (could be\n" 33 "all silence phones, or just the ones used for optional silence).\n" 34 "Note: this is done by modifying the GMM weights. If the silence\n" 35 "model shares a GMM with other models, then it will modify the GMM\n" 36 "weights for all models that may correspond to silence.\n" 38 "Usage: gmm-boost-silence [options] <silence-phones-list> <model-in> <model-out>\n" 39 "e.g.: gmm-boost-silence --boost=1.5 1:2:3 1.mdl 1_boostsil.mdl\n";
41 bool binary_write =
true;
45 po.Register(
"binary", &binary_write,
"Write output in binary mode");
46 po.Register(
"boost", &boost,
"Factor by which to boost silence probs");
50 if (po.NumArgs() != 3) {
56 silence_phones_string = po.GetArg(1),
57 model_rxfilename = po.GetArg(2),
58 model_wxfilename = po.GetArg(3);
60 std::vector<int32> silence_phones;
61 if (silence_phones_string !=
"") {
63 std::sort(silence_phones.begin(), silence_phones.end());
66 KALDI_WARN <<
"gmm-boost-silence: no silence phones specified, doing nothing.";
73 Input ki(model_rxfilename, &binary_read);
74 trans_model.
Read(ki.Stream(), binary_read);
75 am_gmm.
Read(ki.Stream(), binary_read);
79 std::vector<int32> pdfs;
82 KALDI_WARN <<
"The pdfs for the silence phones may be shared by other phones " 83 <<
"(note: this probably does not matter.)";
85 for (
size_t i = 0;
i < pdfs.size();
i++) {
93 KALDI_LOG <<
"Boosted weights for " << pdfs.size()
94 <<
" pdfs, by factor of " << boost;
98 Output ko(model_wxfilename, binary_write);
99 trans_model.
Write(ko.Stream(), binary_write);
100 am_gmm.
Write(ko.Stream(), binary_write);
103 KALDI_LOG <<
"Wrote model to " << model_wxfilename;
104 }
catch(
const std::exception &e) {
105 std::cerr << e.what() <<
'\n';
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
bool SplitStringToIntegers(const std::string &full, const char *delim, bool omit_empty_strings, std::vector< I > *out)
Split a string (e.g.
int32 ComputeGconsts()
Sets the gconsts.
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
void Read(std::istream &is, bool binary)
const Vector< BaseFloat > & weights() const
void Scale(Real alpha)
Multiplies all elements by this constant.
DiagGmm & GetPdf(int32 pdf_index)
Accessors.
void Write(std::ostream &os, bool binary) const
A class representing a vector.
#define KALDI_ASSERT(cond)
void Write(std::ostream &out_stream, bool binary) const
Definition for Gaussian Mixture Model with diagonal covariances.
void SetWeights(const VectorBase< Real > &w)
Mutators for both float or double.
bool GetPdfsForPhones(const TransitionModel &trans_model, const std::vector< int32 > &phones, std::vector< int32 > *pdfs)
Works out which pdfs might correspond to the given phones.
bool IsSortedAndUniq(const std::vector< T > &vec)
Returns true if the vector is sorted and contains each element only once.
void Read(std::istream &in_stream, bool binary)