40     using namespace kaldi;
    44         "Save features as HTK files:\n"     45         "Each utterance will be stored as a unique HTK file in a specified directory.\n"    46         "The HTK filename will correspond to the utterance-id (key) in the input table, with the specified extension.\n"    47         "Usage: copy-feats-to-htk [options] in-rspecifier\n"    48         "Example: copy-feats-to-htk --output-dir=/tmp/HTK-features --output-ext=fea  scp:feats.scp\n";
    51     std::string dir_out = 
"./";
    52     std::string ext_out = 
"fea";
    53     int32 sample_period = 100000; 
    54     int32 sample_kind = 9; 
    70     po.Register(
"output-ext", &ext_out, 
"Output ext of HTK files");
    71     po.Register(
"output-dir", &dir_out, 
"Output directory");
    72     po.Register(
"sample-period", &sample_period, 
"HTK sampPeriod - sample period in 100ns units");
    73     po.Register(
"sample-kind", &sample_kind, 
"HTK parmKind - a code indicating the sample kind (e.g., 6=MFCC, 7=FBANK, 9=USER, 11=PLP)");
    81     if (po.NumArgs() != 1) {
    86     std::string rspecifier = po.GetArg(1);
    89     const char * c = dir_out.c_str();
    90    if ( access( c, 0 ) != 0 ){
    94        if (mkdir(c, S_IRWXU|S_IRGRP|S_IXGRP) != 0)
    96        KALDI_ERR << 
"Could not create output directory: " << dir_out;
   115     int32 num_frames, dim, num_done=0;
   117     for (; !feats_reader.Done(); feats_reader.Next()) {
   118       std::string utt = feats_reader.Key();
   127       std::stringstream ss;
   128       ss << dir_out << 
"/" << utt << 
"." << ext_out; 
   129       output.Range(0, num_frames, 0, dim).CopyFromMat(feats.
Range(0, num_frames, 0, dim));    
   130       std::ofstream os(ss.str().c_str(), std::ios::out|std::ios::binary);
   134     KALDI_LOG << num_done << 
" HTK feature files generated in the direcory: " << dir_out;
   135     return (num_done != 0 ? 0 : 1);
   137   } 
catch(
const std::exception &e) {
   138     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). 
 
bool WriteHtk(std::ostream &os, const MatrixBase< Real > &M, HtkHeader htk_hdr)
 
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...
 
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix). 
 
SubMatrix< Real > Range(const MatrixIndexT row_offset, const MatrixIndexT num_rows, const MatrixIndexT col_offset, const MatrixIndexT num_cols) const
Return a sub-part of matrix.