title: Remove background noise from recorded audio
body: <p>I am trying to record and play the audio at a time on android. But the recorded audio has more noise like zzzzz.... </p>
  
  <p>I want to filter the noise from the audio. My code is </p>
  
  <pre><code>private void record() {
  
      // Get the minimum buffer size required for the successful creation
      // of an AudioRecord object.
      int N = AudioRecord.getMinBufferSize(RECORDER_SAMPLERATE, RECORDER_CHANNELS, RECORDER_AUDIO_ENCODING);
      audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, 8000, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT, N * 10,
              AudioTrack.MODE_STREAM);
  
      AudioRecord audioRecorder = null;
      int bufferSizeInShorts;
      int shortsRead;
      short audioBuffer[];
  
      try {
  
          bufferSizeInShorts = (N / 2);
  
          // Initialize Audio Recorder.
          audioRecorder = new AudioRecord(MediaRecorder.AudioSource.VOICE_RECOGNITION, RECORDER_SAMPLERATE, RECORDER_CHANNELS,
                  RECORDER_AUDIO_ENCODING, N * 10);
  
          NoiseSuppressor.create(audioRecorder.getAudioSessionId());
  
  
          // Start Recording.
          audioBuffer = new short[bufferSizeInShorts];
          audioRecorder.startRecording();
          isRecording = true;
  
          audioTrack.play();
          while (isRecording) {
              shortsRead = audioRecorder.read(audioBuffer, 0, bufferSizeInShorts);
  
              if (shortsRead == AudioRecord.ERROR_BAD_VALUE || shortsRead == AudioRecord.ERROR_INVALID_OPERATION) {
                  Log.e("record()", "Error reading from microphone.");
                  isRecording = false;
                  break;
              }
  
              audioTrack.write(audioBuffer, 0, audioBuffer.length);
          }
      } finally {
          if (audioRecorder != null) {
              audioRecorder.stop();
              audioRecorder.release();
          }
  
          if (audioTrack != null) {
              audioTrack.stop();
              audioTrack.release();
          }
      }
  }
  </code></pre>
  
  <p>How can I filter the background noise, so that I can hear only voices.</p>