mirror of
https://github.com/modelscope/FunASR
synced 2025-09-15 14:48:36 +08:00
adapted pcm to 8k online
This commit is contained in:
parent
de87e1d180
commit
51f7b76660
@ -112,7 +112,7 @@ int main(int argc, char *argv[])
|
||||
auto& wav_file = wav_list[i];
|
||||
auto& wav_id = wav_ids[i];
|
||||
|
||||
int32_t sampling_rate_ = -1;
|
||||
int32_t sampling_rate_ = audio_fs.getValue();
|
||||
funasr::Audio audio(1);
|
||||
if(is_target_file(wav_file.c_str(), "wav")){
|
||||
if(!audio.LoadWav2Char(wav_file.c_str(), &sampling_rate_)){
|
||||
@ -145,7 +145,7 @@ int main(int argc, char *argv[])
|
||||
is_final = false;
|
||||
}
|
||||
gettimeofday(&start, NULL);
|
||||
FUNASR_RESULT result = FunASRInferBuffer(online_handle, speech_buff+sample_offset, step, RASR_NONE, NULL, is_final, audio_fs.getValue());
|
||||
FUNASR_RESULT result = FunASRInferBuffer(online_handle, speech_buff+sample_offset, step, RASR_NONE, NULL, is_final, sampling_rate_);
|
||||
gettimeofday(&end, NULL);
|
||||
seconds = (end.tv_sec - start.tv_sec);
|
||||
taking_micros += ((seconds * 1000000) + end.tv_usec) - (start.tv_usec);
|
||||
|
||||
@ -52,7 +52,7 @@ void runReg(FUNASR_HANDLE asr_handle, vector<string> wav_list, vector<string> wa
|
||||
// warm up
|
||||
for (size_t i = 0; i < 10; i++)
|
||||
{
|
||||
int32_t sampling_rate_ = -1;
|
||||
int32_t sampling_rate_ = audio_fs;
|
||||
funasr::Audio audio(1);
|
||||
if(is_target_file(wav_list[0].c_str(), "wav")){
|
||||
if(!audio.LoadWav2Char(wav_list[0].c_str(), &sampling_rate_)){
|
||||
@ -84,7 +84,7 @@ void runReg(FUNASR_HANDLE asr_handle, vector<string> wav_list, vector<string> wa
|
||||
} else {
|
||||
is_final = false;
|
||||
}
|
||||
FUNASR_RESULT result = FunASRInferBuffer(online_handle, speech_buff+sample_offset, step, RASR_NONE, NULL, is_final, audio_fs);
|
||||
FUNASR_RESULT result = FunASRInferBuffer(online_handle, speech_buff+sample_offset, step, RASR_NONE, NULL, is_final, sampling_rate_);
|
||||
if (result)
|
||||
{
|
||||
FunASRFreeResult(result);
|
||||
@ -98,7 +98,7 @@ void runReg(FUNASR_HANDLE asr_handle, vector<string> wav_list, vector<string> wa
|
||||
if (i >= wav_list.size()) {
|
||||
break;
|
||||
}
|
||||
int32_t sampling_rate_ = -1;
|
||||
int32_t sampling_rate_ = audio_fs;
|
||||
funasr::Audio audio(1);
|
||||
if(is_target_file(wav_list[i].c_str(), "wav")){
|
||||
if(!audio.LoadWav2Char(wav_list[i].c_str(), &sampling_rate_)){
|
||||
@ -131,7 +131,7 @@ void runReg(FUNASR_HANDLE asr_handle, vector<string> wav_list, vector<string> wa
|
||||
is_final = false;
|
||||
}
|
||||
gettimeofday(&start, NULL);
|
||||
FUNASR_RESULT result = FunASRInferBuffer(online_handle, speech_buff+sample_offset, step, RASR_NONE, NULL, is_final, audio_fs);
|
||||
FUNASR_RESULT result = FunASRInferBuffer(online_handle, speech_buff+sample_offset, step, RASR_NONE, NULL, is_final, sampling_rate_);
|
||||
gettimeofday(&end, NULL);
|
||||
seconds = (end.tv_sec - start.tv_sec);
|
||||
long taking_micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec);
|
||||
|
||||
@ -141,10 +141,9 @@ int main(int argc, char *argv[])
|
||||
auto& wav_file = wav_list[i];
|
||||
auto& wav_id = wav_ids[i];
|
||||
|
||||
int32_t sampling_rate_ = -1;
|
||||
int32_t sampling_rate_ = audio_fs.getValue();
|
||||
funasr::Audio audio(1);
|
||||
if(is_target_file(wav_file.c_str(), "wav")){
|
||||
int32_t sampling_rate_ = -1;
|
||||
if(!audio.LoadWav2Char(wav_file.c_str(), &sampling_rate_)){
|
||||
LOG(ERROR)<<"Failed to load "<< wav_file;
|
||||
exit(-1);
|
||||
@ -172,7 +171,7 @@ int main(int argc, char *argv[])
|
||||
is_final = false;
|
||||
}
|
||||
gettimeofday(&start, NULL);
|
||||
FUNASR_RESULT result = FsmnVadInferBuffer(online_hanlde, speech_buff+sample_offset, step, NULL, is_final, audio_fs.getValue());
|
||||
FUNASR_RESULT result = FsmnVadInferBuffer(online_hanlde, speech_buff+sample_offset, step, NULL, is_final, sampling_rate_);
|
||||
gettimeofday(&end, NULL);
|
||||
seconds = (end.tv_sec - start.tv_sec);
|
||||
taking_micros += ((seconds * 1000000) + end.tv_usec) - (start.tv_usec);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user