IM 录制语音格式说明

开发者自己录制语音消息,参考下面格式
发布时间: 2019-08-29 15:12

回答:

IM 录制语音格式说明

iOS 录制语音格式参考:

 1. 必须是单声道的 wav 格式音频数据;
 2. 采样率必须是 8000Hz,采样位数(精度)必须为 16 位。

 您可以参考IMKit中的录音参数:
 NSDictionary *settings = @{AVFormatIDKey: @(kAudioFormatLinearPCM),
                            AVSampleRateKey: @8000.00f,
                            AVNumberOfChannelsKey: @1,
                            AVLinearPCMBitDepthKey: @16,
                            AVLinearPCMIsNonInterleaved: @NO,
                            AVLinearPCMIsFloatKey: @NO,
                            AVLinearPCMIsBigEndianKey: @NO};

Android 录制语音格式参考:

mMediaRecorder.setAudioSamplingRate(8000);
mMediaRecorder.setAudioEncodingBitRate(7950);
mMediaRecorder.setAudioChannels(1);

mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);