28 int main(
int argc,
char *argv[]) {
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";
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).
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
A templated class for writing objects to an archive or script file; see The Table concept...
void Write(const std::string &key, const T &value) const
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].
const T & Value(const std::string &key)
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables.
std::string GetArg(int param) const
Returns one of the positional parameters; 1-based indexing for argc/argv compatibility.
MatrixIndexT Dim() const
Returns the dimension of the vector.
bool HasKey(const std::string &key)
Real Sum() const
Returns sum of the elements.
int NumArgs() const
Number of positional parameters (c.f. argc-1).
A class representing a vector.
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
int main(int argc, char *argv[])