Reputation: 521
Question Statement: I want to start recording when there is some Voice/Noise in vicinity of Phones MIC and stop when user stops speaking. Just Like Talking Tom etc.
Is there any third party library or some native code to do this?
Thanks
Upvotes: 2
Views: 3150
Reputation: 521
There are some things in this code to change IF YOU WANT TO HAVE IT RUNNING continuously like Talking Tom etc.
You need to delete the breake;
statement from while(true)
loop.
Stop audioRecorder.stop();
, then save audio data to file and play it (if you want).
Clear out the previous buffers and indexes after saving data to a file to insure that, this data will not be used again. i.e
recording = false;
tempIndex = 0;
audioBuffer = null;
totalByteBuffer = null;
audioBuffer = new byte[bufferSizeInBytes];
totalByteBuffer = new byte[60 * 44100 * 2];
totalReadBytes = 0;
Start RecorderaudioRecorder.startRecording();
This will insure that Recorder will not record the audio being Played.
Delete the previous created file after playing it.
Hope This will help someone in future.
Upvotes: 1