Голос другого пользователя записывается в низком тоне - PullRequest
0 голосов
/ 29 июня 2018

Я создал один сервис записи, который записывает звук вызова, но я обнаружил, что это не только запись голоса, но и запись рядом со звуком. И кому я звоню, этот голос тоже звучит слишком медленно, и я не могу правильно записать.

Я сделал Google, перепробовал много примеров и изменил AudioEncodingBitRate и AudioSamplingRate , но все еще не нашел никаких изменений. Помогите мне, пожалуйста. Я тоже использовал RehearsalAudioRecorder . Мой код следующий

 private void startRecording(int callType) {
    Log.d(Constants.TAG, "RecordService startRecording");

    try {
        ContactDataSource dataSource = new ContactDataSource();
        recordingAllowedForNumber = dataSource.getRecordingAllowed(UserSQLiteHelper.geReadableInstance(AppContext.getInstance()), phoneNumber);
        if (recordingAllowedForNumber == false) {
            boolean isknownCall = dataSource.isknownCall(UserSQLiteHelper.geReadableInstance(AppContext.getInstance()), phoneNumber);
            recordingAllowedForNumber = !isknownCall;
        }
        if (recordingAllowedForNumber) {
            ApplicationUtils.logE("Recording is allowed for the number  : "  );
            boolean isRecordingStarted = startRecording(1, callType);
            if (isRecordingStarted == false) {
                isRecordingStarted = startRecording(2, callType);
                if (isRecordingStarted == false) {
                    isRecordingStarted = startRecording(3, callType);
                }
            }
        }
    } catch (Exception e) {
        ApplicationUtils.log("Failed to set up recorder." + e.getMessage());
    }
}



private boolean startRecording(int voiceCallType, int callType) {
    boolean isRecordingStarted = true;
    recorder = null;
    recorder = new MediaRecorder();

    try {
      switch (voiceCallType) {
            case 1:
                ApplicationUtils.logE("Deault ");
                recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
                break;
            case 2:
                ApplicationUtils.logE("MIC ");
                recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
                break;
            case 3:
                ApplicationUtils.logE("VOICECALL ");
                recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
                break;
           /* case 4:
                ApplicationUtils.logE("camcorder ");
                recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
                break;*/
        }

        ApplicationUtils.log("Chandni voiceCallType = " + voiceCallType);

        int type = UserPreferences.getVoiceExtensionType();
        ApplicationUtils.logE("Aakansha - type of call " + type);
       switch (type) {
            case UserPreferences.GP_3_EXTENSION:
                recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
                break;
            case UserPreferences.MPEG_4_EXTENSiON:
                recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
                break;
            default:
                recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

        }


        if (Build.VERSION.SDK_INT >= 10) {
            recorder.setAudioSamplingRate(44100);
            recorder.setAudioEncodingBitRate(16 * 44100);

            recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
        } else {
            // older version of Android, use crappy sounding voice codec
            recorder.setAudioSamplingRate(8000);
            recorder.setAudioEncodingBitRate(12200);

            recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        }
...