30 using namespace kaldi;
34 "Select a subset of frames of the input files, based on the output of\n" 35 "compute-vad or a similar program (a vector of length num-frames,\n" 36 "containing 1.0 for voiced, 0.0 for unvoiced). Caution: this is\n" 37 "mostly useful only in speaker identification applications.\n" 38 "Usage: select-voiced-frames [options] <feats-rspecifier> " 39 " <vad-rspecifier> <feats-wspecifier>\n" 40 "E.g.: select-voiced-frames [options] scp:feats.scp scp:vad.scp ark:-\n";
45 if (po.NumArgs() != 3) {
50 std::string feat_rspecifier = po.GetArg(1),
51 vad_rspecifier = po.GetArg(2),
52 feat_wspecifier = po.GetArg(3);
58 int32 num_done = 0, num_err = 0;
60 for (;!feat_reader.Done(); feat_reader.Next()) {
61 std::string utt = feat_reader.Key();
64 KALDI_WARN <<
"Empty feature matrix for utterance " << utt;
68 if (!vad_reader.HasKey(utt)) {
69 KALDI_WARN <<
"No VAD input found for utterance " << utt;
77 <<
" for features and VAD " << voiced.
Dim()
78 <<
", for utterance " << utt;
82 if (voiced.
Sum() == 0.0) {
83 KALDI_WARN <<
"No features were judged as voiced for utterance " 95 if (voiced(
i) != 0.0) {
97 voiced_feat.Row(index).CopyFromVec(feat.
Row(
i));
102 feat_writer.Write(utt, voiced_feat);
106 KALDI_LOG <<
"Done selecting voiced frames; processed " 107 << num_done <<
" utterances, " 108 << num_err <<
" had errors.";
109 return (num_done != 0 ? 0 : 1);
110 }
catch(
const std::exception &e) {
111 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
A templated class for writing objects to an archive or script file; see The Table concept...
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].
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
MatrixIndexT Dim() const
Returns the dimension of the vector.
Real Sum() const
Returns sum of the elements.
A class representing a vector.
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).