protected void computeSpectrogram() {
try {
AudioDataInputStream is = new AudioDataInputStream(audio);
dataSource.setInputStream(is, "live audio");
/* Run through all the spectra one at a time and convert * them to an log intensity value. */ArrayList<double[]>intensitiesList=newArrayList<double[]>();//intensityListdoublemaxIntensity=Double.MIN_VALUE;Dataspectrum=frontEnd.getData();//getdatawhile(!(spectruminstanceofDataEndSignal)){if(spectruminstanceofDoubleData){double[]spectrumData=((DoubleData)spectrum).getValues();//System.out.println("values................."+spectrumData);double[]intensities=newdouble[spectrumData.length];for(inti=0;i<intensities.length;i++){/* * A very small intensity is, for all intents * and purposes, the same as 0. */intensities[i]=Math.max(Math.log(spectrumData[i]),0.0);if(intensities[i]>maxIntensity){maxIntensity=intensities[i];}}intensitiesList.add(intensities);}spectrum=frontEnd.getData();}is.close();intwidth=intensitiesList.size();intheight=(intensitiesList.get(0)).length;intmaxYIndex=height-1;Dimensiond=newDimension(width,height);setMinimumSize(d);setMaximumSize(d);setPreferredSize(d);/* Create the image for displaying the data. */spectrogram=newBufferedImage(width,height,BufferedImage.TYPE_INT_RGB);/* Set scaleFactor so that the maximum value, after removing * the offset, will be 0xff. */doublescaleFactor=((0xff+offsetFactor)/maxIntensity);for(inti=0;i<width;i++){double[]intensities=intensitiesList.get(i);for(intj=maxYIndex;j>=0;j--) {/* Adjust the grey value to make a value of 0 to mean * white and a value of 0xff to mean black. */intgrey=(int)(intensities[j]*scaleFactor-offsetFactor);grey=Math.max(grey,0);grey=0xff-grey;/* Turn the grey into a pixel value. */intpixel=((grey<<16)&0xff0000)|((grey<<8)&0xff00)|(grey&0xff);spectrogram.setRGB(i,maxYIndex-j,pixel);}}ImageFilterscaleFilter=newReplicateScaleFilter((int)(zoom*width),height);scaledSpectrogram=createImage(newFilteredImageSource(spectrogram.getSource(),scaleFilter));Dimensionsz=getSize();repaint(0,0,0,sz.width-1,sz.height-1);}catch(Exceptione){e.printStackTrace();}}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
protected void computeSpectrogram() {
try {
AudioDataInputStream is = new AudioDataInputStream(audio);
dataSource.setInputStream(is, "live audio");
What your question is about?
i mean if user speaks too low or too loud ...can the recognizer be able to recognize,....what are its parameters