Mean Vector in Mean vectors
How can I find probability of a mean vector in mean vectors ? Below is my codes. I am using comirva package.
public class SpeechRecognition {
private PointList list;
public Vector<double[]> getMFCC(File file) {
AudioInputStream audioInputStream;
AudioPreProcessor preProcessor;
MFCC ccm;
Vector<double[]> features = new Vector<double[]>();
try {
audioInputStream = AudioSystem.getAudioInputStream(file);
preProcessor = new AudioPreProcessor(audioInputStream, audioInputStream.getFormat().getSampleRate());
ccm = new MFCC(preProcessor.getSampleRate());
features = ccm.process(preProcessor);
return features;
} catch (IOException e) {
} catch (UnsupportedAudioFileException e) {
}
return features;
}
public double[] getSingleFileFeatures(Vector<double[]> doubles) {
double[] result = new double[600];
int k = 0;
for (int i = 0; i < doubles.size(); i++) {
for (int j = 0; j < doubles.get(0).length; j++) {
result[k] = doubles.get(i)[j];
k++;
}
}
return result;
}
pu开发者_开发知识库blic GaussianComponent getComponent(File file) {
GaussianComponent component;
double[] result = getSingleFileFeatures(getMFCC(file));
PointList list = new PointList(result.length);
list.add(result);
KMeansClustering clustering = new KMeansClustering(list.size(), list);
clustering.run();
System.out.println(clustering.getClusterWeight(0));
component = new GaussianComponent(clustering.getClusterWeight(0), clustering.getMean(0), clustering.getFullCovarianceMatrix(0));
return component;
}
public GaussianMixture getGaussianMixtures(File[] files) {
GaussianMixture mixture;
getPointList(files);
System.out.println();
KMeansClustering clustering = new KMeansClustering(list.size(), list);
clustering.run();
for(int i=0; i<files.length; i++){
System.out.println(clustering.getClusterWeight(i));
}
mixture = new GaussianMixture(clustering.getClusterWeights(), clustering.getMeans(), clustering.getFullCovariances());
return mixture;
}
public Matrix getMFCCAsMatrix(File file){
return new Matrix(getMFCC(file).toArray(new double[0][]));
}
public PointList pointList(File file){
double[] result = getSingleFileFeatures(getMFCC(file));
PointList list = new PointList(600);
list.add(result);
return list;
}
public PointList getPointList(File[] files){
list = new PointList(600);
for(int i=0; i<files.length; i++){
double[] result = getSingleFileFeatures(getMFCC(files[i]));
list.add(result);
}
System.out.println(list.size());
return list;
}
public Matrix getPointListMatrix(File file){
return pointList(file).get(0);
}
}
精彩评论