I have spent a few weeks implementing sound acquisition and processing in android and have come up with something to begin with.
Presenting:
Shh..Silence
An application that monitors sound level of an environment and plays a 'Shhhh...' when noise levels pass a limit.
You can download it here:
Google Play and the Google Play logo are trademarks of Google LLC.
For the end user, it is a harmless application but from an engineering point of view, the internals are a window to a ton of possibilities.
The application monitors sound in the following manner :
- Acquire Microphone
- Configure
- Sample Rate
- Mono/Stereo
- Encoding format
- Buffer size
- Calculate average over the buffer size
- Compare obtained value with threshold
- Trigger when above threshold
The pipeline is simple when dealing only with the average. Here's a code snippet for step 3:
private void readAudioBuffer() {
try {
short[] buffer = new short[bufferSize];
int bufferReadResult = 1;
if (audio != null) {
bufferReadResult = audio.read(buffer, 0, bufferSize); //Audio Samples
double sumLevel = 0;
for (int i = 0; i < bufferReadResult; i++) {
sumLevel += buffer[i];
}
lastLevel = Math.abs((sumLevel / bufferReadResult));
}
} catch (Exception e) {
e.printStackTrace();
}
}
The most intriguing part of it is at bufferReadResult. It contains a sequence of numbers that depict the sound received by the microphone. Following this, it is a matter of requirement what needs to be done next. On extracting audio features like Mel Coefficients, MFCC etc, the application can be stretched to domains of Audio Classification, Speech Recognition, User Identification and Keyword Detection.
Implementing ML/DL on android has become easier than ever using TensorFlow with a light framework. The next step is to develop an application that uses TensorFlow for purpose of classifying sounds.
The Optimist sees the potential in a seed
Kudos.
0 comments:
Post a Comment