|
|
@ -19,23 +19,24 @@
|
|
|
|
#include "decoder/ctc_tlg_decoder.h"
|
|
|
|
#include "decoder/ctc_tlg_decoder.h"
|
|
|
|
#include "frontend/audio/feature_pipeline.h"
|
|
|
|
#include "frontend/audio/feature_pipeline.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// feature
|
|
|
|
|
|
|
|
DEFINE_bool(use_fbank, false, "False for fbank; or linear feature");
|
|
|
|
|
|
|
|
// DEFINE_bool(to_float32, true, "audio convert to pcm32. True for linear
|
|
|
|
|
|
|
|
// feature, or fbank");
|
|
|
|
|
|
|
|
DEFINE_int32(num_bins, 161, "num bins of mel");
|
|
|
|
DEFINE_string(cmvn_file, "", "read cmvn");
|
|
|
|
DEFINE_string(cmvn_file, "", "read cmvn");
|
|
|
|
DEFINE_double(streaming_chunk, 0.1, "streaming feature chunk size");
|
|
|
|
DEFINE_double(streaming_chunk, 0.1, "streaming feature chunk size");
|
|
|
|
DEFINE_bool(to_float32, true, "audio convert to pcm32");
|
|
|
|
// feature sliding window
|
|
|
|
DEFINE_string(model_path, "avg_1.jit.pdmodel", "paddle nnet model");
|
|
|
|
|
|
|
|
DEFINE_string(param_path, "avg_1.jit.pdiparams", "paddle nnet model param");
|
|
|
|
|
|
|
|
DEFINE_string(word_symbol_table, "words.txt", "word symbol table");
|
|
|
|
|
|
|
|
DEFINE_string(graph_path, "TLG", "decoder graph");
|
|
|
|
|
|
|
|
DEFINE_double(acoustic_scale, 1.0, "acoustic scale");
|
|
|
|
|
|
|
|
DEFINE_int32(max_active, 7500, "max active");
|
|
|
|
|
|
|
|
DEFINE_double(beam, 15.0, "decoder beam");
|
|
|
|
|
|
|
|
DEFINE_double(lattice_beam, 7.5, "decoder beam");
|
|
|
|
|
|
|
|
DEFINE_int32(receptive_field_length,
|
|
|
|
DEFINE_int32(receptive_field_length,
|
|
|
|
7,
|
|
|
|
7,
|
|
|
|
"receptive field of two CNN(kernel=5) downsampling module.");
|
|
|
|
"receptive field of two CNN(kernel=5) downsampling module.");
|
|
|
|
DEFINE_int32(downsampling_rate,
|
|
|
|
DEFINE_int32(downsampling_rate,
|
|
|
|
4,
|
|
|
|
4,
|
|
|
|
"two CNN(kernel=5) module downsampling rate.");
|
|
|
|
"two CNN(kernel=5) module downsampling rate.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// nnet
|
|
|
|
|
|
|
|
DEFINE_string(model_path, "avg_1.jit.pdmodel", "paddle nnet model");
|
|
|
|
|
|
|
|
DEFINE_string(param_path, "avg_1.jit.pdiparams", "paddle nnet model param");
|
|
|
|
DEFINE_string(
|
|
|
|
DEFINE_string(
|
|
|
|
model_input_names,
|
|
|
|
model_input_names,
|
|
|
|
"audio_chunk,audio_chunk_lens,chunk_state_h_box,chunk_state_c_box",
|
|
|
|
"audio_chunk,audio_chunk_lens,chunk_state_h_box,chunk_state_c_box",
|
|
|
@ -47,8 +48,14 @@ DEFINE_string(model_cache_names,
|
|
|
|
"chunk_state_h_box,chunk_state_c_box",
|
|
|
|
"chunk_state_h_box,chunk_state_c_box",
|
|
|
|
"model cache names");
|
|
|
|
"model cache names");
|
|
|
|
DEFINE_string(model_cache_shapes, "5-1-1024,5-1-1024", "model cache shapes");
|
|
|
|
DEFINE_string(model_cache_shapes, "5-1-1024,5-1-1024", "model cache shapes");
|
|
|
|
DEFINE_bool(use_fbank, false, "use fbank or linear feature");
|
|
|
|
|
|
|
|
DEFINE_int32(num_bins, 161, "num bins of mel");
|
|
|
|
// decoder
|
|
|
|
|
|
|
|
DEFINE_string(word_symbol_table, "words.txt", "word symbol table");
|
|
|
|
|
|
|
|
DEFINE_string(graph_path, "TLG", "decoder graph");
|
|
|
|
|
|
|
|
DEFINE_double(acoustic_scale, 1.0, "acoustic scale");
|
|
|
|
|
|
|
|
DEFINE_int32(max_active, 7500, "max active");
|
|
|
|
|
|
|
|
DEFINE_double(beam, 15.0, "decoder beam");
|
|
|
|
|
|
|
|
DEFINE_double(lattice_beam, 7.5, "decoder beam");
|
|
|
|
|
|
|
|
|
|
|
|
namespace ppspeech {
|
|
|
|
namespace ppspeech {
|
|
|
|
// todo refactor later
|
|
|
|
// todo refactor later
|
|
|
@ -56,22 +63,23 @@ FeaturePipelineOptions InitFeaturePipelineOptions() {
|
|
|
|
FeaturePipelineOptions opts;
|
|
|
|
FeaturePipelineOptions opts;
|
|
|
|
opts.cmvn_file = FLAGS_cmvn_file;
|
|
|
|
opts.cmvn_file = FLAGS_cmvn_file;
|
|
|
|
opts.linear_spectrogram_opts.streaming_chunk = FLAGS_streaming_chunk;
|
|
|
|
opts.linear_spectrogram_opts.streaming_chunk = FLAGS_streaming_chunk;
|
|
|
|
opts.to_float32 = FLAGS_to_float32;
|
|
|
|
|
|
|
|
kaldi::FrameExtractionOptions frame_opts;
|
|
|
|
kaldi::FrameExtractionOptions frame_opts;
|
|
|
|
frame_opts.dither = 0.0;
|
|
|
|
frame_opts.dither = 0.0;
|
|
|
|
frame_opts.frame_shift_ms = 10;
|
|
|
|
frame_opts.frame_shift_ms = 10;
|
|
|
|
opts.use_fbank = FLAGS_use_fbank;
|
|
|
|
opts.use_fbank = FLAGS_use_fbank;
|
|
|
|
if (opts.use_fbank) {
|
|
|
|
if (opts.use_fbank) {
|
|
|
|
frame_opts.window_type = "povey";
|
|
|
|
opts.to_float32 = false;
|
|
|
|
frame_opts.frame_length_ms = 25;
|
|
|
|
frame_opts.window_type = "povey";
|
|
|
|
opts.fbank_opts.fbank_opts.mel_opts.num_bins = FLAGS_num_bins;
|
|
|
|
frame_opts.frame_length_ms = 25;
|
|
|
|
opts.fbank_opts.fbank_opts.frame_opts = frame_opts;
|
|
|
|
opts.fbank_opts.fbank_opts.mel_opts.num_bins = FLAGS_num_bins;
|
|
|
|
|
|
|
|
opts.fbank_opts.fbank_opts.frame_opts = frame_opts;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
frame_opts.remove_dc_offset = false;
|
|
|
|
opts.to_float32 = true;
|
|
|
|
frame_opts.frame_length_ms = 20;
|
|
|
|
frame_opts.remove_dc_offset = false;
|
|
|
|
frame_opts.window_type = "hanning";
|
|
|
|
frame_opts.frame_length_ms = 20;
|
|
|
|
frame_opts.preemph_coeff = 0.0;
|
|
|
|
frame_opts.window_type = "hanning";
|
|
|
|
opts.linear_spectrogram_opts.frame_opts = frame_opts;
|
|
|
|
frame_opts.preemph_coeff = 0.0;
|
|
|
|
|
|
|
|
opts.linear_spectrogram_opts.frame_opts = frame_opts;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
opts.feature_cache_opts.frame_chunk_size = FLAGS_receptive_field_length;
|
|
|
|
opts.feature_cache_opts.frame_chunk_size = FLAGS_receptive_field_length;
|
|
|
|
opts.feature_cache_opts.frame_chunk_stride = FLAGS_downsampling_rate;
|
|
|
|
opts.feature_cache_opts.frame_chunk_stride = FLAGS_downsampling_rate;
|
|
|
|