00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #if !defined(ALIZE_AccumulateJFAStat_h)
00056 #define ALIZE_AccumulateJFAStat_h
00057
00058 #if defined(_WIN32)
00059 #if defined(LIA_SPKTOOLS_EXPORTS)
00060 #define LIA_SPKTOOLS_API __declspec(dllexport)
00061 #else
00062 #define LIA_SPKTOOLS_API __declspec(dllimport)
00063 #endif
00064 #else
00065 #define LIA_SPKTOOLS_API
00066 #endif
00067
00068 #include <alize.h>
00069 #include "liatools.h"
00070
00077
00078 class LIA_SPKTOOLS_API JFATranslate{
00079 XLine _id;
00080 ULongVector _locidx;
00081 ULongVector _sessionidx;
00082
00083
00084
00086 long _idxOfID(const String &file) {
00087 _id.rewind();
00088 for(unsigned long i=0;i<_id.getElementCount();i++)
00089 if(file==_id.getElement(i)) return i;
00090 return -1;
00091 }
00092
00093
00094 public:
00095 JFATranslate() {};
00096
00099 JFATranslate(XList &fileList) {
00100 fileList.rewind(); XLine *pline;String *pFile;
00101 unsigned long sent=0;
00102 unsigned long loc=0;
00103 while((pline=fileList.getLine())!=NULL) {
00104 while((pFile=pline->getElement())!=NULL) {
00105 _id.addElement(*pFile);
00106 _locidx.addValue(loc);
00107 _sessionidx.addValue(sent);
00108 sent++;
00109 }
00110 loc++;
00111 }
00112 };
00113 ~JFATranslate() {};
00114
00119 unsigned long locNb(const String &file) {
00120 unsigned long idx=_idxOfID(file);
00121 if (idx==-1) throw Exception("File not known",__FILE__,__LINE__);
00122 return _locidx[idx];
00123 }
00124
00129 unsigned long firstSession(unsigned long spk) {
00130 unsigned long i;
00131 for(i=0;;i++) if (_locidx[i]==spk) break;
00132 return (_sessionidx[i]);
00133 }
00134
00140 unsigned long numSession(unsigned long spk, unsigned long session) {
00141 unsigned long i, cnt;
00142 if(spk==0) return(session);
00143 for(i=session-1,cnt=0;;i--,cnt++) if (_locidx[i]!=spk) break;
00144 return (cnt);
00145 }
00146
00151 unsigned long locNb(unsigned long idx) {
00152 return _locidx[idx];
00153 }
00154
00159 unsigned long sessionNb(const String &file) {
00160 long idx=_idxOfID(file);
00161 if (idx==-1) throw Exception("File not known",__FILE__,__LINE__);
00162 return _sessionidx[idx];
00163 }
00164 };
00165
00173
00174 class LIA_SPKTOOLS_API JFAAcc{
00175
00176 private :
00177
00178 MixtureServer _ms;
00179 StatServer _ss;
00180
00181 XList _fileList;
00182 unsigned long _vectSize;
00183 unsigned long _n_distrib;
00184 unsigned long _svSize;
00185 unsigned long _rankEC;
00186 unsigned long _rankEV;
00187 unsigned long _n_speakers;
00188 unsigned long _n_sessions;
00189
00191 RealVector<double> _ubm_means;
00192 RealVector<double> _ubm_invvar;
00193
00195 Matrix<double> _matN;
00196 Matrix<double> _N_h;
00197 Matrix<double> _F_X;
00198 Matrix<double> _F_X_h;
00199
00201 Matrix<double> _cN;
00202 Matrix<double> _cN_h;
00203 Matrix<double> _cF_X;
00204 Matrix<double> _cF_X_h;
00205
00207 RealVector<double> _D;
00208 Matrix<double> _V;
00209 Matrix<double> _matU;
00210 Matrix<double> _VU;
00211
00212 Matrix<double> _Z;
00213 Matrix<double> _Y;
00214 Matrix<double> _matX;
00215 Matrix<double> _YX;
00216
00218 RefVector<DoubleSquareMatrix> _vEvT;
00220 RefVector<DoubleSquareMatrix> _uEuT;
00222 RefVector<DoubleSquareMatrix> _vuEvuT;
00223
00225 RefVector<DoubleSquareMatrix> _l_spk_inv;
00226 RefVector<DoubleSquareMatrix> _l_sess_inv;
00227 RefVector<DoubleSquareMatrix> _l_yx_inv;
00228
00230 RefVector<DoubleSquareMatrix> _Aev;
00231 Matrix<double> _Cev;
00232 RefVector<DoubleSquareMatrix> _Aec;
00233 Matrix<double> _Cec;
00234
00239 void _init(XList & list,Config & config);
00240
00241
00242 public :
00243
00245 JFATranslate _ndxTable;
00246
00247 JFAAcc(String &,Config &);
00248 JFAAcc(XList &,Config & );
00249 virtual ~JFAAcc();
00250 virtual String getClassName() const;
00251
00255 void computeAndAccumulateJFAStat(Config& config);
00256
00260 void computeAndAccumulateJFAStatUnThreaded(Config& config);
00261
00265 #ifdef THREAD
00266
00267
00268
00269 void computeAndAccumulateJFAStatThreaded(Config&);
00270 #endif
00271
00276 void computeAndAccumulateJFAStat(FeatureServer & fs,Config & config);
00277
00283 void computeAndAccumulateJFAStat(SegCluster & sc,FeatureServer & fs,Config & config);
00284
00287 void resetAcc();
00288
00291 void resetTmpAcc();
00292
00297 void loadEV(const String& file, Config& config);
00298
00302 void loadEV(Matrix<double> & mat, Config& config);
00303
00308 void loadEC(const String&, Config&);
00309
00313 void loadEC(Matrix<double> & mat, Config& config);
00314
00319 void loadD(const String& file, Config& config);
00320
00324 void loadD(DoubleVector & vec);
00325
00329 void loadN(Config&);
00330
00334 void loadN_h(Config&);
00335
00339 void loadF_X(Config&);
00340
00344 void loadF_X_h(Config&);
00345
00348 void initEV(Config&);
00349
00352 void initEC(Config&);
00353
00354
00356 void initD(Config&);
00357
00360 void initVU();
00361
00365 void saveV(const String& file, Config& config);
00366
00370 void saveU(const String& file, Config& config);
00371
00375 void saveD(const String& file, Config& config);
00376
00380 void estimateVEVT(Config & config);
00381
00384 void estimateVEVTUnThreaded();
00385
00389 void estimateUEUT(Config & config);
00390
00393 void estimateUEUTUnThreaded();
00394
00398 void estimateVUEVUT(Config &);
00399
00402 void estimateVUEVUTUnThreaded();
00403
00404 #ifdef THREAD
00405
00406
00407
00408 void estimateVEVTThreaded(unsigned long threads);
00409
00413 void estimateUEUTThreaded(unsigned long threads);
00414
00418 void estimateVUEVUTThreaded(unsigned long threads);
00419 #endif
00420
00425 void getVY(DoubleVector & vy, String & file);
00426
00431 void getVY(DoubleVector &file, unsigned long spk);
00432
00437 void getVUYX(DoubleVector &vuyx, String & file);
00438
00443 void getVUYX(DoubleVector &vuyx, unsigned long spk);
00444
00449 void getDZ(DoubleVector & dz, unsigned long spk);
00450
00455 void getUX(DoubleVector & ux, unsigned long session);
00456
00461 void getUX(DoubleVector &ux, String& file);
00462
00467 void getVYplusDZ(DoubleVector &vyplusdz, String &file);
00468
00473 void getVYplusDZ(DoubleVector &, unsigned long spk);
00474
00479 void getMplusDZ(DoubleVector &MplusDZ, String& file);
00480
00485 void getMplusDZ(DoubleVector &MplusDZ, unsigned long spk);
00486
00491 void getMplusVY(DoubleVector &MplusVY, String& file);
00492
00497 void getMplusVY(DoubleVector &MplusVY, unsigned long spk);
00498
00503 void getMplusUX(DoubleVector &MplusUX, String& file);
00504
00509 void getMplusUX(DoubleVector &MplusUX, unsigned long session);
00510
00515 void getMplusVYplusDZ(DoubleVector &, String& file);
00516
00521 void getMplusVYplusDZ(DoubleVector &, unsigned long spk);
00522
00527 void getMplusVUYX(DoubleVector &MplusVUYX, String& file);
00528
00533 void getMplusVUYX(DoubleVector &MplusVUYX, unsigned long spk);
00534
00538 void estimateAndInverseL_EV(Config&);
00539
00542 void estimateAndInverseLUnThreaded_EV();
00543
00547 void estimateAndInverseL_EC(Config&);
00548
00551 void estimateAndInverseLUnThreaded_EC();
00552
00556 void estimateAndInverseL_VU(Config&);
00557
00560 void estimateAndInverseLUnThreaded_VU();
00561
00565 void estimateYandV(Config &);
00566
00569 void estimateYandVUnThreaded();
00570
00571 #ifdef THREAD
00572
00573
00574
00575 void estimateAndInverseLThreaded_EV(unsigned long threads);
00576
00580 void estimateAndInverseLThreaded_EC(unsigned long threads);
00581
00585 void estimateAndInverseLThreaded_VU(unsigned long threads);
00586
00590 void estimateYandVThreaded(unsigned long threads);
00591 #endif
00592
00596 void estimateY(Config &);
00597
00600 void estimateYUnThreaded();
00601
00605 void estimateXandU(Config &);
00606
00609 void estimateXandUUnThreaded();
00610
00614 void estimateX(Config &);
00615
00618 void estimateXUnThreaded();
00619
00620 #ifdef THREAD
00621
00622
00623
00624 void estimateXandUThreaded(unsigned long threads);
00625
00629 void estimateXThreaded(unsigned long threads);
00630
00634 void estimateYThreaded(unsigned long threads);
00635 #endif
00636
00639 void estimateU();
00640
00643 void estimateZandD();
00644
00647 void estimateYX();
00648
00651 void estimateZ();
00652
00656 void estimateZMAP(unsigned long tau);
00657
00660 void updateVestimate();
00661
00664 void updateUestimate();
00665
00668 XList& getXList();
00669
00672 unsigned long getNSpeakers();
00673
00676 unsigned long getNSessions();
00677
00680 unsigned long getNDistrib();
00681
00684 unsigned long getVectSize();
00685
00688 unsigned long getSvSize();
00689
00692 unsigned long getRankEV();
00693
00696 unsigned long getRankEC();
00697
00700 DoubleVector& getUbmMeans();
00701
00704 DoubleVector& getUbmInvVar();
00705
00708 Matrix<double> getV();
00709
00712 Matrix<double> getU();
00713
00716 DoubleVector getD();
00717
00718
00720 Matrix<double> getVU();
00721
00724 Matrix<double> getY();
00725
00728 Matrix<double> getX();
00729
00732 Matrix<double> getZ();
00733
00736 Matrix<double> getYX();
00737
00740 void splitYX();
00741
00744 void storeAccs();
00745
00748 void restoreAccs();
00749
00753 void substractMplusDZ(Config & config);
00754
00757 void substractMplusDZUnThreaded();
00758
00762 void substractMplusVY(Config &);
00763
00766 void substractMplusVYUnThreaded();
00767
00768
00772 void substractUX(Config & config);
00773
00776 void substractUXUnThreaded();
00777
00781 void substractMplusUX();
00782
00785 void substractMplusVUYX();
00786
00790 void substractMplusVYplusDZ(Config &);
00791
00794 void substractMplusVYplusDZUnThreaded();
00795
00798 void substractMplusDZByChannel();
00799
00800 #ifdef THREAD
00801
00802
00803
00804 void substractMplusDZThreaded(unsigned long threads);
00805
00809 void substractUXThreaded(unsigned long threads);
00810
00814 void substractMplusVYplusDZThreaded(unsigned long threads);
00815
00819 void substractMplusVYThreaded(unsigned long threads);
00820 #endif
00821
00826 void getSpeakerModel(MixtureGD &mixture, String& file);
00827
00833 void normalizeFeatures(alize::SegCluster& segCluster, alize::FeatureServer& featureServer, alize::Config& config);
00834
00839 void substractUXfromFeatures(FeatureServer &fs,Config &config);
00840
00844 void saveAccs(Config &config);
00845
00851 double getLLK(SegCluster &selectedSegments,MixtureGD &model,FeatureServer&fs,Config & config);
00852
00858 void verifyEMLK(Config& config);
00859
00862 Matrix <double>& getN();
00863
00866 Matrix <double>& getN_h();
00867
00870 Matrix <double>& getF_X();
00871
00874 Matrix <double>& getF_X_h();
00875
00876 };
00877 #endif