| | |
| | | } |
| | | } |
| | | |
| | | void print_segs(vector<vector<int>>* vec) { |
| | | string seg_out="["; |
| | | void print_segs(vector<vector<int>>* vec, string &wav_id) { |
| | | string seg_out=wav_id + ": ["; |
| | | for (int i = 0; i < vec->size(); i++) { |
| | | vector<int> inner_vec = (*vec)[i]; |
| | | seg_out += "["; |
| | |
| | | |
| | | // read wav_path |
| | | vector<string> wav_list; |
| | | vector<string> wav_ids; |
| | | string default_id = "wav_default_id"; |
| | | string wav_path_ = model_path.at(WAV_PATH); |
| | | if(is_target_file(wav_path_, "wav") || is_target_file(wav_path_, "pcm")){ |
| | | wav_list.emplace_back(wav_path_); |
| | | wav_ids.emplace_back(default_id); |
| | | } |
| | | else if(is_target_file(wav_path_, "scp")){ |
| | | ifstream in(wav_path_); |
| | |
| | | istringstream iss(line); |
| | | string column1, column2; |
| | | iss >> column1 >> column2; |
| | | wav_list.emplace_back(column2); |
| | | wav_list.emplace_back(column2); |
| | | wav_ids.emplace_back(column1); |
| | | } |
| | | in.close(); |
| | | }else{ |
| | |
| | | |
| | | float snippet_time = 0.0f; |
| | | long taking_micros = 0; |
| | | for(auto& wav_file : wav_list){ |
| | | for (int i = 0; i < wav_list.size(); i++) { |
| | | auto& wav_file = wav_list[i]; |
| | | auto& wav_id = wav_ids[i]; |
| | | gettimeofday(&start, NULL); |
| | | FUNASR_RESULT result=FsmnVadInfer(vad_hanlde, wav_file.c_str(), NULL, 16000); |
| | | gettimeofday(&end, NULL); |
| | |
| | | if (result) |
| | | { |
| | | vector<std::vector<int>>* vad_segments = FsmnVadGetResult(result, 0); |
| | | print_segs(vad_segments); |
| | | print_segs(vad_segments, wav_id); |
| | | snippet_time += FsmnVadGetRetSnippetTime(result); |
| | | FsmnVadFreeResult(result); |
| | | } |
| | |
| | | LOG(ERROR) << ("No return data!\n"); |
| | | } |
| | | } |
| | | |
| | | |
| | | LOG(INFO) << "Audio length: " << (double)snippet_time << " s"; |
| | | LOG(INFO) << "Model inference takes: " << (double)taking_micros / 1000000 <<" s"; |
| | | LOG(INFO) << "Model inference RTF: " << (double)taking_micros/ (snippet_time*1000000); |