35 std::string *rspecifier) {
36 size_t pos = arg.find_first_of(
'=');
37 if (pos == std::string::npos) {
38 KALDI_ERR <<
"Bad command line argument (expecting '='): " 41 *name = std::string(arg, 0, pos);
42 *rspecifier = std::string(arg, pos + 1);
44 KALDI_ERR <<
"Bad command line argument (expecting a valid name before '='): " 48 KALDI_ERR <<
"Bad command line argument (expecting an rspecifier after '='): " 55 int main(
int argc,
char *argv[]) {
57 using namespace kaldi;
60 typedef kaldi::int64 int64;
63 "Get frame-by-frame examples of data for nnet3 neural network training.\n" 64 "This is like nnet3-get-egs, but does not split up its inputs into pieces\n" 65 "and allows more general generation of egs. E.g. this is usable for image\n" 66 "recognition tasks.\n" 68 "Usage: nnet3-get-egs-simple [options] <name1>=<rspecifier1> " 69 "<name2>=<rspecifier2> ...\n" 72 "nnet3-get-egs-simple input=scp:images.scp \\\n" 73 "output='ark,o:ali-to-post ark:labels.txt ark:- | post-to-smat --dim=10 ark:- ark:-' ark:egs.ark\n" 75 "See also: nnet3-get-egs\n";
93 std::string first_name, first_reader_name;
97 std::vector<std::string> other_names;
99 std::vector<RandomAccessGeneralMatrixReader*> other_readers;
102 std::string name, rspecifier;
104 other_names.push_back(name);
108 int32 num_done = 0, num_err = 0;
110 for (; !first_reader.Done(); first_reader.Next()) {
111 std::string key = first_reader.Key();
116 eg.
io.push_back(
NnetIo(first_name, t, feats));
118 for (
size_t i = 0;
i < other_names.size();
i++) {
119 if (!other_readers[
i]->HasKey(key)) {
120 KALDI_WARN <<
"Could not find input for key " << key
121 <<
" for io-name=" << other_names[
i];
126 eg.
io.push_back(
NnetIo(other_names[
i], t, other_feats));
131 example_writer.
Write(key, eg);
136 KALDI_WARN << num_err <<
" utterances had errors and could " 138 return (num_done > 0 ? 0 : 1);
139 }
catch(
const std::exception &e) {
140 std::cerr << e.what() <<
'\n';
NnetExample is the input data and corresponding label (or labels) for one or more frames of input...
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
This class is a wrapper that enables you to store a matrix in one of three forms: either as a Matrix<...
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
void SplitArgOnEquals(const std::string &arg, std::string *name, std::string *rspecifier)
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
RspecifierType ClassifyRspecifier(const std::string &rspecifier, std::string *rxfilename, RspecifierOptions *opts)
bool IsToken(const std::string &token)
Returns true if "token" is nonempty, and all characters are printable and whitespace-free.
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
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.
int main(int argc, char *argv[])
std::string GetArg(int param) const
Returns one of the positional parameters; 1-based indexing for argc/argv compatibility.
int NumArgs() const
Number of positional parameters (c.f. argc-1).
RandomAccessTableReader< KaldiObjectHolder< GeneralMatrix > > RandomAccessGeneralMatrixReader
std::vector< NnetIo > io
"io" contains the input and output.