gpt4 book ai didi

android - setAudioEncodingBitRate 录制语音有什么好处

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:48:38 25 4
gpt4 key购买 nike

你好,我想用mediaRecorder录音。我要保存的格式是amr。

this.mediaRecorder = new MediaRecorder();
this.mediaRecorder.setAudioChannels(1);
this.mediaRecorder.setAudioSamplingRate(8000);

this.mediaRecorder.setAudioEncodingBitRate(16);
this.mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
this.mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
this.mediaRecorder.setOutputFile(this.file.getAbsolutePath());

this.mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

我用了this.mediaRecorder.setAudioEncodingBitRate(16),有些设备没问题

mediaRecorder.setAudioEncodingBitRate(12500),部分设备正常

但我删除了 mediaRecorder.setAudioEncodingBitRate 一些设备没问题

所以我的问题是如何获得默认的 AudioEncodingBitRate。我需要使用哪个参数?

最佳答案

您将 AudioEncodingBitRate 设置得太低。我犯了同样的错误:-)

这似乎可行:

MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
if (Build.VERSION.SDK_INT >= 10) {
recorder.setAudioSamplingRate(44100);
recorder.setAudioEncodingBitRate(96000);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
} else {
// older version of Android, use crappy sounding voice codec
recorder.setAudioSamplingRate(8000);
recorder.setAudioEncodingBitRate(12200);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
}
recorder.setOutputFile(file.getAbsolutePath());
try {
recorder.prepare();
} catch (IOException e) {
throw new RuntimeException(e);
}

思路来自here

加:阅读文档。 setAudioSamplingRate 的文档说明如下:

The sampling rate really depends on the format for the audio recording, as well as the capabilities of the platform. For instance, the sampling rate supported by AAC audio coding standard ranges from 8 to 96 kHz, the sampling rate supported by AMRNB is 8kHz, and the sampling rate supported by AMRWB is 16kHz.

关于android - setAudioEncodingBitRate 录制语音有什么好处,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14645850/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com