Object.h

Go to the documentation of this file.
00001 /*
00002         This file is part of ALIZE which is an open-source tool for 
00003         speaker recognition.
00004 
00005     ALIZE is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU Lesser General Public License as 
00007     published by the Free Software Foundation, either version 3 of 
00008     the License, or any later version.
00009 
00010     ALIZE is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public 
00016     License along with ALIZE.
00017     If not, see <http://www.gnu.org/licenses/>.
00018         
00019         ALIZE is a development project initiated by the ELISA consortium
00020         [alize.univ-avignon.fr/] and funded by the French Research 
00021         Ministry in the framework of the TECHNOLANGUE program 
00022         [www.technolangue.net]
00023 
00024         The ALIZE project team wants to highlight the limits of voice
00025         authentication in a forensic context.
00026         The "Person  Authentification by Voice: A Need of Caution" paper 
00027         proposes a good overview of this point (cf. "Person  
00028         Authentification by Voice: A Need of Caution", Bonastre J.F., 
00029         Bimbot F., Boe L.J., Campbell J.P., Douglas D.A., Magrin-
00030         chagnolleau I., Eurospeech 2003, Genova].
00031         The conclusion of the paper of the paper is proposed bellow:
00032         [Currently, it is not possible to completely determine whether the 
00033         similarity between two recordings is due to the speaker or to other 
00034         factors, especially when: (a) the speaker does not cooperate, (b) there 
00035         is no control over recording equipment, (c) recording conditions are not 
00036         known, (d) one does not know whether the voice was disguised and, to a 
00037         lesser extent, (e) the linguistic content of the message is not 
00038         controlled. Caution and judgment must be exercised when applying speaker 
00039         recognition techniques, whether human or automatic, to account for these 
00040         uncontrolled factors. Under more constrained or calibrated situations, 
00041         or as an aid for investigative purposes, judicious application of these 
00042         techniques may be suitable, provided they are not considered as infallible.
00043         At the present time, there is no scientific process that enables one to 
00044         uniquely characterize a person=92s voice or to identify with absolute 
00045         certainty an individual from his or her voice.]
00046         Contact Jean-Francois Bonastre for more information about the licence or
00047         the use of ALIZE
00048 
00049         Copyright (C) 2003-2010
00050         Laboratoire d'informatique d'Avignon [lia.univ-avignon.fr]
00051         ALIZE admin [alize@univ-avignon.fr]
00052         Jean-Francois Bonastre [jean-francois.bonastre@univ-avignon.fr]
00053 */
00054 
00055 #if !defined(ALIZE_Object_h)
00056 #define ALIZE_Object_h
00057 
00058 #if defined(_WIN32)
00059 #if defined(ALIZE_EXPORTS)
00060 #define ALIZE_API __declspec(dllexport)
00061 #else
00062 #define ALIZE_API __declspec(dllimport)
00063 #endif
00064 #else
00065 #define ALIZE_API
00066 #endif
00067 
00068 #include <cassert>
00069 
00070 #ifndef NULL
00071   #define NULL 0
00072 #endif
00073 
00074 namespace alize
00075 {
00076   class String;
00077 
00078   typedef double real_t;
00079   typedef double lk_t;
00080   typedef double occ_t;
00081   typedef double weight_t;
00082   typedef String FileName;
00083 
00084   enum ParamType
00085   {
00086     PARAMTYPE_INTEGER,
00087     PARAMTYPE_FLOAT,
00088     PARAMTYPE_BOOLEAN,
00089     PARAMTYPE_STRING,
00090     PARAMTYPE_UNDEFINED
00091   };
00092   enum BigEndian
00093   {
00094     BIGENDIAN_AUTO,
00095     BIGENDIAN_TRUE,
00096     BIGENDIAN_FALSE
00097   };
00098   enum BufferUsage
00099   {
00100     BUFFER_AUTO, // auto-sizes buffer
00101     BUFFER_USERDEFINE  // user defines buffer size
00102   };
00103   enum HistoricUsage
00104   {
00105     LIMITED,
00106     ALL_FEATURES
00107   };
00108   enum DeleteFlag
00109   {
00110     DELETE,
00111     DO_NOT_DELETE
00112   };
00113   enum DuplDistrib
00114   {
00115     DUPL_DISTRIB,
00116     SHARE_DISTRIB
00117   };
00118   enum DistribType
00119   {
00120     DistribType_GD,
00121     DistribType_GF
00122   };
00123   enum SPRO3DataKind    /* Definition of sample kinds     */
00124   {
00125     SPRO3DataKind_OTHER,     /* Anything else I didn't think about */
00126     SPRO3DataKind_FBANK,     /* Filter bank output         */
00127     SPRO3DataKind_FBCEPSTRA,   /* Cepstra from filter bank analysis  */
00128     SPRO3DataKind_LPCEPSTRA,   /* Cepstra from LPC analysis      */
00129     SPRO3DataKind_LPCOEFF,   /* Linear prediction coefficients   */
00130     SPRO3DataKind_PARCOR,    /* Partial correlation coefficients   */
00131     SPRO3DataKind_LAR      /* Log area ratios          */
00132   };
00133   enum MixtureFileWriterFormat
00134   {
00135     MixtureFileWriterFormat_XML,
00136     MixtureFileWriterFormat_RAW,
00137     MixtureFileWriterFormat_ETAT
00138   };
00139 
00140   enum FeatureFileReaderFormat
00141   {
00142     FeatureFileReaderFormat_RAW,
00143     FeatureFileReaderFormat_SPRO3,
00144     FeatureFileReaderFormat_SPRO4,
00145     FeatureFileReaderFormat_HTK,
00146   };
00147 
00148   enum MixtureFileReaderFormat
00149   {
00150     MixtureFileReaderFormat_AMIRAL,
00151     MixtureFileReaderFormat_RAW,
00152     MixtureFileReaderFormat_XML
00153   };
00154 
00155   enum FeatureFileWriterFormat
00156   {
00157     FeatureFileWriterFormat_SPRO3,
00158     FeatureFileWriterFormat_SPRO4,
00159     FeatureFileWriterFormat_RAW
00160   };
00161 
00162   enum SegServerFileReaderFormat
00163   {
00164     SegServerFileReaderFormat_LIUM,
00165     SegServerFileReaderFormat_XML,
00166     SegServerFileReaderFormat_RAW
00167   };
00168 
00169   enum SegServerFileWriterFormat
00170   {
00171     SegServerFileWriterFormat_XML,
00172     SegServerFileWriterFormat_LIUM,
00173     SegServerFileWriterFormat_RAW,
00174     SegServerFileWriterFormat_TRS
00175   };
00176 
00177   enum MixtureServerFileWriterFormat
00178   {
00179     MixtureServerFileWriterFormat_XML,
00180     MixtureServerFileWriterFormat_RAW
00181   };
00182 
00183   class ALIZE_API TopDistribsAction
00184   {
00185     friend class Object;
00186   public:
00187     TopDistribsAction(): _i(0) {};
00188     TopDistribsAction(const TopDistribsAction& o):_i(o._i) {};
00189     bool operator==(const TopDistribsAction& o) const { return _i == o._i; };
00190     bool operator!=(const TopDistribsAction& o) const { return _i != o._i; };
00191   private :
00192     long _i;
00193   };
00194 
00208   class ALIZE_API Object
00209   {
00210   public :
00211 
00212     Object();
00213     virtual ~Object();
00214 
00218     virtual String getClassName() const = 0;
00219 
00226     virtual String toString() const;
00227 
00230     virtual String getAddress() const;
00231 
00232     bool isSameObject(const Object&) const;
00233 
00234     static String getParamTypeName(ParamType t);
00235     static ParamType getParamType(const String& s);
00236     static String getDistribTypeName(DistribType);
00237     static DistribType getDistribType(const String& name);
00238     static FeatureFileReaderFormat getFeatureFileReaderFormat(
00239              const String& name);
00240     static SPRO3DataKind getSPro3DataKind(const String& name);
00241     static SegServerFileReaderFormat getSegServerFileReaderFormat(
00242              const String& name);
00243     static SegServerFileWriterFormat getSegServerFileWriterFormat(
00244              const String& name);
00245     static MixtureFileWriterFormat getMixtureFileWriterFormat(
00246              const String& name);
00247     static FeatureFileWriterFormat getFeatureFileWriterFormat(
00248              const String& name);
00249     static MixtureFileReaderFormat getMixtureFileReaderFormat(
00250              const String& name);
00251     static MixtureServerFileWriterFormat getMixtureServerFileWriterFormat(
00252              const String& name);
00253 
00257     static void assertIsInBounds(const char* fileName, int line,
00258                                  unsigned long i, unsigned long size);
00259 
00263     static void assertMemoryIsAllocated(const void* p, const char* fileName,
00264                                         int line);
00265 
00266     static unsigned long max(unsigned long, unsigned long);
00267 
00268 #if !defined NDEBUG
00269   public:
00272     static unsigned long getCreationCounter();
00273 
00276     static unsigned long getDestructionCounter();
00277 
00278     static unsigned long getMax();
00279 
00280   private:
00281     static unsigned long _max;
00282     static unsigned long _creationCounter;
00283     static unsigned long _destructionCounter;
00284 #endif
00285     
00286   protected:
00288     //
00289     static const real_t MIN_COV;
00290 
00292     //
00293     static const real_t EPS_LK;
00294     static const real_t PI;
00295     static const real_t PI2;
00296 
00297   private :
00298     static bool _initialized;
00299   };
00300 
00301   //-----------------------------------------------------------------------
00302 
00315 
00316   
00317   class K
00318   {
00319     friend class Seg;
00320     friend class XList;
00321     friend class Config;
00322     friend class Distrib;
00323     friend class TestSeg;
00324     friend class Mixture;
00325     friend class SegServer;
00326     friend class DistribGD;
00327     friend class DistribGF;
00328     friend class MixtureGD;
00329     friend class MixtureGF;
00330     friend class SegCluster;
00331     friend class StatServer;
00332     friend class SegAbstract;
00333     friend class MixtureStat;
00334     friend class MixtureDict;
00335     friend class TestFeature;
00336     friend class ViterbiAccum;
00337     friend class ConfigChecker;
00338     friend class TestSegServer;
00339     friend class TestDistribGD;
00340     friend class TestDistribGF;
00341     friend class TestMixtureGD;
00342     friend class TestMixtureGF;
00343     friend class MixtureGDStat;
00344     friend class MixtureGFStat;
00345     friend class MixtureServer;
00346     friend class TestSegCluster;
00347     friend class TestMixtureDict;
00348     friend class FeatureComputer;
00349     friend class DistribRefVector;
00350     friend class TestViterbiAccum;
00351     friend class TestMixtureGDStat;
00352     friend class TestMixtureGFStat;
00353     friend class TestMixtureServer;
00354     friend class MixtureFileWriter;
00355     friend class MixtureFileReaderXml;
00356     friend class TestDistribRefVector;
00357     friend class MixtureFileReaderRaw;
00358     friend class TestMixtureFileWriter;
00359     friend class SegServerFileReaderRaw;
00360     friend class MixtureFileReaderAmiral;
00361     friend class MixtureServerFileWriter;
00362     friend class TestMixtureFileReaderRaw;
00363     friend class MixtureFileReaderAbstract;
00364     friend class FeatureMultipleFileReader;
00365     friend class MixtureServerFileReaderXml;
00366     friend class MixtureServerFileReaderRaw;
00367     friend class TestMixtureServerFileWriter;
00368     friend class FeatureFileReader;
00369     friend class FeatureFileReaderSingle;
00370     friend class FeatureInputStreamModifier;
00371     friend class FeatureServer;
00372 
00373   private :
00374     K(){}; 
00375     static const K k; 
00376   };
00377   extern ALIZE_API const TopDistribsAction DETERMINE_TOP_DISTRIBS;
00378   extern ALIZE_API const TopDistribsAction USE_TOP_DISTRIBS;
00379   extern ALIZE_API const TopDistribsAction TOP_DISTRIBS_NO_ACTION;
00380 
00381 } // end namespace alize
00382 
00383 #endif // !defined(ALIZE_Object_h)
00384