classify.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
00002 /* ====================================================================
00003  * Copyright (c) 2004 Carnegie Mellon University.  All rights
00004  * reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer. 
00012  *
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in
00015  *    the documentation and/or other materials provided with the
00016  *    distribution.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 
00019  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
00020  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00021  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
00022  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00023  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
00024  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
00025  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
00026  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00027  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00028  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029  *
00030  * ====================================================================
00031  *
00032  */
00033 /*************************************************
00034  * CMU CALO Speech Project
00035  *
00036  * Copyright (c) 2004 Carnegie Mellon University.
00037  * ALL RIGHTS RESERVED.
00038  * **********************************************
00039  * 
00040  * 17-Jun-2004  Ziad Al Bawab (ziada@cs.cmu.edu) at Carnegie Mellon University
00041  * Created
00042  * $Log$
00043  * Revision 1.1  2006/04/05  20:27:30  dhdfu
00044  * A Great Reorganzation of header files and executables
00045  * 
00046  * Revision 1.10  2006/03/03 20:02:38  arthchan2003
00047  * Removed C++ styles comment. This will make options -ansi and -std=c89 happy
00048  *
00049  * Revision 1.9  2006/02/23 04:05:21  arthchan2003
00050  * Merged from branch SPHINX3_5_2_RCI_IRII_BRANCH: fixed dox-doc.
00051  *
00052  *
00053  * Revision 1.6.4.1  2005/07/05 06:46:23  arthchan2003
00054  * 1, Merged from HEAD.  2, fixed dox-doc.
00055  *
00056  * Revision 1.8  2005/07/04 20:57:53  dhdfu
00057  * Finally remove the "temporary hack" for the endpointer, and do
00058  * everything in logs3 domain.  Should make it faster and less likely to
00059  * crash on Alphas.
00060  *
00061  * Actually it kind of duplicates the existing GMM computation functions,
00062  * but it is slightly different (see the comment in classify.c).  I don't
00063  * know the rationale for this.
00064  *
00065  * Revision 1.7  2005/07/02 04:24:45  egouvea
00066  * Changed some hardwired constants to user defined parameters in the end pointer. Tested with make test-ep.
00067  *
00068  * Revision 1.6  2005/06/21 21:06:47  arthchan2003
00069  * 1, Fixed doxygen documentation, 2, Added  keyword. 3, Change for mdef_init to use logging.
00070  *
00071  * Revision 1.3  2005/06/15 06:48:54  archan
00072  * Sphinx3 to s3.generic: 1, updated the endptr and classify 's code, 2, also added
00073  *
00074  */
00075 
00076 
00077 #include "s3types.h"
00078 #include "cont_mgau.h"
00079 
00083 #ifdef __cplusplus
00084 extern "C" {
00085 #endif 
00086 #if 0
00087 } /* Fool Emacs into not indenting things. */
00088 #endif
00089 
00090 #ifndef __FRAME_CLASSIFIER__
00091 #define __FRAME_CLASSIFIER__
00092 
00093 /******** Set the parameters of the classes *************/
00094 
00095 #define NUMCLASSES      4       /* Number of classes*/
00096 
00097 /*
00098   #define NUMMIXTURES     32    // Number of gaussian mixtures used in classification
00099 */
00100 #define DIMENSIONS      13      /* Length of the feature vector*/
00101 #define MAXFRAMES       10000   
00102 
00103 /******** Set the names of the classes *************/
00104 /* this is how the mdef file arranged the models*/
00105 
00106 #define CLASS_N         0       /* Noise*/
00107 #define CLASS_O         1       /* Owner speech*/
00108 #define CLASS_S         2       /* Secondary speech */
00109 #define CLASS_SIL       3       /* Silence */
00110 
00111 /******** Set the priors of the classes *************/
00112 
00113 #define PRIOR_N         0.1     /* N */
00114 #define PRIOR_O         0.4     /* O */
00115 #define PRIOR_S         0.1     /* S */
00116 #define PRIOR_SIL       0.4     /* SIL */
00117 
00118 /****************************************************/
00119 
00120 
00121 /******** Set the width of the voting Window *************/
00122 
00123 #define VOTEWINDOWLEN   5       /* Don't change this number as the code expects 5, or you have to 
00124                                    change the code*/
00125 
00126 #define CLASSLATENCY    2       /* Number of latency frames caused by the post processing (voting window)
00127                                  */
00128 
00129 #define POSTPROCESS     1       /* Enabling/disabling post-processing
00130                                  */
00131 /**************************************************/
00132 
00138 typedef struct{
00139     char *classname[NUMCLASSES];             
00140     int32 windowlen;                         
00141     mgau_model_t *g ;                        
00142     s3cipid_t classmap[NUMCLASSES];
00143 
00144     int32 priors[NUMCLASSES];
00145 
00146     int32 window[VOTEWINDOWLEN];              
00147     int32 postprocess;
00148     int32 classlatency;
00149 }class_t;
00150 
00151 
00152 
00153 
00154 
00156 #define SWAP_INT(x)   *(x) = ((0x000000ff & (*(x))>>24) | \
00157                                 (0x0000ff00 & (*(x))>>8) | \
00158                                 (0x00ff0000 & (*(x))<<8) | \
00159                                 (0xff000000 & (*(x))<<24))
00160 
00161 #define SWAP_FLOAT(x) SWAP_INT((int *) x)
00162 
00163 void majority_class(class_t* CLASSW, int *classcount, int frame_count);
00164 
00165 class_t * classw_initialize(char *mdeffile,  
00166                             char* meanfile,   
00167                             char *varfile,       
00168                             float64 varfloor,    
00169                             char* mixwfile,         
00170                             float64 mixwfloor,       
00171                             int32 precomp,       
00174                             char *senmgau       
00175     );
00176 
00177 void classw_free(class_t *CLASSW);
00178 
00179 int classify (float *frame,     
00180               mgau_model_t *g,  
00181               int32 priors[NUMCLASSES], 
00182               s3cipid_t *map  
00183     );
00184 
00185 int postclassify (int *window, int windowlen, int *wincap, int myclass);
00186 
00187 int vote (int *window, 
00188           int windowlen 
00189     );
00190 
00191 #endif /*__FRAME_CLASSIFIER__*/
00192 
00193 #if 0
00194 { /* Stop indent from complaining */
00195 #endif
00196 #ifdef __cplusplus
00197 }
00198 #endif 
00199 

Generated on 7 Mar 2010 by  doxygen 1.6.1