提交 56a0a024 编写于 作者: H Hui Zhang

format code

上级 616fc459
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
#pragma once #pragma once
#include "kaldi/base/kaldi-types.h"
#include <limits> #include <limits>
#include "kaldi/base/kaldi-types.h"
typedef float BaseFloat; typedef float BaseFloat;
typedef double double64; typedef double double64;
......
...@@ -47,6 +47,5 @@ ...@@ -47,6 +47,5 @@
#include "base/flags.h" #include "base/flags.h"
#include "base/log.h" #include "base/log.h"
#include "base/macros.h" #include "base/macros.h"
#include "utils/file_utils.h" #include "utils/file_utils.h"
#include "utils/math.h" #include "utils/math.h"
\ No newline at end of file
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "decoder/ctc_beam_search_opt.h" #include "decoder/ctc_beam_search_opt.h"
#include "decoder/ctc_prefix_beam_search_score.h" #include "decoder/ctc_prefix_beam_search_score.h"
#include "decoder/decoder_itf.h" #include "decoder/decoder_itf.h"
#include "fst/symbol-table.h" #include "fst/symbol-table.h"
namespace ppspeech { namespace ppspeech {
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "base/common.h" #include "base/common.h"
#include "decoder/decoder_itf.h" #include "decoder/decoder_itf.h"
#include "kaldi/decoder/lattice-faster-online-decoder.h" #include "kaldi/decoder/lattice-faster-online-decoder.h"
#include "util/parse-options.h" #include "util/parse-options.h"
...@@ -35,7 +34,7 @@ struct TLGDecoderOptions { ...@@ -35,7 +34,7 @@ struct TLGDecoderOptions {
std::string word_symbol_table{}; std::string word_symbol_table{};
std::string fst_path{}; std::string fst_path{};
static TLGDecoderOptions InitFromFlags(){ static TLGDecoderOptions InitFromFlags() {
TLGDecoderOptions decoder_opts; TLGDecoderOptions decoder_opts;
decoder_opts.word_symbol_table = FLAGS_word_symbol_table; decoder_opts.word_symbol_table = FLAGS_word_symbol_table;
decoder_opts.fst_path = FLAGS_graph_path; decoder_opts.fst_path = FLAGS_graph_path;
...@@ -45,9 +44,11 @@ struct TLGDecoderOptions { ...@@ -45,9 +44,11 @@ struct TLGDecoderOptions {
decoder_opts.opts.max_active = FLAGS_max_active; decoder_opts.opts.max_active = FLAGS_max_active;
decoder_opts.opts.beam = FLAGS_beam; decoder_opts.opts.beam = FLAGS_beam;
decoder_opts.opts.lattice_beam = FLAGS_lattice_beam; decoder_opts.opts.lattice_beam = FLAGS_lattice_beam;
LOG(INFO) << "LatticeFasterDecoder max active: " << decoder_opts.opts.max_active ; LOG(INFO) << "LatticeFasterDecoder max active: "
LOG(INFO) << "LatticeFasterDecoder beam: " << decoder_opts.opts.beam ; << decoder_opts.opts.max_active;
LOG(INFO) << "LatticeFasterDecoder lattice_beam: " << decoder_opts.opts.lattice_beam ; LOG(INFO) << "LatticeFasterDecoder beam: " << decoder_opts.opts.beam;
LOG(INFO) << "LatticeFasterDecoder lattice_beam: "
<< decoder_opts.opts.lattice_beam;
return decoder_opts; return decoder_opts;
} }
......
...@@ -30,7 +30,7 @@ DEFINE_int32(receptive_field_length, ...@@ -30,7 +30,7 @@ DEFINE_int32(receptive_field_length,
7, 7,
"receptive field of two CNN(kernel=3) downsampling module."); "receptive field of two CNN(kernel=3) downsampling module.");
DEFINE_int32(subsampling_rate, DEFINE_int32(subsampling_rate,
4, 4,
"two CNN(kernel=3) module downsampling rate."); "two CNN(kernel=3) module downsampling rate.");
DEFINE_int32(nnet_decoder_chunk, 1, "paddle nnet forward chunk"); DEFINE_int32(nnet_decoder_chunk, 1, "paddle nnet forward chunk");
...@@ -62,7 +62,6 @@ DEFINE_double(beam, 15.0, "decoder beam"); ...@@ -62,7 +62,6 @@ DEFINE_double(beam, 15.0, "decoder beam");
DEFINE_double(lattice_beam, 7.5, "decoder beam"); DEFINE_double(lattice_beam, 7.5, "decoder beam");
// DecodeOptions flags // DecodeOptions flags
// DEFINE_int32(chunk_size, -1, "decoding chunk size"); // DEFINE_int32(chunk_size, -1, "decoding chunk size");
DEFINE_int32(num_left_chunks, -1, "left chunks in decoding"); DEFINE_int32(num_left_chunks, -1, "left chunks in decoding");
......
...@@ -32,15 +32,15 @@ struct RecognizerResource { ...@@ -32,15 +32,15 @@ struct RecognizerResource {
ModelOptions model_opts{}; ModelOptions model_opts{};
TLGDecoderOptions tlg_opts{}; TLGDecoderOptions tlg_opts{};
// CTCBeamSearchOptions beam_search_opts; // CTCBeamSearchOptions beam_search_opts;
static RecognizerResource InitFromFlags(){ static RecognizerResource InitFromFlags() {
RecognizerResource resource; RecognizerResource resource;
resource.acoustic_scale = FLAGS_acoustic_scale; resource.acoustic_scale = FLAGS_acoustic_scale;
resource.feature_pipeline_opts = FeaturePipelineOptions::InitFromFlags(); resource.feature_pipeline_opts =
FeaturePipelineOptions::InitFromFlags();
resource.model_opts = ModelOptions::InitFromFlags(); resource.model_opts = ModelOptions::InitFromFlags();
resource.tlg_opts = TLGDecoderOptions::InitFromFlags(); resource.tlg_opts = TLGDecoderOptions::InitFromFlags();
return resource; return resource;
} }
}; };
......
...@@ -21,10 +21,9 @@ ...@@ -21,10 +21,9 @@
#include "decoder/ctc_prefix_beam_search_decoder.h" #include "decoder/ctc_prefix_beam_search_decoder.h"
#include "decoder/decoder_itf.h" #include "decoder/decoder_itf.h"
#include "frontend/audio/feature_pipeline.h" #include "frontend/audio/feature_pipeline.h"
#include "nnet/decodable.h"
#include "fst/fstlib.h" #include "fst/fstlib.h"
#include "fst/symbol-table.h" #include "fst/symbol-table.h"
#include "nnet/decodable.h"
DECLARE_int32(nnet_decoder_chunk); DECLARE_int32(nnet_decoder_chunk);
DECLARE_int32(num_left_chunks); DECLARE_int32(num_left_chunks);
...@@ -63,9 +62,9 @@ struct DecodeOptions { ...@@ -63,9 +62,9 @@ struct DecodeOptions {
// CtcEndpointConfig ctc_endpoint_opts; // CtcEndpointConfig ctc_endpoint_opts;
CTCBeamSearchOptions ctc_prefix_search_opts{}; CTCBeamSearchOptions ctc_prefix_search_opts{};
static DecodeOptions InitFromFlags(){ static DecodeOptions InitFromFlags() {
DecodeOptions decoder_opts; DecodeOptions decoder_opts;
decoder_opts.chunk_size=FLAGS_nnet_decoder_chunk; decoder_opts.chunk_size = FLAGS_nnet_decoder_chunk;
decoder_opts.num_left_chunks = FLAGS_num_left_chunks; decoder_opts.num_left_chunks = FLAGS_num_left_chunks;
decoder_opts.ctc_weight = FLAGS_ctc_weight; decoder_opts.ctc_weight = FLAGS_ctc_weight;
decoder_opts.rescoring_weight = FLAGS_rescoring_weight; decoder_opts.rescoring_weight = FLAGS_rescoring_weight;
...@@ -86,15 +85,16 @@ struct U2RecognizerResource { ...@@ -86,15 +85,16 @@ struct U2RecognizerResource {
DecodeOptions decoder_opts{}; DecodeOptions decoder_opts{};
static U2RecognizerResource InitFromFlags() { static U2RecognizerResource InitFromFlags() {
U2RecognizerResource resource; U2RecognizerResource resource;
resource.vocab_path = FLAGS_vocab_path; resource.vocab_path = FLAGS_vocab_path;
resource.acoustic_scale = FLAGS_acoustic_scale; resource.acoustic_scale = FLAGS_acoustic_scale;
resource.feature_pipeline_opts = ppspeech::FeaturePipelineOptions::InitFromFlags(); resource.feature_pipeline_opts =
resource.model_opts = ppspeech::ModelOptions::InitFromFlags(); ppspeech::FeaturePipelineOptions::InitFromFlags();
resource.decoder_opts = ppspeech::DecodeOptions::InitFromFlags(); resource.model_opts = ppspeech::ModelOptions::InitFromFlags();
return resource; resource.decoder_opts = ppspeech::DecodeOptions::InitFromFlags();
} return resource;
}
}; };
......
...@@ -56,4 +56,4 @@ class DataCache : public FrontendInterface { ...@@ -56,4 +56,4 @@ class DataCache : public FrontendInterface {
DISALLOW_COPY_AND_ASSIGN(DataCache); DISALLOW_COPY_AND_ASSIGN(DataCache);
}; };
} } // namespace ppspeech
\ No newline at end of file \ No newline at end of file
...@@ -46,17 +46,17 @@ struct FeaturePipelineOptions { ...@@ -46,17 +46,17 @@ struct FeaturePipelineOptions {
FeatureCacheOptions feature_cache_opts{}; FeatureCacheOptions feature_cache_opts{};
AssemblerOptions assembler_opts{}; AssemblerOptions assembler_opts{};
static FeaturePipelineOptions InitFromFlags(){ static FeaturePipelineOptions InitFromFlags() {
FeaturePipelineOptions opts; FeaturePipelineOptions opts;
opts.cmvn_file = FLAGS_cmvn_file; opts.cmvn_file = FLAGS_cmvn_file;
LOG(INFO) << "cmvn file: " << opts.cmvn_file; LOG(INFO) << "cmvn file: " << opts.cmvn_file;
// frame options // frame options
kaldi::FrameExtractionOptions frame_opts; kaldi::FrameExtractionOptions frame_opts;
frame_opts.dither = 0.0; frame_opts.dither = 0.0;
LOG(INFO) << "dither: " << frame_opts.dither; LOG(INFO) << "dither: " << frame_opts.dither;
frame_opts.frame_shift_ms = 10; frame_opts.frame_shift_ms = 10;
LOG(INFO) << "frame shift ms: " << frame_opts.frame_shift_ms; LOG(INFO) << "frame shift ms: " << frame_opts.frame_shift_ms;
opts.use_fbank = FLAGS_use_fbank; opts.use_fbank = FLAGS_use_fbank;
LOG(INFO) << "feature type: " << (opts.use_fbank ? "fbank" : "linear"); LOG(INFO) << "feature type: " << (opts.use_fbank ? "fbank" : "linear");
if (opts.use_fbank) { if (opts.use_fbank) {
...@@ -76,15 +76,19 @@ struct FeaturePipelineOptions { ...@@ -76,15 +76,19 @@ struct FeaturePipelineOptions {
opts.linear_spectrogram_opts.frame_opts = frame_opts; opts.linear_spectrogram_opts.frame_opts = frame_opts;
} }
LOG(INFO) << "frame length ms: " << frame_opts.frame_length_ms; LOG(INFO) << "frame length ms: " << frame_opts.frame_length_ms;
// assembler opts // assembler opts
opts.assembler_opts.subsampling_rate = FLAGS_subsampling_rate; opts.assembler_opts.subsampling_rate = FLAGS_subsampling_rate;
LOG(INFO) << "subsampling rate: " << opts.assembler_opts.subsampling_rate; LOG(INFO) << "subsampling rate: "
opts.assembler_opts.receptive_filed_length = FLAGS_receptive_field_length; << opts.assembler_opts.subsampling_rate;
LOG(INFO) << "nnet receptive filed length: " << opts.assembler_opts.receptive_filed_length; opts.assembler_opts.receptive_filed_length =
FLAGS_receptive_field_length;
LOG(INFO) << "nnet receptive filed length: "
<< opts.assembler_opts.receptive_filed_length;
opts.assembler_opts.nnet_decoder_chunk = FLAGS_nnet_decoder_chunk; opts.assembler_opts.nnet_decoder_chunk = FLAGS_nnet_decoder_chunk;
LOG(INFO) << "nnet chunk size: " << opts.assembler_opts.nnet_decoder_chunk; LOG(INFO) << "nnet chunk size: "
<< opts.assembler_opts.nnet_decoder_chunk;
return opts; return opts;
} }
}; };
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#pragma once #pragma once
#include "kaldi/feat/feature-mfcc.h"
#include "kaldi/feat/feature-mfcc.h" #include "kaldi/feat/feature-mfcc.h"
#include "kaldi/matrix/kaldi-vector.h" #include "kaldi/matrix/kaldi-vector.h"
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
#pragma once #pragma once
#include <numeric> #include <numeric>
#include "base/common.h" #include "base/common.h"
#include "kaldi/matrix/kaldi-matrix.h" #include "kaldi/matrix/kaldi-matrix.h"
#include "nnet/nnet_itf.h" #include "nnet/nnet_itf.h"
......
...@@ -48,25 +48,25 @@ struct ModelOptions { ...@@ -48,25 +48,25 @@ struct ModelOptions {
bool enable_fc_padding{false}; bool enable_fc_padding{false};
bool enable_profile{false}; bool enable_profile{false};
static ModelOptions InitFromFlags(){ static ModelOptions InitFromFlags() {
ModelOptions opts; ModelOptions opts;
opts.subsample_rate = FLAGS_subsampling_rate; opts.subsample_rate = FLAGS_subsampling_rate;
LOG(INFO) << "subsampling rate: " << opts.subsample_rate; LOG(INFO) << "subsampling rate: " << opts.subsample_rate;
opts.model_path = FLAGS_model_path; opts.model_path = FLAGS_model_path;
LOG(INFO) << "model path: " << opts.model_path ; LOG(INFO) << "model path: " << opts.model_path;
opts.param_path = FLAGS_param_path; opts.param_path = FLAGS_param_path;
LOG(INFO) << "param path: " << opts.param_path ; LOG(INFO) << "param path: " << opts.param_path;
LOG(INFO) << "DS2 param: "; LOG(INFO) << "DS2 param: ";
opts.cache_names = FLAGS_model_cache_names; opts.cache_names = FLAGS_model_cache_names;
LOG(INFO) << " cache names: " << opts.cache_names; LOG(INFO) << " cache names: " << opts.cache_names;
opts.cache_shape = FLAGS_model_cache_shapes; opts.cache_shape = FLAGS_model_cache_shapes;
LOG(INFO) << " cache shape: " << opts.cache_shape; LOG(INFO) << " cache shape: " << opts.cache_shape;
opts.input_names = FLAGS_model_input_names; opts.input_names = FLAGS_model_input_names;
LOG(INFO) << " input names: " << opts.input_names; LOG(INFO) << " input names: " << opts.input_names;
opts.output_names = FLAGS_model_output_names; opts.output_names = FLAGS_model_output_names;
LOG(INFO) << " output names: " << opts.output_names; LOG(INFO) << " output names: " << opts.output_names;
return opts; return opts;
} }
}; };
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "base/common.h" #include "base/common.h"
#include "kaldi/matrix/kaldi-matrix.h" #include "kaldi/matrix/kaldi-matrix.h"
#include "nnet/nnet_itf.h" #include "nnet/nnet_itf.h"
#include "paddle/extension.h" #include "paddle/extension.h"
#include "paddle/jit/all.h" #include "paddle/jit/all.h"
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
#include "base/common.h" #include "base/common.h"
#include "boost/asio/connect.hpp" #include "boost/asio/connect.hpp"
#include "boost/asio/ip/tcp.hpp" #include "boost/asio/ip/tcp.hpp"
#include "boost/beast/core.hpp" #include "boost/beast/core.hpp"
...@@ -54,4 +53,4 @@ class WebSocketClient { ...@@ -54,4 +53,4 @@ class WebSocketClient {
websocket::stream<tcp::socket> ws_{ioc_}; websocket::stream<tcp::socket> ws_{ioc_};
std::unique_ptr<std::thread> t_{nullptr}; std::unique_ptr<std::thread> t_{nullptr};
}; };
} } // namespace ppspeech
\ No newline at end of file \ No newline at end of file
...@@ -15,12 +15,10 @@ ...@@ -15,12 +15,10 @@
#pragma once #pragma once
#include "base/common.h" #include "base/common.h"
#include "boost/asio/connect.hpp" #include "boost/asio/connect.hpp"
#include "boost/asio/ip/tcp.hpp" #include "boost/asio/ip/tcp.hpp"
#include "boost/beast/core.hpp" #include "boost/beast/core.hpp"
#include "boost/beast/websocket.hpp" #include "boost/beast/websocket.hpp"
#include "decoder/recognizer.h" #include "decoder/recognizer.h"
#include "frontend/audio/feature_pipeline.h" #include "frontend/audio/feature_pipeline.h"
......
...@@ -20,4 +20,4 @@ bool ReadFileToVector(const std::string& filename, ...@@ -20,4 +20,4 @@ bool ReadFileToVector(const std::string& filename,
std::vector<std::string>* data); std::vector<std::string>* data);
std::string ReadFile2String(const std::string& path); std::string ReadFile2String(const std::string& path);
} } // namespace ppspeech
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册