| | |
| | | cmvn_path = pathAppend(path, "am.mvn"); |
| | | config_path = pathAppend(path, "config.yaml"); |
| | | |
| | | fe = new FeatureExtract(3); |
| | | fft_input = (float *)fftwf_malloc(sizeof(float) * fft_size); |
| | | fft_out = (fftwf_complex *)fftwf_malloc(sizeof(fftwf_complex) * fft_size); |
| | | memset(fft_input, 0, sizeof(float) * fft_size); |
| | | plan = fftwf_plan_dft_r2c_1d(fft_size, fft_input, fft_out, FFTW_ESTIMATE); |
| | | |
| | | //sessionOptions.SetInterOpNumThreads(1); |
| | | sessionOptions.SetIntraOpNumThreads(nNumThread); |
| | |
| | | |
| | | ModelImp::~ModelImp() |
| | | { |
| | | if(fe) |
| | | delete fe; |
| | | if (m_session) |
| | | { |
| | | delete m_session; |
| | |
| | | } |
| | | if(vocab) |
| | | delete vocab; |
| | | fftwf_free(fft_input); |
| | | fftwf_free(fft_out); |
| | | fftwf_destroy_plan(plan); |
| | | fftwf_cleanup(); |
| | | } |
| | | |
| | | void ModelImp::reset() |
| | | { |
| | | fe->reset(); |
| | | printf("Not Imp!!!!!!\n"); |
| | | } |
| | | |
| | | void ModelImp::apply_lfr(Tensor<float>*& din) |
| | |
| | | |
| | | string ModelImp::forward(float* din, int len, int flag) |
| | | { |
| | | |
| | | Tensor<float>* in; |
| | | fe->insert(din, len, flag); |
| | | FeatureExtract* fe = new FeatureExtract(3); |
| | | fe->reset(); |
| | | fe->insert(plan, din, len, flag); |
| | | fe->fetch(in); |
| | | apply_lfr(in); |
| | | apply_cmvn(in); |
| | |
| | | auto outputTensor = m_session->Run(run_option, m_szInputNames.data(), input_onnx.data(), m_szInputNames.size(), m_szOutputNames.data(), m_szOutputNames.size()); |
| | | std::vector<int64_t> outputShape = outputTensor[0].GetTensorTypeAndShapeInfo().GetShape(); |
| | | |
| | | |
| | | int64_t outputCount = std::accumulate(outputShape.begin(), outputShape.end(), 1, std::multiplies<int64_t>()); |
| | | float* floatData = outputTensor[0].GetTensorMutableData<float>(); |
| | | auto encoder_out_lens = outputTensor[1].GetTensorMutableData<int64_t>(); |
| | |
| | | result = ""; |
| | | } |
| | | |
| | | |
| | | if(in) |
| | | if(in){ |
| | | delete in; |
| | | in = nullptr; |
| | | } |
| | | if(fe){ |
| | | delete fe; |
| | | fe = nullptr; |
| | | } |
| | | |
| | | return result; |
| | | } |