Audio

Goal Description Hints Passoff

Due Date - Mar 30

Goal

 
Use microphone on an Android device to detect when someone is talking
 CS 656
Description
 

Build an Android application that turns on the microphone whenever it is active. When it hears someone talking it displays an indication on the screen (be creative). When it hears other noises that are not talking, it indicates that nobody is talking. It also indicates that nobody is talking when there is silence.

Hints
 

The Android AudioRecord class is your best source as well as various code examples on the web.

Here is a code example

boolean stopped=false;
public void run()
{	android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
	AudioRecord recorder=null;
	short buffer[];
	try 
	{	
		int len = AudioRecord.getMinBufferSize(8000,
    			AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT);
		buffer = new short[len];
		recorder = new AudioRecord(AudioSource.MIC,
				8000, AudioFormat.CHANNEL_IN_MONO,
				AudioFormat.ENCODING_PCM_16BIT,
				len*10);
		recorder.startRecording();
		while(!stopped)
		{	int samplesRead = recorder.read(buffer,0,len);
        	
            		// your code goes here to handle the samples stored in buffer
            
		}
	} catch(Throwable x)
	{	System.err.println("Error reading audio");
		System.err.println(x);
	} 
}

 

Passoff
 

__ 6) Screen correctly indicates when talking is occuring

__ 2) Screen does not indicate talking when the device is tapped or bumped

__ 2) Screen does not indicate talking when user is whistling.