Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用VAD时,再进行录音则采集到的录音数据会变快 (AUD-5014) #1108

Open
meibao-real opened this issue Nov 12, 2023 · 1 comment

Comments

@meibao-real
Copy link

你好,我在进行一个功能实现,使用ESP-ADF框架,具体功能是需要检测到声音时进行录音采集,静音时不进行处理,当前使用到了VAD检测,主要实现方法如下:

......
#define VAD_SAMPLE_RATE_HZ 16000
#define VAD_FRAME_LENGTH_MS 30
#define VAD_BUFFER_LENGTH (VAD_FRAME_LENGTH_MS * VAD_SAMPLE_RATE_HZ / 1000)
......
vad_inst = vad_create(VAD_MODE_4); //级别过滤
int sample_buffer_size = VAD_BUFFER_LENGTH * sizeof(short);           //960 byte
int16_t *vad_buff = (int16_t *)audio_malloc(sample_buffer_size);
while (1) {
   raw_stream_read(raw_read, (char *)vad_buff, sample_buffer_size);
   vad_state_t vad_state = vad_process(vad_inst, vad_buff, VAD_SAMPLE_RATE_HZ, VAD_FRAME_LENGTH_MS); 
   if (vad_state == VAD_SPEECH)
   {
      if (http_state_value)
            {
                i2s_stream_set_clk(i2s_stream_reader, VAD_SAMPLE_RATE_HZ, 16, 1); // 修改录音采样率16000与VAD保持一致
                audio_pipeline_stop(http_pipeline);
                audio_pipeline_wait_for_stop(http_pipeline);
                audio_pipeline_reset_ringbuffer(http_pipeline);
                audio_pipeline_reset_elements(http_pipeline);
                audio_pipeline_terminate(http_pipeline);
                audio_element_set_uri(http_stream_writer, "http://xxxxx");
                audio_pipeline_run(http_pipeline);
                http_state_value = 0;
            }
   }
}

实测下来服务器接收到的录音在播放的时候语速会变的非常快,日志没有报出错误,录音数据也正常上传,但是采集到的录音语速很快,请问这样问题解决方向应该从哪方便入手?

@github-actions github-actions bot changed the title 使用VAD时,再进行录音则采集到的录音数据会变快 使用VAD时,再进行录音则采集到的录音数据会变快 (AUD-5014) Nov 12, 2023
@jason-mao
Copy link
Collaborator

@meibao-real 这个问题可能有两种原因,一是传数据的时候不及时,被迫丢了些数据,这个听起来会变快,声音不完整;二是采样率配置不正常,可能采集是16k,而播放是32k。你可以先将录音数据存储到sdacrd中,来看是哪种原因。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants