| | |
| | | return nullptr; |
| | | |
| | | funasr::Audio audio(1); |
| | | if(wav_format == "pcm" || wav_format == "PCM"){ |
| | | if (!audio.LoadPcmwav(sz_buf, n_len, &sampling_rate)) |
| | | return nullptr; |
| | | }else{ |
| | | if (!audio.FfmpegLoad(sz_buf, n_len)) |
| | | return nullptr; |
| | | try{ |
| | | if(wav_format == "pcm" || wav_format == "PCM"){ |
| | | if (!audio.LoadPcmwav(sz_buf, n_len, &sampling_rate)) |
| | | return nullptr; |
| | | }else{ |
| | | if (!audio.FfmpegLoad(sz_buf, n_len)) |
| | | return nullptr; |
| | | } |
| | | }catch (std::exception const &e) |
| | | { |
| | | LOG(ERROR)<<e.what(); |
| | | return nullptr; |
| | | } |
| | | |
| | | funasr::FUNASR_RECOG_RESULT* p_result = new funasr::FUNASR_RECOG_RESULT; |
| | |
| | | return nullptr; |
| | | |
| | | funasr::Audio audio(1); |
| | | if(funasr::is_target_file(sz_filename, "wav")){ |
| | | int32_t sampling_rate_ = -1; |
| | | if(!audio.LoadWav(sz_filename, &sampling_rate_)) |
| | | return nullptr; |
| | | }else if(funasr::is_target_file(sz_filename, "pcm")){ |
| | | if (!audio.LoadPcmwav(sz_filename, &sampling_rate)) |
| | | return nullptr; |
| | | }else{ |
| | | if (!audio.FfmpegLoad(sz_filename)) |
| | | return nullptr; |
| | | try{ |
| | | if(funasr::is_target_file(sz_filename, "wav")){ |
| | | int32_t sampling_rate_ = -1; |
| | | if(!audio.LoadWav(sz_filename, &sampling_rate_)) |
| | | return nullptr; |
| | | }else if(funasr::is_target_file(sz_filename, "pcm")){ |
| | | if (!audio.LoadPcmwav(sz_filename, &sampling_rate)) |
| | | return nullptr; |
| | | }else{ |
| | | if (!audio.FfmpegLoad(sz_filename)) |
| | | return nullptr; |
| | | } |
| | | }catch (std::exception const &e) |
| | | { |
| | | LOG(ERROR)<<e.what(); |
| | | return nullptr; |
| | | } |
| | | |
| | | funasr::FUNASR_RECOG_RESULT* p_result = new funasr::FUNASR_RECOG_RESULT; |
| | | p_result->snippet_time = audio.GetTimeLen(); |
| | | if(p_result->snippet_time == 0){ |
| | |
| | | while (audio.Fetch(buff, len, flag, start_time) > 0) { |
| | | string msg = (offline_stream->asr_handle)->Forward(buff, len, true, hw_emb); |
| | | std::vector<std::string> msg_vec = funasr::split(msg, '|'); |
| | | if(msg_vec.size()==0){ |
| | | continue; |
| | | } |
| | | p_result->msg += msg_vec[0]; |
| | | //timestamp |
| | | if(msg_vec.size() > 1){ |
| | |
| | | // if (!audio->FfmpegLoad(sz_buf, n_len)) |
| | | // return nullptr; |
| | | LOG(ERROR) <<"Wrong wav_format: " << wav_format ; |
| | | exit(-1); |
| | | return nullptr; |
| | | } |
| | | |
| | | funasr::FUNASR_RECOG_RESULT* p_result = new funasr::FUNASR_RECOG_RESULT; |