Answer to Question #138406 in Java | JSP | JSF for samantha

Question #138406
The following pseudo-code represents the algorithm of the pitch changing detector of the Voice Interaction technique shown in the lecture video.

Answer the correct combination of code fragments to fill in the blanks.
1
Expert's answer
2020-10-14T12:40:59-0400
AudioDispatcher dispatcher;

dispatcher= AudioDispatcher.fromDefaultMicrophone(1024, 0);

dispatcher.addAudioProcessor(new AudioProcessor() {

 float threshold = -70;

//dB @Override

public boolean process(AudioEvent audioEvent) {

 float[] buffer = audioEvent.getFloatBuffer();

double level = soundPressureLevel(buffer);

if(level > threshold){

System.out.println("Sound detected.");

} return true;

}

@Override

 public void processingFinished() {}

/**

* Returns the dBSPL for a buffer.

*/

private double soundPressureLevel(final float[] buffer) {

double power = 0.0D; for (float element : buffer) {

 power += element * element; }

double value = Math.pow(power, 0.5)/ buffer.length;
 return 20.0 * Math.log10(value); 
  } 
});

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS