30 using namespace kaldi;
34 "Apply weight to silences in posts\n" 35 "Usage: weight-silence-post [options] <silence-weight> <silence-phones> " 36 "<model> <posteriors-rspecifier> <posteriors-wspecifier>\n" 38 " weight-silence-post 0.0 1:2:3 1.mdl ark:1.post ark:nosil.post\n";
42 bool distribute =
false;
44 po.Register(
"distribute", &distribute,
"If true, rather than weighting the " 45 "individual posteriors, apply the weighting to the whole frame: " 46 "i.e. on time t, scale all posterior entries by " 47 "p(sil)*silence-weight + p(non-sil)*1.0");
51 if (po.NumArgs() != 5) {
57 std::string silence_weight_str = po.GetArg(1),
58 silence_phones_str = po.GetArg(2),
59 model_rxfilename = po.GetArg(3),
60 posteriors_rspecifier = po.GetArg(4),
61 posteriors_wspecifier = po.GetArg(5);
65 KALDI_ERR <<
"Invalid silence-weight parameter: expected float, got \"" 66 << silence_weight_str <<
'"';
67 std::vector<int32> silence_phones;
69 KALDI_ERR <<
"Invalid silence-phones string " << silence_phones_str;
70 if (silence_phones.empty())
71 KALDI_WARN <<
"No silence phones, this will have no effect";
77 int32 num_posteriors = 0;
81 for (; !posterior_reader.Done(); posterior_reader.Next()) {
84 Posterior post = posterior_reader.Value();
88 silence_weight, &post);
91 silence_weight, &post);
93 posterior_writer.Write(posterior_reader.Key(), post);
95 KALDI_LOG <<
"Done " << num_posteriors <<
" posteriors.";
96 return (num_posteriors != 0 ? 0 : 1);
97 }
catch(
const std::exception &e) {
98 std::cerr << e.what();
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.
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)
void WeightSilencePost(const TransitionModel &trans_model, const ConstIntegerSet< int32 > &silence_set, BaseFloat silence_scale, Posterior *post)
Weight any silence phones in the posterior (i.e.
std::vector< std::vector< std::pair< int32, BaseFloat > > > Posterior
Posterior is a typedef for storing acoustic-state (actually, transition-id) posteriors over an uttera...
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
void WeightSilencePostDistributed(const TransitionModel &trans_model, const ConstIntegerSet< int32 > &silence_set, BaseFloat silence_scale, Posterior *post)
This is similar to WeightSilencePost, except that on each frame it works out the amount by which the ...
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
bool ConvertStringToReal(const std::string &str, T *out)
ConvertStringToReal converts a string into either float or double and returns false if there was any ...