2

重複の可能性:
Android でオーディオ録音の品質を向上させますか?

音声を 3gp ファイルに録音したい。問題なくできますし、声も聞こえます。しかし、私が聞くことができる声は非常に遅く、明確ではありません。音声品質を上げるためにプログラムを作成しましたが、java.lang.RuntimeException: start failed が発生します

public void onClick(View arg0) 
        {
            root=Environment.getExternalStorageDirectory();
            audiofile=new File(root,"sound.3gp");
            if(!audiofile.exists())
            {
                Log.w(TAG, "File doesn't exists");
                try 
                {
                    audiofile.createNewFile();

                } catch (IOException e) 
                {
                    Log.w(TAG, "Unable to create audio file",e);
                }                   
            }

            recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
            recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
            recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);           
            recorder.setOutputFile(audiofile.getAbsolutePath());

            try 
            {
                recorder.setAudioSamplingRate(10);
                recorder.setAudioEncodingBitRate(20);
                recorder.prepare();

            } catch (IllegalStateException e) 
            {
                Log.w(TAG, "This is IllegalStateException");
            } catch (IOException e) 
            {
                Log.w(TAG, "This is IoException");
            }
            recorder.start();
        }

私のコードで何が間違っていますか? ありがとう。

4

2 に答える 2

1

Stackoverflow に関する私の既存の回答に従って、音質を改善するために以下のコードを提供しました。

recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setAudioEncoder(MediaRecorder.getAudioSourceMax());
recorder.setAudioEncodingBitRate(16);
recorder.setAudioSamplingRate(44100);
recorder.setOutputFile(path);
recorder.prepare();
recorder.start();
于 2012-06-11T14:08:33.680 に答える