00001
00002
00003
00004
00005
00006
00007 using namespace std;
00008
00009 #include <iostream>
00010 #include<cstring>
00011 #include<string>
00012 #include<cstdlib>
00013
00014 #ifndef CLUSTERMANAGERINCLUDED
00015 #include "clustermanager.cpp"
00016 #endif
00017
00018 #ifndef FRAMEINCLUDED
00019 #include "frame.cpp"
00020 #endif
00021
00022 #ifndef PARAMETERSINCLUDED
00023 #include "parameters.cpp"
00024 #endif
00025
00026 #define REPOSITORYGENERATORINCLUDED
00027
00028 class repositorygenerator {
00029
00030 private:
00031
00032 public:
00033
00034 int generate(string filename, string emailid)
00035 {
00036
00037 char* frmdata;
00038 unsigned long int frsize;
00039 wavefile* trainingfile=new wavefile(filename);
00040 cout<<"Input OK"<<endl;
00041 clustermanager clustermgr;
00042 int gmstatus;
00043 vector<double> mfcc;
00044 do
00045 {
00046 mfcc=trainingfile->getMFCC(&gmstatus);
00047 if(gmstatus==FAILURE)
00048 break;
00049 clustermgr.fmtbl.addFrame(mfcc);
00050 }while(1);
00051 cout<<"MFCC table created"<<endl;
00052 string framename;
00053 clustermgr.start();
00054 cout<<"Clustering done"<<endl;
00055 vector<unsigned long int> indices=clustermgr.getIndices();
00056 cout<<"Identified centroids"<<endl;
00057 vector<vector<double> > cluster_centers=clustermgr.getcentroids();
00058 repositorymanager repmgr(emailid,CREATE);
00059 for(unsigned int i=0;i<k;i++)
00060 {
00061 repmgr.addMFCC(cluster_centers[i]);
00062 framename=repmgr.makeNewFileName(i);
00063 trainingfile->getFrame(i,framename);
00064 }
00065 cout<<"Repository generated"<<endl;
00066 delete trainingfile;
00067 return 0;
00068 }
00069
00070 };