diff --git a/fluid/DeepASR/decoder/post_latgen_faster_mapped.cc b/fluid/DeepASR/decoder/post_latgen_faster_mapped.cc index 87791d513162c5e53ccd1eaca1ec5a2a79c2afa0..f83730ce51a78ae302107914194f4e5699b4afd0 100644 --- a/fluid/DeepASR/decoder/post_latgen_faster_mapped.cc +++ b/fluid/DeepASR/decoder/post_latgen_faster_mapped.cc @@ -26,6 +26,7 @@ Decoder::Decoder(std::string trans_model_in_filename, std::string word_syms_filename, std::string fst_in_filename, std::string logprior_in_filename, + size_t beam_size, kaldi::BaseFloat acoustic_scale) { const char *usage = "Generate lattices using neural net model.\n" @@ -51,7 +52,7 @@ Decoder::Decoder(std::string trans_model_in_filename, int argc = 2; char *argv[] = {(char *)"post-latgen-faster-mapped", - (char *)("--beam=" + std::string("11")).c_str()}; + (char *)("--beam=" + std::to_string(beam_size)).c_str()}; po.Read(argc, argv); diff --git a/fluid/DeepASR/decoder/post_latgen_faster_mapped.h b/fluid/DeepASR/decoder/post_latgen_faster_mapped.h index 0bbb93065afab35a7bfd77d1e28b494bcabb42f3..9c234b8681690b9f1e3d30b61ac3b97b7055887f 100644 --- a/fluid/DeepASR/decoder/post_latgen_faster_mapped.h +++ b/fluid/DeepASR/decoder/post_latgen_faster_mapped.h @@ -29,6 +29,7 @@ public: std::string word_syms_filename, std::string fst_in_filename, std::string logprior_in_filename, + size_t beam_size, kaldi::BaseFloat acoustic_scale); ~Decoder(); diff --git a/fluid/DeepASR/decoder/pybind.cc b/fluid/DeepASR/decoder/pybind.cc index 151eae3b836bcc855e6bddb36c4ee682692d4a94..4a9b27d4cf862e5c1492875512fdeba3e95ecb15 100644 --- a/fluid/DeepASR/decoder/pybind.cc +++ b/fluid/DeepASR/decoder/pybind.cc @@ -27,6 +27,7 @@ PYBIND11_MODULE(post_latgen_faster_mapped, m) { std::string, std::string, std::string, + size_t, kaldi::BaseFloat>()) .def("decode_from_file", (void (Decoder::*)(std::string, size_t)) & Decoder::decode_from_file, diff --git a/fluid/DeepASR/examples/aishell/infer_by_ckpt.sh b/fluid/DeepASR/examples/aishell/infer_by_ckpt.sh index 990daee3756fc21bb18352a2ac3813e787a10380..60a48ba5daeb70fe46359caa09dc1301f2b158f2 100644 --- a/fluid/DeepASR/examples/aishell/infer_by_ckpt.sh +++ b/fluid/DeepASR/examples/aishell/infer_by_ckpt.sh @@ -4,10 +4,11 @@ export CUDA_VISIBLE_DEVICES=2,3,4,5 python -u ../../infer_by_ckpt.py --batch_size 96 \ --checkpoint checkpoints/deep_asr.pass_20.checkpoint \ --infer_feature_lst data/test_feature.lst \ - --mean_var data/aishell/global_mean_var \ + --mean_var data/global_mean_var \ --frame_dim 80 \ --class_num 3040 \ --num_threads 24 \ + --beam_size 11 \ --decode_to_path $decode_to_path \ --trans_model mapped_decoder_data/exp/tri5a/final.mdl \ --log_prior mapped_decoder_data/logprior \ diff --git a/fluid/DeepASR/infer_by_ckpt.py b/fluid/DeepASR/infer_by_ckpt.py index 881b5ba225665c4ad7b00727760500625b35a55b..1e0fb15c6d6f05aa1e054b37333b0fa0cb5cd8d9 100644 --- a/fluid/DeepASR/infer_by_ckpt.py +++ b/fluid/DeepASR/infer_by_ckpt.py @@ -27,6 +27,11 @@ def parse_args(): type=int, default=32, help='The sequence number of a batch data. (default: %(default)d)') + parser.add_argument( + '--beam_size', + type=int, + default=11, + help='The beam size for decoding. (default: %(default)d)') parser.add_argument( '--minimum_batch_size', type=int, @@ -211,7 +216,7 @@ def infer_from_ckpt(args): # init decoder decoder = Decoder(args.trans_model, args.vocabulary, args.graphs, - args.log_prior, args.acoustic_scale) + args.log_prior, args.beam_size, args.acoustic_scale) ltrans = [ trans_add_delta.TransAddDelta(2, 2),