Page 1 of 1

【求助】【IPC SDK 5.X】使用语音对讲功能,设备端解析后,杂音很大

Posted: 2023年 May 11日 19:51
by thomasyoung

在app使用语音对讲功能下发数据到硬件中去,在嵌入式设备里面增加一下代码将回调的pcm数据保存到文件:
#define SAVE_FILE_AUDIO 1
#ifdef SAVE_FILE_AUDIO
static FILE * audio_fp=NULL;
#endif
/* Callback of talkback mode,turn on or off the sound /
VOID TUYA_APP_Rev_Audio_CB(IN CONST MEDIA_FRAME_S p_audio_frame,
TUYA_AUDIO_SAMPLE_E audio_sample,
TUYA_AUDIO_DATABITS_E audio_databits,
TUYA_AUDIO_CHANNEL_E audio_channel)
{
printf(">>>>>rev audio cb len:%u sample:%d db:%d channel:%d\r\n", p_audio_frame->size, audio_sample, audio_databits, audio_channel);
play_audio_queue_entry(p_audio_frame->p_buf,p_audio_frame->size);
#ifdef SAVE_FILE_AUDIO
if (audio_fp==NULL){
unlink("/tmp/output.pcm");
audio_fp=fopen("/tmp/output.pcm","wb");
}
fwrite(p_audio_frame->p_buf,p_audio_frame->size,1,audio_fp);
fflush(audio_fp);
#endif
//PCM-Format 8K 16Bit MONO
//TODO
/ Developers need to implement the operations of voice playback
/

}
日志显示:
“>>>>>rev audio cb len:320 sample:16000 db:16 channel:0”