77#include " online2/online-endpoint.h"
88#include " fstext/fstext-lib.h"
99#include " lat/lattice-functions.h"
10+ #include " lat/lattice-functions-transition-model.h"
1011#include " lat/word-align-lattice.h"
1112#include " nnet3/decodable-simple-looped.h"
1213
1516#endif
1617
1718const int arate = 8000 ;
18-
19+
1920void ConfigFeatureInfo (kaldi::OnlineNnet2FeaturePipelineInfo& info,
2021 std::string ivector_model_dir) {
2122 // Configure inline to avoid absolute paths in ".conf" files
@@ -32,7 +33,7 @@ void ConfigFeatureInfo(kaldi::OnlineNnet2FeaturePipelineInfo& info,
3233 &info.ivector_extractor_info .diag_ubm );
3334 ReadKaldiObject (ivector_model_dir + " /final.ie" ,
3435 &info.ivector_extractor_info .extractor );
35-
36+
3637 info.ivector_extractor_info .num_gselect = 5 ;
3738 info.ivector_extractor_info .min_post = 0.025 ;
3839 info.ivector_extractor_info .posterior_scale = 0.1 ;
@@ -77,12 +78,12 @@ int main(int argc, char *argv[]) {
7778 using namespace kaldi ;
7879 using namespace fst ;
7980
80- setbuf (stdout, NULL );
81+ setbuf (stdout, NULL );
8182
8283 std::string nnet_dir = " exp/tdnn_7b_chain_online" ;
8384 std::string graph_dir = nnet_dir + " /graph_pp" ;
8485 std::string fst_rxfilename = graph_dir + " /HCLG.fst" ;
85-
86+
8687 if (argc == 3 ) {
8788 nnet_dir = argv[1 ];
8889 graph_dir = nnet_dir + " /graph_pp" ;
@@ -92,7 +93,7 @@ int main(int argc, char *argv[]) {
9293 usage ();
9394 return EXIT_FAILURE;
9495 }
95-
96+
9697#ifdef HAVE_CUDA
9798 fprintf (stdout, " Cuda enabled\n " );
9899 CuDevice &cu_device = CuDevice::Instantiate ();
@@ -102,7 +103,7 @@ int main(int argc, char *argv[]) {
102103#endif
103104 const std::string ivector_model_dir = nnet_dir + " /ivector_extractor" ;
104105 const std::string nnet3_rxfilename = nnet_dir + " /final.mdl" ;
105-
106+
106107 const std::string word_syms_rxfilename = graph_dir + " /words.txt" ;
107108 const string word_boundary_filename = graph_dir + " /phones/word_boundary.int" ;
108109 const string phone_syms_rxfilename = graph_dir + " /phones.txt" ;
@@ -116,7 +117,7 @@ int main(int argc, char *argv[]) {
116117 ConfigDecoding (nnet3_decoding_config);
117118 OnlineEndpointConfig endpoint_config;
118119 ConfigEndpoint (endpoint_config);
119-
120+
120121
121122 BaseFloat frame_shift = feature_info.FrameShiftInSeconds ();
122123
@@ -133,16 +134,16 @@ int main(int argc, char *argv[]) {
133134 nnet_simple_looped_opts.acoustic_scale = 1.0 ; // changed from 0.1?
134135
135136 nnet3::DecodableNnetSimpleLoopedInfo de_nnet_simple_looped_info (nnet_simple_looped_opts, &am_nnet);
136-
137+
137138 fst::Fst<fst::StdArc> *decode_fst = ReadFstKaldi (fst_rxfilename);
138139
139140 fst::SymbolTable *word_syms =
140141 fst::SymbolTable::ReadText (word_syms_rxfilename);
141142
142143 fst::SymbolTable* phone_syms =
143144 fst::SymbolTable::ReadText (phone_syms_rxfilename);
144-
145-
145+
146+
146147 OnlineIvectorExtractorAdaptationState adaptation_state (feature_info.ivector_extractor_info );
147148
148149 OnlineNnet2FeaturePipeline feature_pipeline (feature_info);
@@ -151,7 +152,7 @@ int main(int argc, char *argv[]) {
151152 OnlineSilenceWeighting silence_weighting (
152153 trans_model,
153154 feature_info.silence_weighting_config );
154-
155+
155156 SingleUtteranceNnet3Decoder decoder (nnet3_decoding_config,
156157 trans_model,
157158 de_nnet_simple_looped_info,
@@ -172,7 +173,7 @@ int main(int argc, char *argv[]) {
172173 else if (strcmp (cmd," reset\n " ) == 0 ) {
173174 feature_pipeline.~OnlineNnet2FeaturePipeline ();
174175 new (&feature_pipeline) OnlineNnet2FeaturePipeline (feature_info);
175-
176+
176177 decoder.~SingleUtteranceNnet3Decoder ();
177178 new (&decoder) SingleUtteranceNnet3Decoder (nnet3_decoding_config,
178179 trans_model,
@@ -188,11 +189,11 @@ int main(int argc, char *argv[]) {
188189 fgets (cmd, sizeof (cmd), stdin);
189190 sscanf (cmd, " %d\n " , &chunk_len);
190191
191- int16_t audio_chunk[chunk_len];
192+ int16_t audio_chunk[chunk_len];
192193 Vector<BaseFloat> wave_part = Vector<BaseFloat>(chunk_len);
193-
194+
194195 fread (&audio_chunk, 2 , chunk_len, stdin);
195-
196+
196197 // We need to copy this into the `wave_part' Vector<BaseFloat> thing.
197198 // From `gst-audio-source.cc' in gst-kaldi-nnet2
198199 for (int i = 0 ; i < chunk_len ; ++i) {
@@ -221,7 +222,7 @@ int main(int argc, char *argv[]) {
221222 Lattice final_lat;
222223 decoder.GetBestPath (true , &final_lat);
223224 CompactLattice clat;
224- ConvertLattice (final_lat, &clat);
225+ ConvertLattice (final_lat, &clat);
225226
226227 // Compute prons alignment (see: kaldi/latbin/nbest-to-prons.cc)
227228 CompactLattice aligned_clat;
@@ -254,12 +255,12 @@ int main(int argc, char *argv[]) {
254255 }
255256
256257 fprintf (stdout, " done with words\n " );
257-
258+
258259 }
259260 else {
260261
261262 fprintf (stderr, " unknown command %s\n " , cmd);
262-
263+
263264 }
264265 }
265266}
0 commit comments