gpt4 book ai didi

Android 语音通话录音问题....无法与 audiosource.voicecall 一起正常工作

转载 作者:行者123 更新时间:2023-11-29 01:58:49 24 4
gpt4 key购买 nike

我想在 android 中制作通话记录器。我有以下代码,当我使用MediaRecorder.AudioSource.VOICE_DOWNLINK | MediaRecorder.AudioSource.VOICE_UPLINK 正在录制通话但播放时无法理解。如果对 AudioSouce.MIC
使用相同的代码 然后记录文件是可以理解的。这是我的代码

package com.example.callrecoder;

import java.io.File;
import java.io.IOException;

import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final Button record_call = (Button)this.findViewById(R.id.record);
final Button stop_recorder = (Button)this.findViewById(R.id.stop);
final MediaRecorder _recorder = new MediaRecorder();
record_call.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
//MediaRecorder _recorder = new MediaRecorder();



try {
String state = android.os.Environment.getExternalStorageState();
/* if (!state.equals(android.os.Environment.MEDIA_MOUNTED)) {
throw new IOException("SD Card is not mounted. It is " + state
+ ".");
}

// make sure the directory we plan to store the recording in exists
File directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath()
+ "/sam.wav").getParentFile();
if (!directory.exists() && !directory.mkdirs()) {
throw new IOException("Path to file could not be created.");
}*/


//_recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL );
_recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_DOWNLINK | MediaRecorder.AudioSource.VOICE_UPLINK );
_recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
_recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
//_recorder.setOutputFile(Environment.getExternalStorageDirectory().getAbsolutePath()
// + "/test.wav");
_recorder.setOutputFile("/sdcard/sample.3GPP");
_recorder.prepare();
_recorder.start();

} catch (Exception e) {
e.printStackTrace();
}
}


});
stop_recorder.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
try
{
_recorder.stop();
_recorder.reset();
_recorder.release();
}
catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}


//_recorder = null;

}
});
}

public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub

}




}

我想使用 AudioSource.downlink 和 uplink 录制通话。请帮我解决这个问题。我正在 Samsang Galaxay Gio 手机上进行测试。

最佳答案

代替 VOICE_CALL 使用 VOICE_RECOGNITION,,,

callRecorder = new MediaRecorder();                                         
callRecorder.reset();
callRecorder.setAudioSamplingRate(8000);
callRecorder.setAudioEncodingBitRate(12200);
callRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_RECOGNITION);
callRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
callRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

关于Android 语音通话录音问题....无法与 audiosource.voicecall 一起正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13758842/

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