SegTools.h

Go to the documentation of this file.
00001 /*
00002 This file is part of LIA_RAL which is a set of software based on ALIZE
00003 toolkit for speaker recognition. ALIZE toolkit is required to use LIA_RAL.
00004 
00005 LIA_RAL project is a development project was initiated by the computer
00006 science laboratory of Avignon / France (Laboratoire Informatique d'Avignon -
00007 LIA) [http://lia.univ-avignon.fr <http://lia.univ-avignon.fr/>]. Then it
00008 was supported by two national projects of the French Research Ministry:
00009         - TECHNOLANGUE program [http://www.technolangue.net]
00010         - MISTRAL program [http://mistral.univ-avignon.fr]
00011 
00012 LIA_RAL is free software: you can redistribute it and/or modify
00013 it under the terms of the GNU Lesser General Public License as
00014 published by the Free Software Foundation, either version 3 of
00015 the License, or any later version.
00016 
00017 LIA_RAL is distributed in the hope that it will be useful,
00018 but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00020 GNU Lesser General Public License for more details.
00021 
00022 You should have received a copy of the GNU Lesser General Public
00023 License along with LIA_RAL.
00024 If not, see [http://www.gnu.org/licenses/].
00025 
00026 The LIA team as well as the LIA_RAL project team wants to highlight the
00027 limits of voice authentication in a forensic context.
00028 The "Person Authentification by Voice: A Need of Caution" paper
00029 proposes a good overview of this point (cf. "Person
00030 Authentification by Voice: A Need of Caution", Bonastre J.F.,
00031 Bimbot F., Boe L.J., Campbell J.P., Douglas D.A., Magrin-
00032 chagnolleau I., Eurospeech 2003, Genova].
00033 The conclusion of the paper of the paper is proposed bellow:
00034 [Currently, it is not possible to completely determine whether the
00035 similarity between two recordings is due to the speaker or to other
00036 factors, especially when: (a) the speaker does not cooperate, (b) there
00037 is no control over recording equipment, (c) recording conditions are not
00038 known, (d) one does not know whether the voice was disguised and, to a
00039 lesser extent, (e) the linguistic content of the message is not
00040 controlled. Caution and judgment must be exercised when applying speaker
00041 recognition techniques, whether human or automatic, to account for these
00042 uncontrolled factors. Under more constrained or calibrated situations,
00043 or as an aid for investigative purposes, judicious application of these
00044 techniques may be suitable, provided they are not considered as infallible.
00045 At the present time, there is no scientific process that enables one to
00046 uniquely characterize a persones voice or to identify with absolute
00047 certainty an individual from his or her voice.]
00048 
00049 Copyright (C) 2004-2010
00050 Laboratoire d'informatique d'Avignon [http://lia.univ-avignon.fr]
00051 LIA_RAL admin [alize@univ-avignon.fr]
00052 Jean-Francois Bonastre [jean-francois.bonastre@univ-avignon.fr]
00053 */
00054 
00055 #if !defined(ALIZE_SegTools_h)
00056 #define ALIZE_SegTools_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 
00071 
00072 using namespace alize;
00073 using namespace std;
00074 
00075 // Display a cluster
00076 LIA_SPKTOOLS_API void showCluster(SegCluster& cluster);
00077 // return in clusterOutput the clusterOne without the data in clusterTwothe number of frame in the cluster
00078 LIA_SPKTOOLS_API unsigned long totalFrame(SegCluster& cluster);
00079 // return the last frame of a segment
00080 LIA_SPKTOOLS_API unsigned long endSeg(Seg *seg);
00081 
00082 
00083 //------------------------------------------------------------------------------------------------------------------------------
00084 // Output a cluster in a  label file
00085 // Author: JFB
00086 LIA_SPKTOOLS_API void outputLabelFile(SegCluster &selectedSeg,String FileName,Config &config);
00087 
00088 
00089 /*********************************************************
00090 * fonction d'analyse par segments d'une liste de fichiers "listSeg" 
00091 * Paramètres entrées :
00092 * pointeur vers le serveur de label "labelServer"
00093 * le nombre de modèle pour apprentissage "nbrModels"
00094 * tableau avec les labels d'apprentissage de chaque modele "labelaAnaliser"
00095 * un pointeur vers une fonction "pfunc" qui est la fonction qui represente l'action à appliquer (EM,MAP,etc...)
00096 * deux pointeurs vers void "pv1" et "pv2" utilisé par le pointeur vers la fonction 
00097 *
00098 * Auteur : Dan Istrate novembre 2004
00099 **********************************************************/
00100 LIA_SPKTOOLS_API void analiseParSegments(Config &config, XList *listSeg, LabelServer *labelServer, int nbrModels, XLine *labelaAnaliser,SegServer &segmentsServer,void (*pfunc)(int,Feature&,Config &config,void *pv1,void *pv2),void *pv1,void *pv2);
00101 
00102 
00103 
00104 //******* Create a default cluster with the label labelToAnalyse, including all the input file frames
00105 //** From N Scheffer
00106 //** Modifications JFB*/
00107 LIA_SPKTOOLS_API void createDefSeg (SegServer & ss, FeatureServer & fs,Config &config);
00108 
00109 //************************************** 
00110 // Verify the labels - if a segment is finishing after the last frame, trunc it*/
00111 LIA_SPKTOOLS_API void verifyClusterFile(SegServer& segmentsServer,FeatureServer& fs,Config& config);
00112 
00113 // From a time to a frame index, taking into account possible bugs on boundaries
00114 LIA_SPKTOOLS_API unsigned long timeToFrameIdx(real_t time,real_t frameLength);
00115 LIA_SPKTOOLS_API real_t frameIdxToTime(unsigned long idx,real_t frameLength);
00116 
00117 // Functions for reading the label files in a segment server
00118 // Load the segments of a file in one cluster
00119 LIA_SPKTOOLS_API void  loadLabelFile(SegCluster &cluster,String fileName,String path, String extension,Config &config);
00120 // the main function for loading the labels - do the job for a given file
00121 LIA_SPKTOOLS_API void loadClusterFile(String &fileName,SegServer& segmentsServer,LabelServer& labelServer,Config& config);
00122 // for a list of file
00123 LIA_SPKTOOLS_API void initializeClusters(const XLine& listFiles,SegServer& segmentsServer,LabelServer& labelServer,Config& config);
00124 // For a list of input files, stored into a XList
00125 LIA_SPKTOOLS_API void initializeClusters(const XList& listXFiles,SegServer& segmentsServer,LabelServer& labelServer,Config& config);
00126 // For a filename parameter, which could be a feature file or a feature file list with an .lst extention
00127 LIA_SPKTOOLS_API void initializeClusters(String &file,SegServer& segmentsServer,LabelServer& labelServer,Config& config);
00128 
00129 LIA_SPKTOOLS_API void initializeClusters(String &file,SegServer& segmentsServer,LabelServer& labelServer,Config& config,bool nomComplet);
00130 
00131 
00132 // A function for create and initialize a Viterbi accumulator
00133 LIA_SPKTOOLS_API ViterbiAccum& createAndInitializeViterbiAccum(StatServer &ss, hmm &cHmm);
00134 
00135 // accumulateStatViterbi() is used for computing the viterbi path
00136 // TAKE CARE: THE accumulator should be reseted before the call
00137 LIA_SPKTOOLS_API void   accumulateStatViterbi(FeatureServer &fs,ViterbiAccum &va,unsigned long beginIdx,unsigned long length,Config &config);
00138 
00139 // On a segment
00140 LIA_SPKTOOLS_API void accumulateStatViterbi(FeatureServer &fs,ViterbiAccum &va,Seg *seg,Config &config);
00141 
00142 // On a segment with PreSeg
00143 // Dan Istrate juillet 2005
00144 LIA_SPKTOOLS_API void accumulateStatViterbi(FeatureServer &fs,ViterbiAccum &va,Seg *seg,Config &config,SegServer& TransitSegServer,DoubleVector&
00145 TransitionsFort,DoubleVector& TransitionsFaible,unsigned long NbState);
00146     
00147 // Remove all the segments of a cluster
00148 LIA_SPKTOOLS_API void removeAllSeg(SegServer &segServer,SegCluster &cluster);
00149 
00150 // initialize an existing segmentation by deleting all the segments and creating an empty cluster by state/speaker
00151 LIA_SPKTOOLS_API void initializeCluster(SegServer &currentSeg,hmm& cHmm,LabelServer &labelServer);
00152 
00153 // removePartOfSeg() removes a part of a segment from a cluster
00154 LIA_SPKTOOLS_API bool removePartOfSeg(SegCluster &clusterSeg,SegServer& segServer,LabelServer &labelServer,
00155                      String segSourceName,unsigned long segStart,unsigned long segLength);
00156 
00157 LIA_SPKTOOLS_API void displayAllClusters(Config& config, SegServer& seg);
00158 
00159 LIA_SPKTOOLS_API void displayOneCluster(Config& config, SegCluster &clusterT);
00160 
00161 LIA_SPKTOOLS_API void displayAllSegments(Config& config, SegServer& seg);
00162 
00163 LIA_SPKTOOLS_API void displayAllSegmentsFromRef(Config& config, String &fileInit, unsigned long fileSize);
00164 
00165 //return the duration of all the segments in a cluster
00166 LIA_SPKTOOLS_API unsigned long computeClusterTime(SegCluster& cluster);
00167 
00168 // look for a specific label in a list
00169 LIA_SPKTOOLS_API long findLabel(XLine classToAnalyse,String labelToFind);
00170 
00171 LIA_SPKTOOLS_API void moveSegmentFromOneClusterToAnother(LabelServer& labelServer,Seg *segment, SegCluster &currentCluster, SegCluster &newCluster);
00172 
00173 /**********************************************************
00174 * longerSegment: search the longer  of a cluster (in terms of time) and return it
00175 * 
00176 * Author C. Fredouille February 2006
00177 ***********************************************************/
00178 LIA_SPKTOOLS_API Seg *longerSegment(Config& config, SegCluster& cluster);
00179 
00180 /**********************************************************
00181 * findClusterIndex: search the index of a cluster in a segment server
00182 * 
00183 * Author C. Fredouille February 2006
00184 ***********************************************************/
00185 LIA_SPKTOOLS_API unsigned long findClusterIndex(String name,SegServer& segTmp);
00186 
00187 #endif