Home | History | Annotate | Download | only in include
      1 /*---------------------------------------------------------------------------*
      2  *  simapi.h  *
      3  *                                                                           *
      4  *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
      5  *                                                                           *
      6  *  Licensed under the Apache License, Version 2.0 (the 'License');          *
      7  *  you may not use this file except in compliance with the License.         *
      8  *                                                                           *
      9  *  You may obtain a copy of the License at                                  *
     10  *      http://www.apache.org/licenses/LICENSE-2.0                           *
     11  *                                                                           *
     12  *  Unless required by applicable law or agreed to in writing, software      *
     13  *  distributed under the License is distributed on an 'AS IS' BASIS,        *
     14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
     15  *  See the License for the specific language governing permissions and      *
     16  *  limitations under the License.                                           *
     17  *                                                                           *
     18  *---------------------------------------------------------------------------*/
     19 
     20 
     21 
     22 #ifndef _h_simapi_
     23 #define _h_simapi_
     24 
     25 #ifdef SET_RCSID
     26 static const char simapi_h[] = "$Id: simapi.h,v 1.22.4.25 2008/03/07 17:37:14 dahan Exp $";
     27 #endif
     28 
     29 #include "creccons.h"   /* CREC Public Constants    */
     30 
     31 #include "c42mul.h"
     32 #include "caexcept.h"
     33 #include "setting.h"
     34 #include "mutualob.h"
     35 #include "srec_sizes.h"
     36 #include "search_network.h"
     37 #include "srec.h"
     38 #include "srec_eosd.h"
     39 #include "srec_results.h"
     40 #include "swimodel.h"
     41 #include "ESR_Locale.h"
     42 
     43 /**
     44  ************************************************************************
     45  * SwigImageBegin       <- DO NOT MOVE THIS LINE !
     46  *
     47  * This is a CADOC Keyword section.
     48  *
     49  * If CADOC is instructed to create a SWIG I-File and this is one of the
     50  * files in the input list, everything between the 'SwigImage Begin' and
     51  * 'SwigImage End' keywords comment blocks will be copied 'as-is' to the
     52  * SWIG I-File specified on the CADOC command line.
     53  *
     54  * The purpose of the following marked section is to identify CA
     55  * structures that SWIG may need to complete the CREC API interface.
     56  *
     57  * Refer to the document "DOC\CADOC.TXT" for details for the CADOC Tool.
     58  *
     59  ************************************************************************
     60  */
     61 
     62 
     63 #ifdef __cplusplus
     64 extern "C"
     65 {
     66 #endif
     67 
     68 
     69 #ifndef SWIGBUILD
     70 
     71   typedef featdata CA_Feature;
     72 
     73 	/**
     74 	 * @todo document
     75 	 */
     76 #define NCONFPARS 6
     77 
     78 typedef struct
     79 {
     80     double scale[NCONFPARS];
     81     double offset[NCONFPARS];
     82     double weight[NCONFPARS];
     83 } Confidence_model_parameters;
     84 
     85   typedef struct
     86   {
     87 	Confidence_model_parameters one_nbest;
     88 	Confidence_model_parameters many_nbest;
     89   }
     90   CA_ConfidenceScorer;
     91 
     92 	/**
     93 	 * @todo document
     94 	 */
     95   typedef struct
     96   {
     97     int         ca_rtti;
     98     booldata    is_resultBlocked;
     99     booldata    is_configured;
    100     int         setup_count;
    101     booldata    is_running;
    102     multi_srec  *recm;                  /* contains recognition structure */
    103     srec_eos_detector_parms* eosd_parms;/* contains ep parameters */
    104   }
    105   CA_Recog;
    106 
    107 	/**
    108 	 * @todo document
    109 	 */
    110   typedef struct
    111   {
    112     int         ca_rtti;
    113     booldata    is_loaded;
    114     int         pattern_setup_count;
    115     int         use_dim;
    116     int         partial_distance_calc_dim;
    117     prdata      imelda_scale;
    118     const SWIModel    *swimodel; /* owning pointer to compact acoustic models */
    119   }
    120   CA_Acoustic;
    121 
    122 	/**
    123 	 * @todo document
    124 	 */
    125   typedef struct
    126   {
    127     int         ca_rtti;
    128     /* IMPORTANT NOTE
    129      *
    130      * This structure is used by CA_WriteSyntaxImage
    131      * in the file "ca/cod_imag.c". Certain assumptions
    132      * about the member types and order are made.
    133      * DON'T change this structure without making
    134      * appropriate changes to the above function.
    135      */
    136 
    137     booldata    has_groups;
    138     booldata    has_rules;
    139     int         setup_count;
    140     /* syntax_info* synx; */
    141     srec_context* synx;
    142   }
    143   CA_Syntax;
    144 
    145 	/**
    146 	 * @todo document
    147 	 */
    148   typedef struct
    149   {
    150     int dummy;
    151   }
    152   CA_Arbdata;
    153 
    154 	/**
    155 	 * @todo document
    156 	 */
    157   typedef struct
    158   {
    159     int         ca_rtti;
    160     /* IMPORTANT NOTE
    161      *
    162      * This structure is used by CA_WritePatternImage
    163      * in the file "ca/cod_imag.c". Certain assumptions
    164      * about the member types and order are made.
    165      * DON'T change this structure without making
    166      * appropriate changes to the above function.
    167      */
    168 
    169     booldata      is_loaded;
    170     //model_info    *setup_whole;
    171     //model_info    *setup_sub;
    172     booldata      has_cache;
    173     booldata      true_accumulates;
    174     booldata      recog_terminated;
    175     pattern_info  data;
    176   }
    177   CA_Pattern;
    178 
    179 
    180 	/**
    181 	 * @todo document
    182 	 */
    183   typedef struct
    184   {
    185     int           dim;
    186     transform_info  imelda_acc;
    187     transform_info  mllr_acc;
    188     booldata      do_mllr;
    189     booldata      do_imelda;
    190     booldata      is_loaded;
    191     booldata      is_setup;
    192   }
    193   CA_Transform;
    194 
    195 
    196 	/**
    197 	 * @todo document
    198 	 */
    199   typedef struct
    200   {
    201     int             ca_rtti;
    202     booldata        is_loaded;    /* generates VOCAB_NOT_CONFIGURED */
    203     vocab_info      voc;
    204   }
    205   CA_Vocab;
    206 
    207 	/**
    208 	 * @todo document
    209 	 */
    210   typedef struct
    211   {
    212     int           ca_rtti;
    213     short         type;
    214     unsigned long startTime;
    215     unsigned long endTime;
    216     short         wordID;
    217     long          score;
    218     char          *label;
    219   }
    220   CA_Result;
    221 
    222   /* typedef nbest_list CA_NBestList; */
    223 
    224 	/**
    225 	 * @todo document
    226 	 */
    227   typedef struct
    228   {
    229     asr_int32_t dummy[2];
    230   }
    231   CA_NBestList;
    232 
    233 	/**
    234 	 * @todo document
    235 	 */
    236   typedef struct
    237   {
    238     int         ca_rtti;
    239     booldata    is_loaded;
    240     int         dimen;
    241     int         stay_penalty;
    242     int         skip_penalty;
    243     int         whole_stay_penalty;
    244     int         whole_skip_penalty;
    245     int         dur_scale;
    246     int         frame_period;
    247     int         min_var;
    248     int         max_var;
    249     booldata    load_all;
    250     char        load_models[MAX_LABEL];
    251   }
    252   CA_AcoustInputParams;
    253 
    254 
    255 	/**
    256 	 * @todo document
    257 	 */
    258 	typedef struct
    259   {
    260     int         ca_rtti;
    261     booldata    is_loaded;
    262     ESR_BOOL        do_early;
    263     ESR_BOOL        do_partial;
    264     int         word_penalty;
    265     int         top_choices;
    266     int         reject_score;
    267     int         traceback_freq;
    268     int         viterbi_prune_thresh;  /*score-based pruning threshold - only keep paths within this delta of best cost*/
    269     int         max_hmm_tokens;       /*controls the maximum number of HMM's alive in any frame.  If number
    270          exceeded, pruning gets tightened.  So, this threshold can be used
    271          to tradeoff accuracy for computation an memory*/
    272     int         max_fsmnode_tokens;   /*controls the maximum number of FSMs alive in any frame.  If number,
    273          exceeded, pruning gets tightened.  So, this threshold can be used
    274          to tradeoff accuracy for computation an memory*/
    275     int         max_word_tokens;      /*controls the maximum number of word tokens kept in the word lattice.
    276          if number exceeded, the word lattice is pruned more tightly (less word
    277          ends per frame*/
    278     int         max_altword_tokens;      /*controls the maximum number of alternative paths to propagate, for nbest */
    279     int         num_wordends_per_frame; /*controls the size of the word lattice - the number of word ends to
    280            keep at each time frame*/
    281     int         max_fsm_nodes;        /*allocation size of a few arrays in the search - needs to be big enough
    282          to handle any grammar that the search needs to run.  Initialization fails
    283          if num exceeded*/
    284     int         max_fsm_arcs;         /*allocation size of a few arrays in the search - needs to be big enough
    285          to handle any grammar that the search needs to run.  Initialization fails
    286          if num exceeded*/
    287     int           max_searches;         /* now: 2 searches for 2 genders */
    288     int         terminal_timeout;           /* end of utterance timeout at terminal node */
    289     int         optional_terminal_timeout;  /* end of utterance timeout at optional terminal node */
    290     int         non_terminal_timeout;       /* end of utterance timeout at non terminal node */
    291     int         eou_threshold;              /* select hypotheses for end-of-utterance tests */
    292     int         stats_enabled;              /* enable frame-by-frame recognizer stats */
    293     int         max_frames;             /* max number of frames in for searching */
    294     int         max_model_states;       /* indicates largest acoustic model this search can use */
    295   }
    296   CA_RecInputParams;
    297 
    298 	/**
    299 	 * @todo document
    300 	 */
    301   typedef struct
    302   {
    303     int         ca_rtti;
    304     booldata    is_loaded;
    305     int         dimen;
    306     int         whole_dimen;
    307     int         feat_start;
    308     float       mix_score_scale;
    309     float       imelda_scale;
    310     float       uni_score_scale;
    311     float       uni_score_offset;
    312     int         forget_speech;
    313     int         forget_background;
    314     int         rel_low;
    315     int         rel_high;
    316     int         gap_period;
    317     int         click_period;
    318     int         breath_period;
    319     int         extend_annotation;
    320     int         param;
    321 #if PARTIAL_DISTANCE_APPROX
    322     int         partial_distance_dim;
    323     int         partial_distance_threshold;
    324     int         partial_distance_offset;
    325     int         global_model_means[MAX_DIMEN];
    326 #endif
    327     int         min_initial_quiet_frames;      /* num silence frames needed before input */
    328     int         min_annotation_frames;          /* minimum overall length */
    329     int         max_annotation_frames;          /* maximum overall length */
    330     int         delete_leading_segments;        /* num segments to delete. 0=no action */
    331     int         leading_segment_accept_if_not_found; /* Do not reject segmentation if not found */
    332     int         leading_segment_min_frames;     /* remove unless shorter */
    333     int         leading_segment_max_frames;     /* remove unless exceeded */
    334     int         leading_segment_min_silence_gap_frames;/* remove if good silence gap to next segment */
    335     int         beep_size;  /*X201 beep filter */
    336     int         beep_threshold;  /*X201 beep filter */
    337     int         min_segment_rel_c0; /* Any segment gets deleted whose peak c0 is < max - min_segment_rel_c0 */
    338 
    339 #if DO_SUBTRACTED_SEGMENTATION
    340     int         snr_holdoff; /* Ignore first n frames when estimating speech level for SNR measure */
    341     int         min_acceptable_snr; /* for successful segmentation */
    342 #endif
    343     int         stats_enabled;                  /* enable frame-by-frame pattern stats */
    344   }
    345   CA_PatInputParams;
    346 
    347 
    348 
    349 #endif
    350 
    351 #define IMELDA_ACC_BETWEEN      1
    352 #define IMELDA_ACC_WITHIN       2
    353 #define IMELDA_ACC_BMEAN        3
    354 #define IMELDA_ACC_WMEAN        4
    355 #define MLLR_ACC_BETWEEN        5
    356 #define MLLR_ACC_WITHIN         6
    357 #define MLLR_ACC_BMEAN          7
    358 #define MLLR_ACC_WMEAN          8
    359 #define IMELDA_MATRIX           9
    360 #define INVERSE_IMELDA_MATRIX   10
    361 #define MLLR_MATRIX             11
    362 #define TRANSFORM_MATRIX        12
    363 #define TRANSFORM_OFFSET        13
    364 #define CHAN_OFFSET             14
    365 
    366   /* for fast match debugging
    367   ** 5/1/99 SL
    368   */
    369 #define FRAME_VOICED            1
    370 #define FRAME_QUIET             2
    371 #define FRAME_UNCERTAIN         3
    372 
    373   int CA_GetVoicingStatus(CA_Pattern *hPattern);
    374   /**
    375    *
    376    * Params       hPattern    Handle to valid object
    377    * Returns      int         See below
    378    *
    379    ************************************************************************
    380    * Returns the voicing status of the current frame contained in the
    381    * Pattern object.
    382    * The function will return one of the following values :-
    383    *
    384    * FRAME_VOICED         1
    385    * FRAME_QUIET          2
    386    * FRAME_UNCERTAIN              3
    387    *
    388    * TODO: Integrate these defines into CR_type.h
    389    ************************************************************************
    390    */
    391 
    392 
    393 
    394   /*
    395   ** File: simapi.c
    396   */
    397   void CA_GetVersion(char *vertab,
    398                      int len);
    399   /**
    400    * Params   *vertab     Version info
    401    *          len         length of vertab
    402    *
    403    * Returns  nothing
    404    *
    405    ************************************************************************
    406    * There doesn't seem to be anything using this function.  Has it been
    407    * replaced by CrecGetVersion??  If so, there should be a CA interface
    408    * to it.
    409    ************************************************************************
    410    */
    411 
    412 
    413   void CA_Log(const char *string);
    414   /**
    415    *
    416    * Params       string  Single string for output log
    417    *
    418    * Returns      nothing
    419    *
    420    *
    421    ************************************************************************
    422    * NOTE swig dosen't allow <varargs> for function arguments hence, you
    423    * will have to format the string yourself prior to calling this function
    424    ************************************************************************
    425    */
    426 
    427 
    428   void CA_Init(void);
    429   /**
    430    *
    431    * Params       void
    432    *
    433    * Returns      Nothing, the error callback routine is registered
    434    *
    435    * See          CA_Term
    436    *
    437    ************************************************************************
    438    * Initializes the CREC (CR) interface.  A callback routine is supplied
    439    * by the user.  This is used as the registered callback function.
    440    * Any errors will vector through this method.  The prototype for the
    441    * callback funtion is defined in CR_TYPE.H
    442    *
    443    * This method must be the first CR call.  It can only be called again
    444    * during the lifetime of a process after a call to CA_Term().
    445    *
    446    * The user can specify NULL as the handler funtion, this will cause
    447    * the default error handler, crDefaultHandler(), to run when errors
    448    * are encountered.  This allows the easy use of PERL scripts and the CR
    449    * interface.  Generally a handler should be supplied.
    450    ************************************************************************
    451    */
    452 
    453   void CA_Term(void);
    454   /**
    455    *
    456    * Params       void
    457    *
    458    * Returns      Nothing, CR is terminated.  No CR method can be called
    459    *              until another call to CA_Init()
    460    *
    461    * See          CA_Init
    462    *
    463    ************************************************************************
    464    * Signals that the CREC (CR) interface is no longer needed.  This should
    465    * be the last method called in a CR application.
    466    *
    467    * The callback routine registered with CA_Init() is released.
    468    *
    469    * A test is made to ensure that all the handles associated with
    470    * CR objects have been de-allocated.  If an object handle still
    471    * exists when CA_Term() is called this will generate an error.
    472    ************************************************************************
    473    */
    474 
    475 
    476 
    477 
    478 #ifdef USE_EXCEPTION_HANDLING
    479   /*
    480   **  CA_Exception methods
    481   */
    482   int  CA_ExceptionGetCode(CA_Exception* e);
    483   int  CA_ExceptionGetMessage(CA_Exception* e , char* buff, int len,
    484                               char *filebuff, int filebufflen, int* line);
    485 
    486   int  CA_ExceptionGetHandleType(CA_Exception* e);
    487   int  CA_ExceptionGetHandle(CA_Exception* e, void **handle);
    488   int  CA_ExceptionDelete(CA_Exception* e);
    489 #endif
    490 
    491 
    492   /*
    493   **  CA_Acoustic methods
    494   */
    495   /*
    496   **  File: acc_basi.c
    497   */
    498   CA_Acoustic *CA_AllocateAcoustic(void);
    499   /**
    500    *
    501    * Params       void
    502    *
    503    * Returns      Handle to new acoustic structure, or NULL on error.
    504    *
    505    * See          CA_FreeAcoustic
    506    *
    507    ************************************************************************
    508    * Allocates a new Acoustic structure (object)
    509    ************************************************************************
    510    */
    511 
    512 
    513   void CA_FreeAcoustic(CA_Acoustic *hAcoust);
    514   /**
    515    *
    516    * Params       hAcoust   Handle to previously allocated acoustic structure
    517    *
    518    * Returns      void
    519    *
    520    * See          CA_AllocateAcoustic
    521    *
    522    ************************************************************************
    523    * Frees a previously allocated acoustic object.
    524    ************************************************************************
    525    */
    526 
    527 
    528   void CA_UnloadAcoustic(CA_Acoustic *hAcoust);
    529 
    530 
    531   /*
    532   **  File: acc_sub.c
    533   */
    534   int  CA_LoadAcousticSub(CA_Acoustic *hAcoust,
    535                           char *subname,
    536                           CA_AcoustInputParams *hAcoustInp);
    537   /**
    538    *
    539    * Params       hAcoust   point to a valid acoustic object
    540    *              subname     subword acoustic model file
    541    *              do_arb      0 for pcx, 1 for arb
    542    *              do_uni      1 for unimodal models
    543    *              hAcoustInp  Handle to valid acoustic input object
    544    *
    545    * Returns      True/False
    546    *
    547    * See          CA_UnloadAcoustic
    548    *              CA_LoadAcousticWhole
    549    *              CA_LoadDictionary
    550    *
    551    ************************************************************************
    552    * The acoustic sub-word models, whether speaker dependent or independent
    553    * must be loaded with this method.
    554    *
    555    * The model files must be in the 'Tracy' format (.PDF, .MIX etc.).
    556    * It is possible to load the ARB files, PCX files and CLV files.
    557    *
    558    * Note:    The phoneme table located with the ARB file is checked with
    559    *          other phoneme tables in the system (such as the one specified
    560    *          in the OK file).  This is why the Vocabulary class is also
    561    *          required.
    562    ************************************************************************
    563    */
    564 
    565 
    566 
    567 
    568   /*
    569   **  CA_Vocab methods
    570   */
    571   /*
    572   **  File: voc_basi.c
    573   */
    574   CA_Vocab *CA_AllocateVocabulary(void);
    575   /**
    576    *
    577    * Params       void
    578    *
    579    * Returns      Handle to allocated vocabulary structure, or NULL on error.
    580    *
    581    * See          CA_FreeVocabulary
    582    *
    583    ************************************************************************
    584    * This method creates a new vocabulary structure (object).  The new
    585    * structure is supplied to the caller by the method's return value.
    586    ************************************************************************
    587    */
    588 
    589 
    590   void CA_FreeVocabulary(CA_Vocab *hVocab);
    591   /**
    592    *
    593    * Params       hVocab  Handle to a previously allocated vocabulary
    594    *
    595    * Returns      void
    596    *
    597    * See          CA_AllocateVocabulary
    598    *
    599    ************************************************************************
    600    * Frees a previously allocated vocabular structure (object).
    601    ************************************************************************
    602    */
    603   void CA_LoadDictionary(CA_Vocab *hVocab,
    604                          const LCHAR* vocname,
    605                          char *phtname,
    606                          ESR_Locale* locale);
    607   /**
    608    *
    609    * Params       hVocab  Handle to vocabulary object
    610    *              vocFile Source vocabulary file
    611    *              phtname Source of phoneme table file
    612    *              locale Locale associated with dictionary
    613    *
    614    * Returns      void
    615    *
    616    * See          CA_UnloadDictionary
    617    *
    618    ************************************************************************
    619    * Loads vocabulary 'words' from an OK file.
    620    ************************************************************************
    621    */
    622 
    623 
    624   void CA_UnloadDictionary(CA_Vocab *hVocab);
    625   /**
    626    *
    627    * Params       hVocab  Handle to vocabulary object
    628    *
    629    * Returns      void
    630    *
    631    * See          CA_LoadDictionary
    632    *
    633    ************************************************************************
    634    * Unloads a previously loaded dictionary
    635    ************************************************************************
    636    */
    637 
    638 
    639   int  CA_CheckEntryInDictionary(CA_Vocab *hVocab,
    640                                  const char *label);
    641   /**
    642    *
    643    * Params       hVocab  Handle to vocabulary object
    644    *              label   textual trasncription of requested word
    645    *
    646    * Returns      ?
    647    *
    648    ************************************************************************
    649    * Checks the existance of a pronunciation
    650    ************************************************************************
    651    */
    652 
    653 
    654   int CA_GetEntryInDictionary(CA_Vocab *hVocab,
    655                               const char *label,
    656                               char *pron,
    657                               int *pronSize,
    658                               int pronMaxSize);
    659   /**
    660    *
    661    * Params       hVocab      Handle to vocabulary object
    662    *              label       textual trasncription of requested word
    663    *              pron        buffer to put pronunciation in.  The format
    664    *                          of this buffer is a series of prons terminated
    665    *                          by a null all terminated by a double null
    666    *              pronSize    the number of bytes returned in the pron buffer
    667    *              pronMaxSiz  this size of "pron"
    668    *
    669    * Returns      true if the word exists in the dictionary
    670    *
    671    ************************************************************************
    672    * Get the pronunciation of a word
    673    ************************************************************************
    674    */
    675 
    676 
    677   /*
    678   **  CA_NGram methods
    679   */
    680   /*
    681   **  File: lmf_basi.c
    682   */
    683   /*
    684   ** Gethin 25Aug00
    685   ** Functions excluded from compilation in ca.mak,
    686   ** therefore commented here
    687   **
    688   ** CA_NGram *CA_AllocateNGram (void);
    689   ** void CA_FreeNGram (CA_NGram *hNGram);
    690   ** void CA_LoadNGram (CA_NGram *hNGram, char *lmfname, char *trnname);
    691   ** void CA_SaveNGram (CA_NGram *hNGram, char *lmfname);
    692   ** void CA_UnloadNGram (CA_NGram *hNGram);
    693   ** int CA_ScoreSentence (CA_NGram *hNGram, char *sentence);
    694   ** int CA_SetupNGram (CA_NGram *hNGram, CA_Vocab *hVocab, int type);
    695   */
    696 
    697   /*
    698   **  CA_Pattern methods
    699   */
    700   /*
    701   **  File: pat_basi.c
    702   */
    703 
    704   CA_Pattern *CA_AllocatePattern(void);
    705   /**
    706    *
    707    * Params       void
    708    *
    709    * Returns      Handle to new pattern object
    710    *
    711    * See          CA_FreePattern
    712    *
    713    ************************************************************************
    714    * Creates a new pattern structure (object)
    715    ************************************************************************
    716    */
    717 
    718 
    719   void CA_FreePattern(CA_Pattern *hPattern);
    720   /**
    721    *
    722    * Params       hPattern    valid pattern handle
    723    *
    724    * Returns      Nothing, the pattern handle is not longer valid.
    725    *
    726    * See          CA_AllocatePattern
    727    *
    728    ************************************************************************
    729    * Deletes a previously allocated pattern structure
    730    ************************************************************************
    731    */
    732 
    733 
    734   int  CA_LoadPattern(CA_Pattern *hPattern,
    735                       CA_PatInputParams *hPatInput,
    736                       int dimen,
    737                       char *multable,
    738                       char *imelda);
    739   /**
    740    *
    741    * Params       hPattern    valid pattern handle
    742    *              hPatInput   valid pattern input paramater handle
    743    *              dimen
    744    *              multable
    745    *              imelda
    746    *
    747    * Returns      true/false
    748    *
    749    * See          CA_UnloadPattern
    750    *              CA_SetupPatternForAcoustic
    751    *              CA_LoadPatternParameters
    752    *
    753    ************************************************************************
    754    * Loads a pattern object.  Once loaded it need to be setup
    755    * with an acoustic model before any further setups involving
    756    * the recognizer.  The imelda parameters and optionally
    757    * the multables are loaded into the object.  Setup operations
    758    * based on parameters are also done.
    759    *
    760    * It is an error to call this function without first loading
    761    * pattern input parameters.
    762    ************************************************************************
    763    */
    764 
    765 
    766   void CA_UnloadPattern(CA_Pattern *hPattern);
    767   /**
    768    *
    769    * Params       hPattern    valid pattern handle
    770    *
    771    * Returns      Nothing, loaded object is unloaded
    772    *
    773    * See          CA_LoadPattern
    774    *
    775    ************************************************************************
    776    * Unloads a previously loaded pattern object
    777    ************************************************************************
    778    */
    779 
    780 
    781   void CA_SetupPatternForAcoustic(CA_Pattern *hPattern,
    782                                   CA_Acoustic *hAcoustic);
    783   /**
    784    *
    785    * Params       hPattern    valid pattern handle
    786    *              hAcoustic   valid acoustic handle
    787    *
    788    * Returns      Nothing, the pattern object is setup and ready for use
    789    *
    790    * See          CA_ClearPatternForAcoustic
    791    *              CA_LoadPattern
    792    *
    793    ************************************************************************
    794    * This sets up a previously allocated pattern object with acoustic
    795    * model information from the appropriate acoustic object.
    796    * It is necessary to call this function before the acoustic
    797    * object can be used any recognition or adaptation.
    798    *
    799    * If you have not called CA_LoadPattern() an error will be generated.
    800    ************************************************************************
    801    */
    802 
    803 
    804   void CA_ClearPatternForAcoustic(CA_Pattern *hPattern,
    805                                   CA_Acoustic *hAcoustic);
    806   /**
    807    *
    808    * Params       hPattern    valid pattern handle
    809    *              hAcoustic   valid acoustic handle
    810    *
    811    * Returns      Nothing
    812    *
    813    * See          CA_SetupPatternForAcoustic
    814    *
    815    ************************************************************************
    816    * un-sets a previously prepared pattern object
    817    ************************************************************************
    818    */
    819 
    820 
    821   int  CA_NextPatternFrame(CA_Pattern *hPattern,
    822                            CA_Utterance *hUtt);
    823   /**
    824    *
    825    * Params       hPattern valid pattern handle
    826    *              hUtt     valid utterance handle
    827    *
    828    * Returns      status code
    829    *
    830    * See          CA_NextUtteranceFrame
    831    *              CA_MakePatternFrame
    832    *              CA_AdvanceRecognitionByFrame
    833    *
    834    ************************************************************************
    835    * Frames can be accessed, on-by-one, from an utterance object into
    836    * a pattern object with this method.  If this routine returns a non-zero
    837    * value then an utterance frame is available for processing and a call
    838    * to the recognition method CA_AdvanceRecognitionByFrame as shown below:
    839    *
    840    * while ( CA_NextPatternFrame( hPattern, hUtt ) )
    841    * {
    842    *     CA_AdvanceRecognitionByFrame( hRecog, hPattern, hUtt );
    843    * }
    844    *
    845    * Frames copied in with this method are transformed (post-IMELDA)
    846    *
    847    * It is now advised that instead of this function,
    848    * one uses CA_GetUtteranceFrame and CA_AdvanceUtteranceFrame
    849    * to access frames in sequence.
    850    ************************************************************************
    851    */
    852 
    853   int  CA_MakePatternFrame(CA_Pattern *hPattern,
    854                            CA_Utterance *hUtt);
    855   /**
    856    *
    857    * Params       hPattern valid pattern handle
    858    *              hUtt     valid utterance object handle
    859    *
    860    * Returns      ?
    861    *
    862    * See          CA_NextUtteranceFrame
    863    *              CA_NextPatternFrame
    864    *
    865    ************************************************************************
    866    * The current frames is pulled in from an utterance object into
    867    * a pattern object with this method.  The frame position is not
    868    * moved on.
    869    *
    870    * Frames copied in with this method are IMELDA transformed
    871    ************************************************************************
    872    */
    873 
    874 
    875   /*
    876   **  File: pat_tran.c
    877   */
    878   void CA_SetCepstrumOffsetInPattern(CA_Pattern *hPattern,
    879                                      int index,
    880                                      int value);
    881    /**
    882    *
    883    * Params       hPattern    valid pattern handle
    884    *              hAcoust   valid acoustic handle
    885    *              relevance   relevance coefficient
    886    *
    887    * Returns      Nothing
    888    *
    889    ************************************************************************
    890    *  Accumulates the relevance of hAcoustic into hPattern
    891    ************************************************************************
    892    */
    893 
    894 
    895   void CA_SetupNoiseConditioning(CA_Pattern *hPattern,
    896                                  CA_FrontendInputParams *hFrontpar,
    897                                  int do_wholeword,
    898                                  int do_subword);
    899   /**
    900    *
    901    * Params       hPattern valid pattern handle
    902    *              hFrontpar valid frontend parameter object handle
    903    *              do_wholeword    true or false
    904    *              do_subword      true or false
    905    *
    906    * Returns      ?
    907    *
    908    * See          CA_ClearNoiseConditioning
    909    *              CA_ConditionAcousticToNoise
    910    *
    911    ************************************************************************
    912    * The initial setup for Extended Noise Conditioning (ENC).
    913    *
    914    ************************************************************************
    915    */
    916 
    917 
    918   void CA_ClearNoiseConditioning(CA_Pattern *hPattern);
    919   /**
    920    *
    921    * Params       hPattern valid pattern handle
    922    *
    923    * Returns      ?
    924    *
    925    * See          CA_SetupNoiseConditioning
    926    *              CA_ConditinAcousticToNoise
    927    *
    928    ************************************************************************
    929    * To free data structures constructed for Extended Noise Conditioning.
    930    *
    931    ************************************************************************
    932    */
    933 
    934 
    935   void CA_WriteMLLRCovariates(CA_Pattern *hPattern,
    936                               CA_Acoustic *hAcoust,
    937                               char *basename);
    938   /**
    939       No CR equivalent function
    940    */
    941 
    942 
    943   void CA_ReadMLLRTransforms(CA_Pattern *hPattern,
    944                              CA_Acoustic *hAcoust,
    945                              char *basename,
    946                              int ntrans);
    947   /**
    948       No CR equivalent function
    949    */
    950 
    951 
    952   /*
    953   **  File: pat_dump.c
    954   */
    955   void CA_SetupTransformDump(CA_Pattern *hPattern,
    956                              char* basename);
    957   /**
    958    *
    959    * Params       hPattern    valid pattern handle
    960    *              basename    file base name
    961    *
    962    * Returns      Nothing
    963    *
    964    * See          CA_ClearTransformDump
    965    *              CA_CalculateTransforms
    966    *              CA_ClearTransformAccumulates
    967    *
    968    ************************************************************************
    969    *  Sets up the facility to save the transform accumulates to a file.
    970    ************************************************************************
    971    */
    972 
    973 
    974   void CA_ClearTransformDump(CA_Pattern *hPattern);
    975   /**
    976    *
    977    * Params       hPattern    valid pattern handle
    978    *
    979    * Returns      Nothing
    980    *
    981    * See          CA_SetupTransformDump
    982    *              CA_CalculateTransforms
    983    *              CA_ClearTransformAccumulates
    984    *
    985    ************************************************************************
    986    *  Clears the facility to save the transform accumulates to a file.
    987    ************************************************************************
    988    */
    989 
    990 
    991   /*
    992    * Pattern Array access methods
    993    */
    994   /*
    995   **  File: pat_swig.c
    996   */
    997 
    998 	/*
    999    * Transform methods
   1000    */
   1001   /*
   1002   **  File: catrans.c
   1003   */
   1004   /*
   1005    * dave 08-Oct-99: These functions are now out of sync with CA.
   1006    *
   1007    * CA_Transform *CA_AllocateTransform (void);
   1008 
   1009    * void CA_FreeTransform (CA_Transform *hTransform);
   1010    * int CA_LoadTransform (CA_Transform *hTransform, int dimen);
   1011    * void CA_UnloadTransform (CA_Transform *hTransform);
   1012    * void CA_ConfigureTransform (CA_Transform *hTransform,int do_mllr,int do_imelda);
   1013    * void CA_ClearTransform (CA_Transform *hTransform);
   1014    * void CA_InheritAccumulates (CA_Transform *hTransform, CA_Pattern *hPattern);
   1015    * void CA_LoadTransformAccumulates( CA_Pattern *hPattern,
   1016    *      CA_Transform *hTransform);
   1017    */
   1018 
   1019   /*
   1020   **  CA_Utterance methods
   1021   */
   1022   /*
   1023   **  File: utt_basi.c
   1024   */
   1025   CA_Utterance *CA_AllocateUtterance(void);
   1026   /**
   1027    *
   1028    * Params       void
   1029    *
   1030    * Returns      Handle to a new utterance object
   1031    *
   1032    * See          CA_FreeUtterance
   1033    *
   1034    ************************************************************************
   1035    * Creates a new utterance object
   1036    ************************************************************************
   1037    */
   1038 
   1039 
   1040   void CA_FreeUtterance(CA_Utterance *hUtt);
   1041   /**
   1042    *
   1043    * Params       hUtt    valid utterance handle
   1044    *
   1045    * Returns      void    the object is no longer valid
   1046    *
   1047    * See          CA_AllocateUtterance
   1048    *
   1049    ************************************************************************
   1050    * Destroys a previously allocated utterance object
   1051    ************************************************************************
   1052    */
   1053 
   1054 
   1055   int  CA_InitUtteranceForFrontend(CA_Utterance *hUtt,
   1056                                    CA_FrontendInputParams *hFrontInp);
   1057   /**
   1058    *
   1059    * Params       hUtt    valid utterance handle
   1060    *              hFrontPar valid frontend input parameter handle
   1061    *
   1062    * Returns      non-zero on error
   1063    *
   1064    * See          CA_ClearUtterance
   1065    *              CA_GetFrontendUtteranceDimension
   1066    *              CA_LoadUtteranceFrame
   1067    *
   1068    ************************************************************************
   1069    * Creates an utterance object ready for the frontend to insert frames.
   1070    * This method should also be used to create utterances which will be
   1071    * used for raw utterance (frame-by-frame) recognition - See
   1072    * CA_LoadUtteranceFrame().
   1073    *
   1074    * Use the result from CA_GetFrontendUtteranceDimension to specify
   1075    * the dimension.
   1076    ************************************************************************
   1077    */
   1078 
   1079 
   1080   void CA_ClearUtterance(CA_Utterance *hUtt);
   1081   /**
   1082    *
   1083    * Params       hUtt    valid utterance handle
   1084    *
   1085    * Returns      void
   1086    *
   1087    * See          CA_InitUtteranceForFrontend
   1088    *
   1089    ************************************************************************
   1090    * Closes a previously opened utterance and frame buffer.
   1091    ************************************************************************
   1092    */
   1093 
   1094 
   1095   int  CA_NextUtteranceFrame(CA_Pattern *hPattern,
   1096                              CA_Utterance *hUtt);
   1097   /**
   1098    *
   1099    * Params       hPattern    valid pattern handle
   1100    *              hUtt        valid utterance handle
   1101    *
   1102    * Returns      status code
   1103    *
   1104    * See          CA_NextPatternFrame
   1105    *              CA_MakePatternFrame
   1106    *              CA_AdvanceUtteranceFrame
   1107    *
   1108    ************************************************************************
   1109    * Frames can be accessed, on-by-one, from an utterance object into
   1110    * a pattern object with this method.  It is advised that instead of
   1111    * this function, one use CA_MakePatternFrame and CA_AdvanceUtteranceFrame
   1112    * to access frames in sequence.
   1113    *
   1114    * Frames copied in with this method are un-transformed (pre-IMELDA)
   1115    ************************************************************************
   1116    */
   1117 
   1118 
   1119   int  CA_AdvanceUtteranceFrame(CA_Utterance *hUtt);
   1120   /**
   1121    *
   1122    * Params       hUtt    valid utterance handle
   1123    *
   1124    * Returns      True if it successfully advances the frame positon by one.
   1125    *
   1126    * See          CA_AdvanceRecognitionByFrame
   1127    *
   1128    ************************************************************************
   1129    ************************************************************************
   1130    */
   1131 
   1132   int  CA_UtteranceHasVoicing(CA_Utterance *hUtt);
   1133   /**
   1134    *
   1135    * Params       hUtt    valid utterance handle
   1136    *
   1137    * Returns      non-zero if utterance has voicing data
   1138    *
   1139    ************************************************************************
   1140    * This method can be polled to interrogate the state of the utterance.
   1141    ************************************************************************
   1142    */
   1143 
   1144   ESR_BOOL CA_IsUtteranceLockedForInput(CA_Utterance *hUtt);
   1145   /**
   1146    *
   1147    * Params       hUtt    valid utterance handle
   1148    *
   1149    * Returns      TRUE if utterance is locked
   1150    *
   1151    * See          CA_LockUtteranceFromInput
   1152    *
   1153    ************************************************************************
   1154    * Indicates if utterance is locked.
   1155    ************************************************************************
   1156    */
   1157 
   1158   void CA_UnlockUtteranceForInput(CA_Utterance *hUtt);
   1159   /**
   1160    *
   1161    * Params       hUtt    valid utterance handle
   1162    *
   1163    * Returns      void
   1164    *
   1165    * See          CA_LockUtteranceFromInput
   1166    *              CA_ResetVoicing
   1167    *
   1168    ************************************************************************
   1169    * This primes the utterance object by setting it's status to ACTIVE
   1170    ************************************************************************
   1171    */
   1172 
   1173 
   1174   void CA_LockUtteranceFromInput(CA_Utterance *hUtt);
   1175   /**
   1176    *
   1177    * Params       hUtt    valid utterance handle
   1178    *
   1179    * Returns      void
   1180    *
   1181    * See          CA_UnlockUtteranceForInput
   1182    *
   1183    ************************************************************************
   1184    * This signals that the utterance is complete by setting it's status to IDLE
   1185    ************************************************************************
   1186    */
   1187 
   1188 
   1189   void CA_ResetVoicing(CA_Utterance *hUtt);
   1190   /**
   1191    *
   1192    * Params       hUtt    valid utterance handle
   1193    *
   1194    * Returns      void
   1195    *
   1196    * See          CA_UnlockUtteranceForInput
   1197    *              CA_LockUtteranceFromInput
   1198    *
   1199    ************************************************************************
   1200    * This prepares the utterance object for re-use.  The 'utterance has
   1201    * started' and 'utterance has ended' flags are cleared.
   1202    * Unlike CA_UnlockUtteranceForInput, this does not fully clear the utterance.
   1203    ************************************************************************
   1204    */
   1205 
   1206 
   1207   void CA_FlushUtteranceFrames(CA_Utterance *hUtt);
   1208   /**
   1209    *
   1210    * Params       hUtt    valid utterance handle
   1211    *
   1212    * Returns      void
   1213    *
   1214    * See          CA_InitUtterance
   1215    *
   1216    ************************************************************************
   1217    * Clears the utterance object's frame buffer
   1218    ************************************************************************
   1219    */
   1220 
   1221 
   1222   void CA_SetEndOfUtteranceByLevelTimeout(CA_Utterance *hUtt,
   1223                                           long timeout,
   1224                                           long holdOff);
   1225   /**
   1226    *
   1227    * Params       hUtt    valid utterance handle
   1228    *              timeout timeout before EOU decision
   1229    *              holdOff Period which must pass before EOU can be signalled
   1230    *
   1231    * Returns      void
   1232    *
   1233    * See          CA_UtteranceHasEnded
   1234    *              CA_SeekStartOfUtterance
   1235    *
   1236    ************************************************************************
   1237    * Sets the duration (of silence) which should pass before making
   1238    * and end-of-utterance (EOU) decision.
   1239    *
   1240    * 'holdOff' is the period which must elapse before an EOU decision can
   1241    * be made.  An EOU will not occure before 'holdOff'.
   1242    *
   1243    * 'timeout' anf 'holdOff' are measured in frames.
   1244    *
   1245    * Caution: if an utterance can be spoken within 'holdOff' frames
   1246    *          it may be missed by the recognizer.
   1247    ************************************************************************
   1248    */
   1249 
   1250 
   1251   int  CA_UtteranceHasEnded(CA_Utterance *hUtt);
   1252   /**
   1253    *
   1254    * Params       hUtt    valid utterance handle
   1255    *
   1256    * Returns      non-zero if utterance has finished
   1257    *              (we've processed the last frame and we're locked from input)
   1258    *
   1259    * See          CA_SeekStartOfUtterance
   1260    *              CA_SetEndOfUtteranceByLevelTimeout
   1261    *
   1262    ************************************************************************
   1263    * This method can be polled to interrogate the state of the utterance.
   1264    ************************************************************************
   1265    */
   1266 
   1267   /*
   1268   **  File: utt_file.c
   1269   */
   1270   int  CA_SeekUtteranceFrame(CA_Utterance *hUtt,
   1271                              int frame_no);
   1272   /**
   1273    *
   1274    * Params       hUtt        valid utterance handle
   1275    *              frame_no    new frame number (should this be unsigned long?)
   1276    *
   1277    * Returns      -1 on error
   1278    *
   1279    * See          CA_NextPatternFrame
   1280    *
   1281    ************************************************************************
   1282    * The 'file pointer' is set to an explicit location
   1283    ************************************************************************
   1284    */
   1285 
   1286 
   1287   int CA_SaveUtterance(CA_Utterance *hUtt);
   1288   /**
   1289    *
   1290    * Params       hUtt    valid utterance handle
   1291    *
   1292    * Returns      int
   1293    *
   1294    ************************************************************************
   1295    * Saves an utterance
   1296    ************************************************************************
   1297    */
   1298 
   1299 
   1300   void CA_SaveUtteranceHeader(CA_Utterance *hUtt, int frames,
   1301                               int samplerate, int framerate);
   1302   /**
   1303    *
   1304    * Params       hUtt        valid utterance handle
   1305    *              frames      frames which have been saved in this utt
   1306    *              samplerate  sampling rate (typically 22050Hz)
   1307    *              framerate   frame rate    (typically 100 frames per second)
   1308    * Returns      void
   1309    *
   1310    ************************************************************************
   1311    * Saves an utterance
   1312    ************************************************************************
   1313    */
   1314 
   1315 
   1316   /*
   1317   **  File: utt_data.c
   1318   */
   1319   int  CA_SeekStartOfUtterance(CA_Utterance *hUtt);
   1320   /**
   1321    *
   1322    * Params       hUtt    valid utterance handle
   1323    *
   1324    * Returns      non-zero if utterance has begun
   1325    *
   1326    * See          CA_UtterancehasEnded
   1327    *
   1328    ************************************************************************
   1329    * This method can be polled to interrogate the state of the utterance.
   1330    ************************************************************************
   1331    */
   1332 
   1333 
   1334   int  CA_GetUnprocessedFramesInUtterance(CA_Utterance *hUtt);
   1335   /**
   1336    *
   1337    * Params       hUtt    valid utterance handle
   1338    *
   1339    * Returns      number of un-read frames in the utterance's frame buffer
   1340    *
   1341    * See          CA_AdvanceRecognitionByFrame
   1342    *
   1343    ************************************************************************
   1344    * Returns the number of un-read frames in the utterance's frame buffer,
   1345    * i.e. those that have been inserted but have not yet been processed
   1346    * by the recognizer object.
   1347    ************************************************************************
   1348    */
   1349 
   1350 
   1351   /*
   1352   **  File: utt_proc.c
   1353   */
   1354   int  CA_LoadUtteranceFrame(CA_Utterance *hUtt,
   1355                              unsigned char* pUttFrame,
   1356                              int uttFrameLen);
   1357   /**
   1358    *
   1359    * Params       hUtt        valid utterance handle
   1360    *              pUttFrame   Pointer utterance data
   1361    *              uttFrameLen Number of items (features) in the frame
   1362    *
   1363    * Returns      zero on error
   1364    *
   1365    * See          CA_InitUtteranceForFrontend
   1366    *              CA_GetFrontendUtteranceDimension
   1367    *
   1368    ************************************************************************
   1369    * Inserts the frame data pointed to by 'pUttFrame' into the utterance
   1370    * object 'hUtt'.
   1371    *
   1372    * The size of the frame must agree with the value used to initialise
   1373    * the utterance object.  Utterances suitable for injection are
   1374    * ones created for the Frontend.
   1375    ************************************************************************
   1376    */
   1377 
   1378 
   1379   int  CA_CopyUtteranceFrame(CA_Utterance *hUtt1,
   1380                              CA_Utterance *hUtt2);
   1381   /**
   1382    *
   1383    * Params       hUtt1   Destination valid utterance handle
   1384    *              hUtt2   Source valid utterance handle
   1385    *
   1386    * Returns      zero on error
   1387    *
   1388    ************************************************************************
   1389    * Copies utterance frames from one utterance object to another
   1390    ************************************************************************
   1391    */
   1392 
   1393 
   1394   void CA_CopyPatternFrame(CA_Utterance *hUtt,
   1395                            CA_Pattern *hPattern);
   1396   /**
   1397       No CR equivalent function
   1398    */
   1399 
   1400 
   1401   int  CA_CalculateUtteranceStatistics(CA_Utterance *hUtt,
   1402                                        int start,
   1403                                        int end);
   1404   /**
   1405    *
   1406    * Params       hUtt    valid utterance handle
   1407    *              start   starting frame ID (timecode)
   1408    *              end     final frame ID (timecode)
   1409    *
   1410    * Returns      Number of frames used in analysis
   1411    *
   1412    *
   1413    ************************************************************************
   1414    * Signals the collection of statistics over a pre-defined range of
   1415    * utterance frames in the utterance's frame buffer.  do_filter flag
   1416    * selects the frames that are likely to have just the ambient noise
   1417    * only.
   1418    * returns the number of frames used in the analysis.
   1419    ************************************************************************
   1420    */
   1421 
   1422 
   1423   /*
   1424   **  CA_Syntax methods
   1425   */
   1426 
   1427   CA_Syntax *CA_AllocateSyntax(void);
   1428   /**
   1429    *
   1430    * Params       void
   1431    *
   1432    * Returns      Handle to new syntax structure (object)
   1433    *
   1434    * See          CA_FreeSyntax
   1435    *
   1436    ************************************************************************
   1437    * creates a new syntax object
   1438    ************************************************************************
   1439    */
   1440 
   1441 
   1442   void CA_FreeSyntax(CA_Syntax *hSyntax);
   1443   /**
   1444    *
   1445    * Params       hSyntax valid syntax handle
   1446    *
   1447    * Returns      void
   1448    *
   1449    * See          CA_AllocateSyntax
   1450    *
   1451    ************************************************************************
   1452    * Frees an allocated syntax object
   1453    ************************************************************************
   1454    */
   1455 
   1456   int CA_IsEnrollmentSyntax(CA_Syntax *hSyntax);
   1457   /**
   1458    *
   1459    * Params       hSyntax valid syntax handle
   1460    *
   1461    * Returns      int
   1462    *
   1463    ************************************************************************
   1464    * tells whether a syntax is to be used for voice-enrollment
   1465    ************************************************************************
   1466    */
   1467 
   1468   int  CA_SetupSyntaxForRecognizer(CA_Syntax *hSyntax,
   1469                                    CA_Recog *hRecog);
   1470   /**
   1471    *
   1472    * Params       hSyntax valid syntax handle
   1473    *              hRecog  valid recog handle
   1474    *
   1475    * Returns      The number of Syntax groups located
   1476    *
   1477    * See          CA_CeilingSyntaxForRecognizer
   1478    *
   1479    ************************************************************************
   1480    * This is an essential, pre-recognition, setup method on the syntax object.
   1481    * A syntax can be set up using more than one recognizer, provided the
   1482    * active models have matching word indices.
   1483    * now deprecated
   1484    ************************************************************************
   1485    */
   1486     int  CA_CeilingSyntaxForRecognizer(CA_Syntax *hSyntax,
   1487                                    CA_Recog *hRecog);
   1488   /**
   1489    *
   1490    * Params       hSyntax valid syntax handle
   1491    *              hRecog  valid recog handle
   1492    *
   1493    * Returns      The number of Syntax groups located
   1494    *
   1495    * See          CA_ClearSyntaxForRecognizer
   1496    *
   1497    ************************************************************************
   1498    * This is an essential, pre-recognition, setup method on the syntax object.
   1499    * A syntax can be set up using more than one recognizer, provided the
   1500    * active models have matching word indices.
   1501    * now deprecated
   1502    ************************************************************************
   1503    */
   1504 
   1505 
   1506 
   1507   void CA_ClearSyntaxForRecognizer(CA_Syntax *hSyntax,
   1508                                    CA_Recog *hRecog);
   1509   /**
   1510    *
   1511    * Params       hSyntax valid syntax handle
   1512    *              hRecog  valid recog handle
   1513    *
   1514    * Returns      void
   1515    *
   1516    * See          CA_SetupSyntaxForRecognizer
   1517    *              CA_UnloadRecognitionModels
   1518    *
   1519    ************************************************************************
   1520    * Clears a previous syntax setup.
   1521    ************************************************************************
   1522    */
   1523 
   1524 
   1525   int  CA_CompileSyntax(CA_Syntax *hSyntax);
   1526   /**
   1527    *
   1528    * Params       hSyntax     valid syntax handle
   1529    *
   1530    * Returns      0 if successful, otherwise 1 to indicate faliure
   1531    *
   1532    * See          CA_AddWordToSyntax
   1533    *
   1534    ************************************************************************
   1535    * Compiles a syntax after words have been added dynamically
   1536    *
   1537    ************************************************************************
   1538    */
   1539 
   1540   /*
   1541   **  File: syn_grou.c
   1542   */
   1543 
   1544 
   1545   void CA_GetGroupName(CA_Syntax *hSyntax,
   1546                        int group_id,
   1547                        char *buff,
   1548                        int buff_len);
   1549   /**
   1550       No CR equivalent function.  Not called by any function
   1551    */
   1552 
   1553   void CA_DeleteSyntaxGroups(CA_Syntax *hSyntax);
   1554   /**
   1555       CR function has no prototype
   1556    */
   1557 
   1558   /*
   1559   **  File: syn_rule.c
   1560   */
   1561 
   1562 int CA_CheckTranscription(CA_Syntax *hSyntax,
   1563                             const char *trans,
   1564                             int allow_group_labels);
   1565   /**
   1566    *
   1567    * Params       hSyntax     valid syntax handle
   1568    *              trans        character string phrase
   1569     allow_group_labels  If 1, permits either words or group labels
   1570    *
   1571    * Returns      -1 if successful, 1 if failed, 0 if all words parsed,
   1572     but not on a valid terminal node.
   1573    *
   1574    ************************************************************************
   1575    * Use CA_CheckTranscription to check whether a phrase is valid for the
   1576    * given syntax. Set allow_group_labels to 0 if you use single-word per group.
   1577    *
   1578    * NB When allow_group_labels is set to 1, there is a danger that a group
   1579    * label might match an invalid word.
   1580    ************************************************************************
   1581    */
   1582 
   1583   /* It's nice to keep the Arbdata separate from the models and from the graphs
   1584      because we may have two or more acoustic models that use the same arbdata,
   1585      which is also justification for having the model durations in the
   1586      acoustic model file.  Different grammars should also be able to
   1587      share an Arbdata */
   1588   /* new CA_Syntax functions */
   1589 int CA_AttachArbdataToSyntax(CA_Syntax* hSyntax, CA_Arbdata* arbdata);
   1590 CA_Arbdata* CA_LoadArbdata(const char* filename);
   1591 unsigned int CA_ArbdataGetModelVersionID(CA_Arbdata* ca_arbdata);
   1592 int CA_ArbdataGetModelIdsForPron(CA_Arbdata* ca_arbdata,
   1593 								 const char* pronunciation,  /* WB assumed at the edges */
   1594 								 int pronunciation_len,
   1595 								 modelID* pmodelIds);
   1596 int CA_ArbdataGetModelIdsForPIC(CA_Arbdata* ca_arbdata, const char lphon, const char cphon, const char rphon);
   1597 
   1598   /**
   1599    * Destroys arbdata.
   1600    *
   1601    * @param arbdata CA_Arbdata handle
   1602    */
   1603 void CA_FreeArbdata(CA_Arbdata* arbdata);
   1604 int CA_AddWordToSyntax(CA_Syntax* syntax, const char* slot,
   1605                          const char *phrase, const char* pronunciation, const int weight);
   1606 int CA_ResetSyntax(CA_Syntax* syntax);
   1607 int CA_LoadSyntaxAsExtensible(CA_Syntax *hSyntax, char *synbase,
   1608                                 int num_words_to_add);
   1609 int CA_DumpSyntaxAsImage(CA_Syntax *hSyntax, const char *imagename, int version_number);
   1610 int CA_DumpSyntax(CA_Syntax *hSyntax, const char *basename);
   1611 int CA_LoadSyntaxFromImage(CA_Syntax *hSyntax, const LCHAR* filename);
   1612 
   1613 
   1614   /*
   1615   **  CA_Recog methods
   1616   */
   1617   /*
   1618   **  File: rec_basi.c
   1619   */
   1620   CA_Recog *CA_AllocateRecognition(void);
   1621   /**
   1622    *
   1623    * Params       void
   1624    *
   1625    * Returns      Handle to valid recognizer object, NULL on error.
   1626    *
   1627    * See          CA_FreeRecognition
   1628    *
   1629    ************************************************************************
   1630    * Creates a reconition object.
   1631    * This only creates the object and internal storage structures.
   1632    * The pointer can be re-used but must be deleted when finished with.
   1633    ************************************************************************
   1634    */
   1635 
   1636 
   1637   int CA_ConfigureRecognition(CA_Recog *hRecoc,
   1638                               CA_RecInputParams *hRecInput);
   1639 
   1640 
   1641 
   1642   void CA_UnconfigureRecognition(CA_Recog *hRecog);
   1643   /**
   1644    *
   1645    * Params       hRecog              valid recog handle
   1646    *
   1647    * Returns      void
   1648    *
   1649    * See          CA_ConfigureRecognition
   1650    *
   1651    ************************************************************************
   1652    * Unconfigures recognizer.
   1653    ************************************************************************
   1654    */
   1655 
   1656 
   1657   void CA_FreeRecognition(CA_Recog *hRecog);
   1658   /**
   1659    *
   1660    * Params       hRecog  valid recog handle
   1661    *
   1662    * Returns      void
   1663    *
   1664    * See          CA_AllocateRecognition
   1665    *
   1666    ************************************************************************
   1667    * Deletes a previously allocated recognizer
   1668    ************************************************************************
   1669    */
   1670 
   1671 
   1672   void CA_BeginRecognition(CA_Recog *hRecog,
   1673                            CA_Syntax *hSyntax,
   1674                            int first_syntax_node,
   1675                            CA_RecInputParams *hRecInput);
   1676   /**
   1677    *
   1678    * Params       hRecog              valid recog handle
   1679    *              hSyntax             valid syntax handle
   1680    *              first_syntax_node   starting syntax node
   1681    *              hRecInput           valid recog input parameter handle
   1682    *
   1683    * Returns      void
   1684    *
   1685    * See          CA_EndRecognition
   1686    *              CA_LoadRecognitionParameters
   1687    *
   1688    ************************************************************************
   1689    * Before a recognizer object can be used it must be initialized.
   1690    * This method performs this task and is given an appropriate
   1691    * syntax (and starting node) along with the required recognition
   1692    * input parameters.
   1693    *
   1694    * 'first_syntax_node' should be set to '1' (the root of the syntax object).
   1695    * Only experienced users should set this to any other value.  It is
   1696    * a start node ID returned by CA_AddNewNode().
   1697    *
   1698    * It is an error to call this function without first loading
   1699    * recognizer input parameters.
   1700    ************************************************************************
   1701    */
   1702 
   1703 
   1704   void CA_AdvanceRecognitionByFrame(CA_Recog *hRecog,
   1705                                     CA_Pattern *hPattern,
   1706                                     CA_Utterance *hUtterance);
   1707   /**
   1708    *
   1709    * Params       hRecog      valid recog handle
   1710    *              hPattern    valid pattern handle
   1711    *              hUtterance  valid utterance handle
   1712    *
   1713    * Returns      void
   1714    *
   1715    * See          CA_BeginRecognition
   1716    *              CA_EndRecognition
   1717    *              CA_AllocatePattern
   1718    *              CA_AllocateUtterance
   1719    *              CA_NextPatternFrame
   1720    *
   1721    ************************************************************************
   1722    * The vocabulary and acoustic object are required by the recognition
   1723    * object to process input frames should already have been loaded with
   1724    * a call to one of the CA_LoadModels methods.
   1725    *
   1726    * This method advances the recognizer by a single frame from the
   1727    * input stream.  This should be called when time permits and frames
   1728    * are available in the input stream (utterance).  Typically one would
   1729    * use the CA_Pattern object to detect the presence of unused frames,
   1730    * This is shown below:
   1731    *
   1732    * while ( CA_NextPatternFrame( hPattern, hUtt ) )
   1733    * {
   1734    *     CA_AdvanceRecognitionByFrame( hRecog, hPattern, hUtt );
   1735    * }
   1736    *
   1737    * This frame-by-frame approach provides the developer with fine control
   1738    * of the recognition task.  In a multi-process real-time enviornment
   1739    * where a sophisticated OS may not be present, one might want to
   1740    * schedule other tasks between individual frames.  This was certainly
   1741    * the case on early DSP boards chosen to host the CA recognizer.
   1742    * The developer may, of course, decide that such fine control is not
   1743    * required.  In such cases a higher level convenience function can easily
   1744    * be constructed and 'wrapped' around this method and
   1745    * which prepares the recognizer, processes all frames and then returns to
   1746    * the caller.
   1747    *
   1748    * Recognition results may be issued at any time within this method,
   1749    * It is partial traceback controls the time when results can be issued.
   1750    * Currently results are placed in a file or to the screen - the
   1751    * CA_Result methods provide additional flexibility.
   1752    ************************************************************************
   1753    */
   1754 
   1755 
   1756   int  CA_EndRecognition(CA_Recog *hRecog,
   1757                          CA_Pattern *hPattern,
   1758                          CA_Utterance *hUtterance);
   1759   /**
   1760    *
   1761    * Params       hRecog      valid recog handle
   1762    *              hPattern    valid pattern handle
   1763    *              hUtterance  valid utterance handle
   1764    *
   1765    * Returns      non-ZERO if correct termination
   1766    *
   1767    * See          CA_BeginRecognition
   1768    *              CA_AdvanceRecognitionByFrame
   1769    *  CA_DiscardRecognition
   1770    *
   1771    ************************************************************************
   1772    * When input processing is deemed to be complete, this mthod must
   1773    * be called.  It should be called after all the required input frames
   1774    * have been advanced through.  Not more than one recognizer may be
   1775    * terminated in this fashion when multiple recognizers are employed on
   1776    * given utterance.  All others should be discarded.
   1777    ************************************************************************
   1778    */
   1779 
   1780 
   1781   int CA_DiscardRecognition(CA_Recog *hRecog,
   1782                             CA_Pattern *hPattern,
   1783                             CA_Utterance *hUtterance);
   1784   /**
   1785    *
   1786    * Params       hRecog      valid recog handle
   1787    *              hPattern    valid pattern handle
   1788    *              hUtterance  valid utterance handle
   1789    *
   1790    *
   1791    * Returns      non-ZERO if successful
   1792    *
   1793    * See          CA_BeginRecognition
   1794    *              CA_AdvanceRecognitionByFrame
   1795    *  CA_EnddRecognition
   1796    *
   1797    ************************************************************************
   1798    * To discard the current recognition process.  Not more than one
   1799    * recognizer may be terminated in this fashion when multiple recognizers
   1800    * are employed on given utterance.  All others should be discarded.
   1801    ************************************************************************
   1802    */
   1803 
   1804 
   1805   void CA_UpdateCMSAccumulates(CA_Utterance *hUtt,
   1806                                CA_Recog *hRecog);
   1807   /**
   1808    *
   1809    * Params       hUtt       valid utterance handle
   1810    *              hRecog     valid recog handle
   1811    *
   1812    * Returns      Nothing
   1813    *
   1814    * See          CA_AttachCMStoUtterane
   1815    *              CA_CalculateCMSParameters
   1816    *
   1817    ************************************************************************
   1818    * Copies channel normalization accumulates from recog to utterance.
   1819    * These are then used when a call is made to CA_CalculateCMSParameters.
   1820    ************************************************************************
   1821    */
   1822 
   1823   /*
   1824   **  File: rec_load.c
   1825   */
   1826   void CA_LoadModelsInAcoustic(CA_Recog *hRecog,
   1827                                CA_Acoustic *hAcoust,
   1828                                CA_AcoustInputParams *hAcoustInp);
   1829   /**
   1830    *
   1831    * Params       hRecog      valid recog handle
   1832    *              hAcoust     valid acoutic (model) handle
   1833    *              hAcoustInp  valid acoustic inpit parameter handle
   1834    *
   1835    * Returns      void
   1836    *
   1837    * See          CA_LoadModelsInDictionary
   1838    *              CA_UnloadRecognitionModels
   1839    *              CA_LoadAcousticParameters
   1840    *
   1841    ************************************************************************
   1842    * This method constructs whole or sub-word models from
   1843    * the entire model set in preparation for recognition.
   1844    *
   1845    * It is an error to call this function without first loading
   1846    * acoustic input parameters.
   1847    ************************************************************************
   1848    */
   1849 
   1850 
   1851   void CA_LoadModelsInDictionary(CA_Recog *hRecog,
   1852                                  CA_Vocab *hVocab,
   1853                                  CA_Acoustic *hAcoust,
   1854                                  CA_AcoustInputParams *hAcoustInp);
   1855 
   1856 
   1857 
   1858   void CA_LoadCrosswordTriphonesInSyntax(CA_Recog *hRecog,
   1859                                          CA_Syntax *hSyntax,
   1860                                          CA_Acoustic *hAcoust,
   1861                                          CA_AcoustInputParams *hAcoustInp,
   1862                                          int do_generics);
   1863   /**
   1864    *
   1865    * Params       hRecog      valid recog handle
   1866    *              hSyntax     valid syntax handle
   1867    *              hVocab      valid vocabulary handle
   1868    *              hAcoust     valid acoustic (model) handle
   1869    *              hAcoustInp  valid acoustic input parameter handle
   1870    *              do-generics
   1871    *
   1872    * Returns      void
   1873    *
   1874    * See          CA_LoadModelsInAcoustic
   1875    *              CA_LoadModelsInDictionary
   1876    *              CA_UnloadRecognitionModels
   1877    *              CA_LoadAcousticParameters
   1878    *
   1879    ************************************************************************
   1880    * It is an error to call this function without first loading
   1881    * acoustic input parameters.
   1882    ************************************************************************
   1883    */
   1884 
   1885 
   1886 void CA_UnloadRecognitionModels (CA_Recog *hRecog);
   1887 /**
   1888  *
   1889  * Params       hRecog  valid recog handle
   1890  *
   1891  * Returns      void
   1892  *
   1893  * See          CA_LoadModelsInAcoustic
   1894  *              CA_LoadModelsInDictionary
   1895  *
   1896  ************************************************************************
   1897  * Destorys a previously loaded set of models.
   1898  * The models could have been constructed from acoustic information,
   1899  * dictionary (vocabulary) information or syntax (grammar) information
   1900  ************************************************************************
   1901  */
   1902 
   1903 
   1904   void CA_LoadMonophonesInAcoustic(CA_Recog *hRecog,
   1905                                    CA_Acoustic *hAcoust,
   1906                                    CA_AcoustInputParams *hAcoustInp);
   1907   /**
   1908    *
   1909    * Params       hRecog      valid recog handle
   1910    *              hAcoust     valid acoustic (model) handle
   1911    *              hAcoustInp  valid acoustic input parameter handle
   1912    *
   1913    * Returns      void
   1914    *
   1915    * See          CA_LoadModelsInAcoustic
   1916    *              CA_LoadCrosswordTriphonesInSyntax
   1917    *              CA_UnloadRecognitionModels
   1918    *              CA_LoadAcousticParameters
   1919    *
   1920    ************************************************************************
   1921    * This method constructs models for phoneme recognition. When using it,
   1922    * replace the calls to CA_LoadModelsInAcoustic and
   1923    * CA_LoadCrosswordTriphonesInSyntax with a call to
   1924    * CA_LoadMonophonesInAcoustic.
   1925    ************************************************************************
   1926    */
   1927 
   1928 
   1929   int CA_CompareModelIndices(CA_Recog *hRecog1,
   1930                              CA_Recog *hRecog2);
   1931   /**
   1932    *
   1933    * Params       hRecog1 valid recog handle
   1934    *              hRecog2 valid recog handle
   1935    *
   1936    * Returns      0 if indices match.
   1937    *
   1938    * See          CA_SetupSyntaxForRecognizer
   1939    *
   1940    ************************************************************************
   1941    * Checks that the model indices for two recognizers that have been set
   1942    * up are compatible. This check should be made if the recognizers are
   1943    * to use a shared syntax object. The check should be made prior to the
   1944 	 * calls to CA_BeginRecognition.
   1945    ************************************************************************
   1946    */
   1947 
   1948 
   1949   int CA_FixModelIndices(CA_Recog *hRecogTgt,
   1950                          CA_Acoustic *hAcousticSub,
   1951                          CA_Acoustic *hAcousticWhole,
   1952                          CA_Recog *hRecogSrc);
   1953   /**
   1954    *
   1955    * Params       hRecogTgt       valid recog handle
   1956    *              hAcousticSub    valid sub-word acoustic handle
   1957    *              hAcousticWhole  valid whole-word acoustic handle
   1958    *              hRecogSrc       valid recog handle
   1959    *
   1960    * Returns      0 if successful.
   1961    *
   1962    * See          CA_CompareModelIndices
   1963    *              CA_LoadCrossWordTriphonesInSyntax
   1964    *
   1965    ************************************************************************
   1966    * Us this function if the model indices for two recognizers that have
   1967    * been set up are not compatible. This function modifies the target
   1968    * recognizer's model indices to make them compatible with one another.
   1969    * This means that they can safely share a syntax object without the
   1970    * need for calling CA_LoadCrosswordTriphonesInSyntax.
   1971    ************************************************************************
   1972    */
   1973 
   1974 
   1975 
   1976 
   1977   /*
   1978   **  File: rec_addi.c
   1979   */
   1980   int  CA_GetRecognitionTopScore(CA_Recog *hRecog);
   1981   /**
   1982    *
   1983    * Params       hRecog  valid recog handle
   1984    *
   1985    * Returns      top score
   1986    *
   1987    * See          CA_SetRecognitionTopScore
   1988    *
   1989    ************************************************************************
   1990    * Reads top scoring result (used in multi-model configurations)
   1991    ************************************************************************
   1992    */
   1993 
   1994 
   1995   void CA_SetRecognitionTopScore(CA_Recog *hRecog,
   1996                                  int score);
   1997   /**
   1998    *
   1999    * Params       hRecog  valid recog handle
   2000    *              score   score
   2001    *
   2002    * Returns      void
   2003    *
   2004    * See          CA_GetRecognitionTopScore
   2005    *
   2006    ************************************************************************
   2007    * Sets top scoring result (used in multi-model configurations)
   2008    ************************************************************************
   2009    */
   2010 
   2011 
   2012   int  CA_GetRecognitionTerminationScore(CA_Recog *hRecog);
   2013   /**
   2014    *
   2015    * Params       hRecog  valid recog handle
   2016    *
   2017    * Returns      top score
   2018    *
   2019    ************************************************************************
   2020    * Reads top scoring final result (used in multi-model configurations)
   2021    ************************************************************************
   2022    */
   2023 
   2024 
   2025   int  CA_TracebackPerformed(CA_Recog* hRecog);
   2026   /**
   2027    *
   2028    * Params       hRecog  valid recog handle
   2029    *
   2030    * Returns      non-ZERO if the previous recognition frame processing
   2031    *              resulted in the execution of a partial-traceback
   2032    *
   2033    * See          CA_SetupRecognizerForSyntax
   2034    *
   2035    ************************************************************************
   2036    * Used to test for the need to get some results
   2037    ************************************************************************
   2038    */
   2039 
   2040 
   2041   void CA_BlockRecognitionResults(CA_Recog *hRecog);
   2042   /**
   2043    *
   2044    * Params       hRecog  valid recog handle
   2045    *
   2046    * Returns      void
   2047    *
   2048    * See          CA_UnBlockRecognitionResults
   2049    *
   2050    ************************************************************************
   2051    * Disables result generation (used in multi-model configurations)
   2052    ************************************************************************
   2053    */
   2054 
   2055 
   2056   void CA_UnBlockRecognitionResults(CA_Recog *hRecog);
   2057   /**
   2058    *
   2059    * Params       hRecog  valid recog handle
   2060    *
   2061    * Returns      void
   2062    *
   2063    * See          CA_BlockRecognitionResults
   2064    *
   2065    ************************************************************************
   2066    * Re-enables result generation (used in multi-model configurations)
   2067    ************************************************************************
   2068    */
   2069 
   2070 
   2071   /*
   2072   **  File: rec_resu.c
   2073   */
   2074   int  CA_FullResultScore(CA_Recog *hRecog,
   2075                           int *score,
   2076                           int do_incsil);
   2077 
   2078 
   2079 
   2080   int  CA_FullResultDuration(CA_Recog *hRecog,
   2081                              int *dur,
   2082                              int do_incsil);
   2083 
   2084 
   2085 
   2086 #ifdef SWIGBUILD
   2087   int  CA_FullResultLabel(CA_Recog *hRecog,
   2088                           void *label,
   2089                           int len);
   2090   /**
   2091    *
   2092    * Params       hRecog  valid recog handle
   2093    *              label   ASCII storage for returned result label
   2094    *              len     Number of charcaters available for label.
   2095    *                      Up to 'len'-1 characters will be returned.
   2096    *
   2097    * Returns      PARTIAL_RESULTS_EMPTY if no result is available for release.
   2098    *              Otherwize the result FULL_RESULT if a valid result is available,
   2099    *              or REJECT_RESULT if the reject score is > reject threshold.
   2100    *
   2101    * See          CA_FullResultScore
   2102    *              CA_PurgeResults
   2103    *
   2104    ************************************************************************
   2105    * This method returns all the Main ROOT results that have occured
   2106    * (and have been unread) up to now.  Results reported by this method
   2107    * will only be removed from subsequent calls after a 'purge'.
   2108    *
   2109    * If no results are available a return code of PARTIAL_RESULTS_EMPTY
   2110    * is returned.  In this situation the label will be set to "<>".
   2111    *
   2112    * All results between 'head' and 'tail' are reported.
   2113    ************************************************************************
   2114    */
   2115 
   2116 
   2117 #else
   2118   int  CA_FullResultLabel(CA_Recog *hRecog,
   2119                           char *label,
   2120                           int len);
   2121   /**
   2122   *
   2123   * Params       hRecog  valid recog handle
   2124   *              label   ASCII storage for returned result label
   2125   *              len     Number of charcaters available for label.
   2126   *                      Up to 'len'-1 characters will be returned.
   2127   *
   2128   * Returns      PARTIAL_RESULTS_EMPTY if no result is available for release.
   2129   *              Otherwize the result FULL_RESULT if a valid result is available,
   2130   *              or REJECT_RESULT if the reject score is > reject threshold.
   2131   *
   2132   * See          CA_FullResultScore
   2133   *              CA_PurgeResults
   2134   *
   2135   ************************************************************************
   2136   * This method returns all the Main ROOT results that have occured
   2137   * (and have been unread) up to now.  Results reported by this method
   2138   * will only be removed from subsequent calls after a 'purge'.
   2139   *
   2140   * If no results are available a return code of PARTIAL_RESULTS_EMPTY
   2141   * is returned.  In this situation the label will be set to "<>".
   2142   *
   2143   * All results between 'head' and 'tail' are reported.
   2144   ************************************************************************
   2145   */
   2146 #endif
   2147 
   2148   /**
   2149    * Strips the slot market characters from the utterance string.
   2150    *
   2151    * @param text String to filter
   2152    */
   2153   ESR_ReturnCode CA_ResultStripSlotMarkers(char *text);
   2154   ESR_ReturnCode CA_FullResultWordIDs(CA_Recog *hRecog, wordID *wordIDs, size_t* len);
   2155 
   2156   /**
   2157    * Gets the recognizer model id that was succesful (id is index in swimdllist file)
   2158    *
   2159    * @param text String to filter
   2160    */
   2161   ESR_ReturnCode CA_GetRecogID(CA_Recog *hRecog, int *id);
   2162 
   2163 
   2164   int  CA_GetRejectMargin(CA_Recog *hRecog);
   2165   /**
   2166    *
   2167    * Params               hRecog  valid recog handle
   2168    *
   2169    * Returns              reject margin, the differnce between the utterance score
   2170    *                      and the reject model score.
   2171    *
   2172    * See          CA_FullResultLabel
   2173    *              CA_FullResultScore
   2174    *
   2175    ************************************************************************
   2176    * This method returns the reject margin, the difference between the
   2177    * utterance score and the reject model score.
   2178    ************************************************************************
   2179    */
   2180 
   2181   void CA_PurgeResults(CA_Recog *hRecog);
   2182   /**
   2183    *
   2184    * Params       hRecog  valid recog handle
   2185    *
   2186    * Returns      Nothing, internal result list will be deleted
   2187    *
   2188    * See          CA_FullResultLabel
   2189    *              CA_FullResultScore
   2190    *
   2191    ************************************************************************
   2192    ************************************************************************
   2193    */
   2194 
   2195 
   2196   void CA_ClearResults(CA_Recog *hRecog);
   2197   /**
   2198    *
   2199    * Params       hRecog  valid recog handle
   2200    *
   2201    * Returns      void
   2202    *
   2203    * See          CA_RecognitionHasResults
   2204    ************************************************************************
   2205    * Clears results in a recognizer.  Should do CA_RecognitionHasResults
   2206    * first, to see if there are results to clear.
   2207    ************************************************************************
   2208    */
   2209 
   2210   int CA_RecognitionHasResults(CA_Recog *hRecog);
   2211   /**
   2212    *
   2213    * Params       hRecog      valid recog handle
   2214    *              num_frames  number of silence frames before end of
   2215    *                          utterance is considered
   2216    *
   2217    * Returns      void
   2218    *
   2219    ************************************************************************
   2220    ************************************************************************
   2221    */
   2222 
   2223 
   2224   int  CA_IsEndOfUtteranceByResults(CA_Recog *hRecog);
   2225   /**
   2226    *
   2227    * Params       hRecog  valid recog handle
   2228    *
   2229    * Returns
   2230    *
   2231    * See
   2232    *
   2233    ************************************************************************
   2234    ************************************************************************
   2235    */
   2236 
   2237 
   2238   int  CA_FullResultWordCount(CA_Recog *hRecog,
   2239                               int *count);
   2240   /**
   2241    *
   2242    * Params       hRecog      valid recog handle
   2243    *              count       pointer to storage for results word count
   2244    *
   2245    * Returns      PARTIAL_RESULTS_EMPTY if no result is available for release.
   2246    *              Otherwize the result FULL_RESULT if a valid result is available,
   2247    *              or REJECT_RESULT if the reject score is > reject threshold.
   2248    *
   2249    * See          CA_FullResultLabel
   2250    *              CA_PurgeResults
   2251    *
   2252    ************************************************************************
   2253    * This method returns the word count of the Main ROOT results that have
   2254    * occured (and have been unread) up to now (silence isn't a word).
   2255    * Results reported by this method will only be removed from subsequent
   2256    * calls after a 'purge'.
   2257    *
   2258    * If no results are available a return code of PARTIAL_RESULTS_EMPTY
   2259    * is returned.  In this situation the the count will be set to 0.
   2260    *
   2261    * All results between 'head' and 'tail' are reported.
   2262    ************************************************************************
   2263    */
   2264 
   2265 
   2266   int  CA_CheckWordHyphenation(CA_Recog *hRecog,
   2267                                int *hyphen,
   2268                                int position);
   2269   /**
   2270    *
   2271    * Params       hRecog      valid recog handle
   2272    *              hyphen      pointer to storage for hyphenation check result
   2273    *              position    first word position to check (zero based)
   2274    *
   2275    * Returns      PARTIAL_RESULTS_EMPTY if no result is available.
   2276    *              INVALID_REQUEST if position is illegal (negative or too big).
   2277    *              Otherwize the result FULL_RESULT.
   2278    *
   2279    * See          CA_FullResultLabel
   2280    *              CA_FullResultWordCount
   2281    *              CA_PurgeResults
   2282    *
   2283    ************************************************************************
   2284    * This method checks whether two words should be hyphenated or not. This
   2285    * check is done on the Main ROOT results that have occured (and have been
   2286    * unread) up to now, excluding silence labels. The words are pointed out
   2287    * by giving the position of the first word to check inside the sequence
   2288    * (zero based, not counting silence labels).
   2289    *
   2290    * If no results are available, a return code of PARTIAL_RESULTS_EMPTY is
   2291    * returned. If the given word position is illegal (either negative or too
   2292    * big), a return code of INVALID_REQUEST is returned.
   2293    * In these situations the hyphenation will be set to 0.
   2294    ************************************************************************
   2295    */
   2296 
   2297 
   2298   /*
   2299   **  File: rec_nbes.c
   2300   */
   2301   CA_NBestList *CA_PrepareNBestList(CA_Recog *hRecog,
   2302                                     int n,
   2303                                     asr_int32_t *bestScore);
   2304   /**
   2305    *
   2306    * Params       hRecog      valid recog object handle
   2307    *              n           number of items in list
   2308    *              bestScore   The score associated with the root result
   2309    *                          is returned in this argument.
   2310    *
   2311    * Returns      Handle to new N-Best object
   2312    *
   2313    * See          CA_DeleteNBestList
   2314    *
   2315    ************************************************************************
   2316    * Creates an N-Best structure for iterating through as results arrive.
   2317    ************************************************************************
   2318    */
   2319 
   2320 
   2321   void CA_DeleteNBestList(CA_NBestList *hNbest);
   2322   /**
   2323    *
   2324    * Params       hNbest   valid nbest object handle
   2325    *
   2326    * Returns      Nothing, the object is no longer valid
   2327    *
   2328    * See          CA_PrepareNBestList
   2329    *
   2330    ************************************************************************
   2331    * Deletes a previously allocated NBest list object
   2332    ************************************************************************
   2333    */
   2334 
   2335   LCHAR* CA_NBestListGetResultWord(CA_NBestList *hNbest, size_t iChoice);
   2336   int  CA_NBestListGetResultConfidenceValue(CA_NBestList *hNbest, size_t iChoice, int* value);
   2337   int  CA_NBestListRemoveResult(CA_NBestList *hNbest, int index);
   2338 
   2339    int  CA_NBestListCount(CA_NBestList *hNbest);
   2340   /**
   2341    *
   2342    * Params       hNbest       valid N-Best object handle
   2343    *
   2344    * Returns      Number of entries found in the list.  The maximum number
   2345    *              of entries in the list is determined when the list is created.
   2346    *
   2347    * See          CA_PrepareNBestList
   2348    *
   2349    ************************************************************************
   2350    * Once an N-Best list has been created this method allows the caller
   2351    * to check the number of entries in the list.
   2352    ************************************************************************
   2353    */
   2354 
   2355   /**
   2356    * Returns the n'th nbest-list entry.
   2357    *
   2358    * @param nbest N-best list structure
   2359    * @param index N-best list index
   2360    * @param wordIDs Array of wordIDs making up the literal
   2361    * @param len [in/out] Length of wordIDs argument. If the return code is ESR_BUFFER_OVERFLOW,
   2362    *            the required length is returned in this variable.
   2363    * @param cost Cost associated with literal
   2364    */
   2365   ESR_ReturnCode CA_NBestListGetResultWordIDs(CA_NBestList* nbest, size_t iChoice, wordID* wordIDs, size_t* len, asr_int32_t* cost);
   2366 
   2367 
   2368   /*
   2369   **  CA_Params methods
   2370   */
   2371   /*
   2372   **  File: par_basi.c
   2373   */
   2374   CA_AcoustInputParams *CA_AllocateAcousticParameters(void);
   2375   /**
   2376    *
   2377    * Params       void
   2378    *
   2379    * Returns      Handle to valid acoustic input object, NULL on error
   2380    *
   2381    * See          CA_FreeAcousticParameters
   2382    *              CA_LoadAcousticWhole
   2383    *              CA_LoadAcousticSub
   2384    *              CA_LoadModelsInAcoustic
   2385    *              CA_SaveAcousticSub
   2386    *              CA_LoadModelsInDictionary
   2387    *
   2388    ************************************************************************
   2389    * Creates a new acoustic input paramater onject
   2390    ************************************************************************
   2391    */
   2392 
   2393 
   2394   void CA_FreeAcousticParameters(CA_AcoustInputParams *hAcoustInp);
   2395   /**
   2396    *
   2397    * Params       hAcoustInp  valid acoustic input handle
   2398    *
   2399    * Returns      Nothing, the acoustic input handle is no longer valid
   2400    *
   2401    * See          CA_AllocateAcousticParameters
   2402    *
   2403    ************************************************************************
   2404    * Removes a previously allocated parameter object
   2405    ************************************************************************
   2406    */
   2407 
   2408 
   2409   CA_PatInputParams *CA_AllocatePatternParameters(void);
   2410   /**
   2411    *
   2412    * Params       void
   2413    *
   2414    * Returns      Handle to a new pattern object, NULL on error
   2415    *
   2416    * See          CA_FreePatternParameters
   2417    *              CA_LoadPattern
   2418    *
   2419    ************************************************************************
   2420    * Creates a new pattern input paramater onject
   2421    ************************************************************************
   2422    */
   2423 
   2424 
   2425   void CA_FreePatternParameters(CA_PatInputParams *hPatInp);
   2426   /**
   2427    *
   2428    * Params       hPatInp valid pattern input handle
   2429    *
   2430    * Returns      void    The input handle is no longer valid.
   2431    *
   2432    * See          CA_AllocatePatternParameters
   2433    *
   2434    ************************************************************************
   2435    * Removes a previously allocated parameter object
   2436    ************************************************************************
   2437    */
   2438 
   2439 
   2440   CA_RecInputParams *CA_AllocateRecognitionParameters(void);
   2441   /**
   2442    *
   2443    * Params       void
   2444    *
   2445    * Returns      Handle to new recog input object
   2446    *
   2447    * See          CA_FreeRecognitionParameters
   2448    *              CA_BeginRecognition
   2449    *
   2450    ************************************************************************
   2451    * Creates a new recog input paramater onject
   2452    ************************************************************************
   2453    */
   2454 
   2455 
   2456   void CA_FreeRecognitionParameters(CA_RecInputParams *hRecInp);
   2457   /**
   2458    *
   2459    * Params       hRecInp valid recog input handle
   2460    *
   2461    * Returns      void    the recognition input object is no longer valid
   2462    *
   2463    * See          CA_AllocateRecognitionParameters
   2464    *
   2465    ************************************************************************
   2466    * Removes a previously allocated parameter object
   2467    ************************************************************************
   2468    */
   2469 
   2470 
   2471 
   2472   /*
   2473   **  File: par_load.c
   2474   */
   2475   void CA_LoadAcousticParameters(CA_AcoustInputParams *hAcoustInp,
   2476                                  const char *parfile);
   2477   /**
   2478    *
   2479    * Params       hAcoustInp  valid acoustic input handle
   2480    *              parfile     parameter (.INI) file to read
   2481    *
   2482    * Returns      void
   2483    *
   2484    * See          CA_SaveAcousticParameters
   2485    *              CA_LoadAcousticWhole
   2486    *              CA_LoadAcousticSub
   2487    *              CA_LoadModelsInAcoustic
   2488    *              CA_SaveAcousticSub
   2489    *              CA_LoadModelsInDictionary
   2490    *
   2491    ************************************************************************
   2492    * Loads known acoustic parameters from the given parameter file.
   2493    * The file is an ASCII text file usually of the type .PAR or .INI
   2494    ************************************************************************
   2495    */
   2496 
   2497 
   2498   void CA_SaveAcousticParameters(CA_AcoustInputParams *hAcoustInp,
   2499                                  const char *parfile);
   2500   /**
   2501    *
   2502    * Params       hAcoustInp  valid acoustic input handle
   2503    *              parfile     parameter (.INI) file to write
   2504    *
   2505    * Returns      void
   2506    *
   2507    * See          CA_LoadAcousticParameters
   2508    *
   2509    ************************************************************************
   2510    * Saves a previously loaded (modified) parameter file
   2511    *
   2512    * It is an error to call this function without first loading
   2513    * acoustic input parameters.
   2514    ************************************************************************
   2515    */
   2516 
   2517 
   2518   void CA_LoadPatternParameters(CA_PatInputParams *hPatInp,
   2519                                 const char *parfile);
   2520   /**
   2521    *
   2522    * Params       hPatInp valid pattern handle
   2523    *              parfile parameter (.INI) file to read
   2524    *
   2525    * Returns      void
   2526    *
   2527    * See          CA_SavePatternParameters
   2528    *              CA_LoadPattern
   2529    *
   2530    ************************************************************************
   2531    * Loads known pattern parameters from the given parameter file.
   2532    * The file is an ASCII text file usually of the type .PAR or .INI
   2533    ************************************************************************
   2534    */
   2535 
   2536 
   2537   void CA_SavePatternParameters(CA_PatInputParams *hPatInp,
   2538                                 const char *parfile);
   2539   /**
   2540    *
   2541    * Params       hPatInp valid pattern input handle
   2542    *              parfile parameter (.INI) file to write
   2543    *
   2544    * Returns      void
   2545    *
   2546    * See          CA_LoadPatternParameters
   2547    *              CA_LoadPattern
   2548    *
   2549    ************************************************************************
   2550    * Saves a previously loaded (modified) parameter file
   2551    *
   2552    * It is an error to call this function without first loading
   2553    * pattern input parameters.
   2554    ************************************************************************
   2555    */
   2556 
   2557 
   2558   void CA_LoadRecognitionParameters(CA_RecInputParams *hRecInp,
   2559                                     const char *parfile);
   2560   /**
   2561    *
   2562    * Params       hRecInp valid recog input handle
   2563    *              parfile parameter (.INI) file to read
   2564    *
   2565    * Returns      void
   2566    *
   2567    * See          CA_AllocateRecognitionParameters
   2568    *              CA_SaveRecognitionParameters
   2569    *              CA_BeginRecognition
   2570    *
   2571    ************************************************************************
   2572    * Loads known recognition parameters from the given parameter file.
   2573    * The file is an ASCII text file usually of the type .PAR or .INI
   2574    ************************************************************************
   2575    */
   2576 
   2577 
   2578   void CA_SaveRecognitionParameters(CA_RecInputParams *hRecInp,
   2579                                     const char *parfile);
   2580   /**
   2581    *
   2582    * Params       hRecInp valid recog input handle
   2583    *              parfile parameter (.INI) file to write
   2584    *
   2585    * Returns      void
   2586    *
   2587    * See          CA_LoadRecognitionParameters
   2588    *              CA_BeginRecognition
   2589    *
   2590    ************************************************************************
   2591    * Saves a previously loaded (modified) parameter file
   2592    ************************************************************************
   2593    */
   2594 
   2595 
   2596   /*
   2597   **  File: par_set.c
   2598   */
   2599 
   2600   int CA_GetAcousticParameter(CA_AcoustInputParams *hAcoustInp,
   2601                               char *key,
   2602                               void *value);
   2603   /**
   2604    *
   2605    * Params       hAcoustInp  valid acoustic input handle
   2606    *              key         parameter key (text label)
   2607    *              value       pointer to store parameter value (text)
   2608    *              valueLen    size of value buffer
   2609    *
   2610    * Returns      False on error
   2611    *
   2612    * See          CA_GetAcousticIntParameter
   2613    *              CA_GetAcousticFloatParameter
   2614    *              CA_LoadAcousticParameters
   2615    *
   2616    ************************************************************************
   2617    * Gets a known acoustic parameter.
   2618    *
   2619    * It is an error to call this function without first loading
   2620    * acoustic input parameters.
   2621    ************************************************************************
   2622    */
   2623 
   2624 
   2625   int CA_GetAcousticStringParameter(CA_AcoustInputParams *hAcoustInp,
   2626                                     char *key,
   2627                                     char *value,
   2628                                     int valueLen,
   2629                                     int *bytes_required);
   2630   /**
   2631    *
   2632    * Params       hAcoustInp  valid acoustic input handle
   2633    *              key         parameter key (text label)
   2634    *              value       pointer to store parameter value (text)
   2635    *              valueLen    size of value buffer
   2636    *
   2637    * Returns      False on error
   2638    *
   2639    * See          CA_GetAcousticIntParameter
   2640    *              CA_GetAcousticFloatParameter
   2641    *              CA_LoadAcousticParameters
   2642    *
   2643    ************************************************************************
   2644    * Gets a known acoustic parameter.
   2645    *
   2646    * It is an error to call this function without first loading
   2647    * acoustic input parameters.
   2648    ************************************************************************
   2649    */
   2650 
   2651   int CA_SetPatternParameter(CA_PatInputParams *hPatInp,
   2652                              char *key,
   2653                              char *value);
   2654   /**
   2655    *
   2656    * Params       hPatInp valid Pattern Input handle
   2657    *              key     parameter key (text label)
   2658    *              value   new parameter value (text)
   2659    *
   2660    * Returns      Zero on error
   2661    *
   2662    * See          CA_GetPatternStringParameter
   2663    *              CA_GetPatternIntParameter
   2664    *              CA_GetPatternFloatParameter
   2665    *              CA_LoadPatternParameters
   2666    *
   2667    ************************************************************************
   2668    * Sets/Modifies a known Pattern Input parameter.
   2669    *
   2670    * It is an error to call this function without first loading
   2671    * pattern input parameters.
   2672    ************************************************************************
   2673    */
   2674 
   2675 
   2676   int CA_GetPatternParameter(CA_PatInputParams *hPatInp,
   2677                              char *key,
   2678                              void *value);
   2679   /**
   2680    *
   2681    * Params       hPatInp valid Pattern Input handle
   2682    *              key     parameter key (text label)
   2683    *              value   pointer to store parameter value (int)
   2684    *
   2685    * Returns      False on error
   2686    *
   2687    * See          CA_SetPatternParameter
   2688    *              CA_LoadPatternParameters
   2689    *
   2690    ************************************************************************
   2691    * Reads a known Pattern Input Parameter.
   2692    *
   2693    * It is an error to call this function without first loading
   2694    * pattern input parameters.
   2695    ************************************************************************
   2696    */
   2697 
   2698 
   2699   int CA_GetPatternStringParameter(CA_PatInputParams *hPatInp,
   2700                                    char *key,
   2701                                    char *value,
   2702                                    int valueLen,
   2703                                    int *bytes_required);
   2704   /**
   2705    *
   2706    * Params       hPatInp     valid Pattern Input handle
   2707    *              key         parameter key (text label)
   2708    *              value       pointer to store parameter value (text)
   2709    *              valueLen    size of value buffer
   2710    *
   2711    * Returns      False on error
   2712    *
   2713    * See          CA_SetPatternParameter
   2714    *              CA_LoadPatternParameters
   2715    *
   2716    ************************************************************************
   2717    * Reads a known Pattern Input Parameter.
   2718    *
   2719    * It is an error to call this function without first loading
   2720    * pattern input parameters.
   2721    ************************************************************************
   2722    */
   2723 
   2724 
   2725   int CA_SetRecognitionParameter(CA_RecInputParams *hRecInp,
   2726                                  char *key,
   2727                                  char *value);
   2728   /**
   2729    *
   2730    * Params       hRecInp valid recog input handle
   2731    *              key     parameter key (text label)
   2732    *              value   new parameter value (text)
   2733    *
   2734    * Returns      Zero on error
   2735    *
   2736    * See          CA_GetRecognitionStringParameter
   2737    *              CA_GetRecognitionIntParameter
   2738    *              CA_GetRecognitionFloatParameter
   2739    *              CA_LoadRecognitionParameters
   2740    *
   2741    ************************************************************************
   2742    * Sets/Modifies a known recognition parameter.
   2743    *
   2744    * It is an error to call this function without first loading
   2745    * recognizer input parameters.
   2746    ************************************************************************
   2747    */
   2748 
   2749   int CA_GetRecognitionParameter(CA_RecInputParams *hRecInp,
   2750                                  char *key,
   2751                                  void *value);
   2752   /**
   2753    *
   2754    * Params       hRecInp valid recog input handle
   2755    *              key     parameter key (text label)
   2756    *              value   pointer to store parameter value (int)
   2757    *
   2758    * Returns      False on error
   2759    *
   2760    * See          CA_SetRecognitionParameter
   2761    *              CA_BeginRecognition
   2762    *              CA_LoadRecognitionParameters
   2763    *
   2764    ************************************************************************
   2765    * Reads a known recognition parameter.
   2766    *
   2767    * It is an error to call this function without first loading
   2768    * recognizer input parameters.
   2769    ************************************************************************
   2770    */
   2771 
   2772 
   2773   int CA_GetRecognitionStringParameter(CA_RecInputParams *hRecInp,
   2774                                        char *key,
   2775                                        char *value,
   2776                                        int valueLen,
   2777                                        int *bytes_required);
   2778 #if USE_CONFIDENCE_SCORER
   2779 
   2780   CA_ConfidenceScorer* CA_AllocateConfidenceScorer(void);
   2781 
   2782   /**
   2783    *
   2784    * Params       void
   2785    *
   2786    * Returns      Handle to new ConfidenceScorer structure, or NULL on error.
   2787    *
   2788    * See          CR_FreeConfidenceScorer
   2789    *
   2790    ************************************************************************
   2791    * Allocates a new SymbolMatch structure (object)
   2792    ************************************************************************
   2793    */
   2794 
   2795   void CA_FreeConfidenceScorer(CA_ConfidenceScorer *hConfidenceScorer);
   2796 
   2797 
   2798   int CA_LoadConfidenceScorer(CA_ConfidenceScorer* hConfidenceScorer);
   2799   /**
   2800    *
   2801    * Params       hConfidenceScorer   Handle to previously allocated ConfidenceScorer object
   2802    *  nnet_file     Name of the confidence scoring file
   2803    *
   2804    * Returns      True if successful, False in the case of an error
   2805    *
   2806    * See
   2807    *
   2808    ************************************************************************
   2809    ************************************************************************
   2810    */
   2811 
   2812   void CA_UnloadConfidenceScorer(CA_ConfidenceScorer *hConfidenceScorer);
   2813   /**
   2814    *
   2815    * Params       hConfidenceScorer   Handle to previously allocated ConfidenceScorer object
   2816    *
   2817    * Returns
   2818    *
   2819    * See
   2820    *
   2821    ************************************************************************
   2822    ************************************************************************
   2823    */
   2824 
   2825   int CA_ComputeConfidenceValues(CA_ConfidenceScorer* hConfidenceScorer,
   2826                                 CA_Recog* recog, CA_NBestList *nbestlist);
   2827    /**
   2828    *
   2829    * Params       hConfidenceScorer   Handle to previously allocated ConfidenceScorer object
   2830    *              recog               Handle to recognizer that won
   2831    *              nbestlist           Handle to nbest list where confidence values will be inserted
   2832    *
   2833    * Returns      0 if successful, 1 if not.
   2834    *
   2835    *
   2836    ************************************************************************
   2837    ************************************************************************
   2838    */
   2839 
   2840 #endif /* #if USE_CONFIDENCE_SCORER */
   2841 
   2842 #ifdef __cplusplus
   2843 }
   2844 #endif
   2845 
   2846 #endif
   2847