⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hmodel.h

📁 实现HMM算法
💻 H
📖 第 1 页 / 共 2 页
字号:
void InitModel(void);/*   Initialise the module*//* --------------- Input XForm DIrectory access -------------------- *//* EXPORT->AddInXFormDir: Add given file directory to set */void  AddInXFormDir(HMMSet *hset, char *dirname);/* ---------------- Macro Related Manipulations -------------------- */void QuantiseObservation(HMMSet *hset, Observation *obs, int frame);MLink NewMacro(HMMSet *hset, short fidx, char type, LabId id, Ptr structure);/*   Create a new macro definition for given HMM set with given values   and insert it into the associated macro table.  Return a pointer to   it.*/void DeleteMacro(HMMSet *hset, MLink p);void DeleteMacroStruct(HMMSet *hset, char type, Ptr structure);/*    Mark macro definition [for given structure] as deleted (ie type='*')*/MLink FindMacroName(HMMSet *hset, char type, LabId id);/*   Find the macro def of given name in hset.  Return NULL if    not found.  This uses a fast hashtable lookup.*/MLink FindMacroStruct(HMMSet *hset, char type, Ptr structure);/*    Return macro definition for given structure. The first   request for this structure requires a slow exhaustive    search through whole macro table.  The ptr is then added   to a hashtable stored in hset so that subsequent   requests are fast.*/Boolean HasMacros(HMMSet *hset, char * types);/*   Returns true if shared structure macros (other than regular   hmmdefs) have been used in any HMM in set.  If types is not NULL,   then a string containing all the different macro types is also   returned.*/void SetVFloor(HMMSet *hset, Vector *vFloor, float minVar);/*   Initialise a set of variance floor vectors.  Marks varFloor vectors   as used then if vFloor!=NULL and macro ~v "varFloorN"   exists then vFloor[N] is set to this vector; otherwise a vector of   length hset->swidth[s] is created in vFloor[s] and all its   components are set to minVar.*/void ApplyVFloor(HMMSet *hset);/*    Apply the variance floors in hset to all covariances in the model set */void PrintHMMProfile(FILE *f, HLink hmm);/*   Print a profile (num states, streams, mixes, etc) to f of   given HMM definition.*/void PrintHSetProfile(FILE *f, HMMSet *hset);/*   Print a profile to f of given HMM set.*//* ------------------- HMM Set Load/Store ---------------------- *//* the basic sequence needed to create a HMM set is      CreateHMMSet {AddMMF} (MakeHMMSet | MakeOneHMM) LoadHMMSet*/void CreateHMMSet(HMMSet *hset, MemHeap *heap, Boolean allowTMods);/*    Create a HMMSet using given heap.  This routine simply   initialises the basic HMMSet structure. It must be followed by   a call to either MakeOneHMM or MakeHMMSet.  */MILink AddMMF(HMMSet *hset, char *fname);/*   Add MMF file to HMM set (must not be already in MMF list).  This is   mainly used for pre-specifying definition files but it can also be   used to force loading of supplementary information coded as macros   such as variance floors.  Returns a pointer to added MMFInfo   record.  AddMMF can be used before or after a call to MakeOneHMM or    MakeHMMSet.  However, it must not be called after LoadHMMSet.*/ReturnStatus MakeHMMSet(HMMSet *hset, char *fname);/*   Make a HMMSet by reading the file fname.  Each line of fname   should contain the logical name of a HMM optionally followed by a   physical name.  If no physical name is given it is assumed to be   the same as the logical name.  This routine creates the macro hash   table, macro definitions for each HMM and HMMDef structures.  It   does NOT load the actual HMM definitions.*/ReturnStatus MakeOneHMM(HMMSet *hset, char *hname);/*   As above but hname is a single HMM definition which is used   to create a singleton HMM set*/ReturnStatus LoadHMMSet(HMMSet *hset, char *hmmDir, char *hmmExt);/*   Load any preloaded MMF files.  Scan the physical list of hset and   for each HMM def which is still unloaded, the physical name is   modified by the given hmmDir and hmmExt, if any, and the resulting   file is loaded.*/void ResetHMMSet(HMMSet *hset);/*  Returns HMMSet to state it was in after calling CreateHMMSet.   Frees memory on hmem, (and logicalHeap if HMM_STORE enabled) etc.*/void SaveInOneFile(HMMSet *hset, char *fname);/*   Called before SaveHMMSet to ignore all original file names and store   the entire HMM set in a single file.*/ReturnStatus SaveHMMSet(HMMSet *hset, char *hmmDir, char *hmmExt, char *macroExt, Boolean binary);/*   Store the given HMM set.  Each HMM def and macro is stored in the   same file as it was loaded from except that if hmmDir is specified   then it replaces the original location of the file.  In the case of   individual HMM files only, the original extension if any is   replaced by the given hmmExt if any.  If the HMM set is TIEDHS or   DISCRETEHS then the mix weights are stored in a compact form.  If   binary is set then all output uses compact binary mode.*/ReturnStatus SaveHMMList(HMMSet *hset, char *fname);/*   Save a HMM list in fname describing given HMM set *//* -------------- Shared Structure "Seen" Flags -------------- *//* When scanning HMM sets, it is convenient to mark certain objects   as "seen".  The nUse and nMix fields are used for this.  If either   is -ve then the attached object seen. */Boolean IsSeen(int flag);/*   return true if flag is set (ie. -ve)*/void Touch(int *flag);void Untouch(int *flag);/*   set or clear given flag (see also TouchV/UntouchV in HMem)*/typedef enum {CLR_HMMS,CLR_STATES,CLR_STREAMS,CLR_ALL} ClearDepth;void ClearSeenFlags(HMMSet *hset, ClearDepth depth);/*   Clear all the seen flags in hset (ie all nUse and nMix fields)   downto given level.*//* ----------------- General HMM Operations --------------------- */int MaxMixtures(HLink hmm);int MaxMixInSet(HMMSet *hset);/*   Returns max number of mixtures in given HMM or set of HMMs*/int MaxMixInS(HLink hmm, int s);int MaxMixInSetS(HMMSet *hset, int s);/*   Returns max number of mixtures in given stream in given HMM or set of HMMs*/int MaxStatesInSet(HMMSet *hset);/*   Returns max number of states in any HMM in set of HMMs*/char *DurKind2Str(DurKind dkind, char *buf);char *CovKind2Str(CovKind ckind, char *buf);/*   Utility routines to convert enum types to strings.  In each case,   string is stored in *buf and pointer to buf is returned*//* ------------- HMM Output Probability Calculations --------------- */void PrecomputeTMix(HMMSet *hset, Observation *x, float tmThresh, int topM);/*   Precompute the tied mixture probs stored in hset->tmRecs.  The   array of mix probs is scaled by the max prob and sorted.  If topM>0   then it is set in each stream, otherwise all mixes within tmThresh   of the max are used*/   LogFloat  OutP(Observation *x, HLink hmm, int state);LogFloat POutP(HMMSet *hset, Observation *x, StateInfo *si);/*   Return the log output probability of observation x in given   state of given model*/LogFloat SOutP(HMMSet *hset, int s, Observation *x, StreamElem *se);/*   Return Stream log output prob of stream s of observation x*//*   Return Mixture log output probability for given vector x.  */Boolean PDEMOutP(Vector otvs, MixPDF *mp, LogFloat *mixp, LogFloat xwtdet);LogFloat MOutP(Vector x, MixPDF *mp);LogFloat IDOutP(Vector x, int vecSize, MixPDF *mp);short DProb2Short(float p);#ifdef PDE_STATS/*    Get PDE stats*/void PrintPDEstats();#endif/*    Convert prob p to scaled log prob = ln(p)*DLOGSCALE*/LogFloat Short2DProb(short s);/*   Convert scaled log prob (s) to prob p = exp(s/DLOGSCALE)*/void FixFullGConst(MixPDF *mp, LogFloat ldet);void FixLLTGConst(MixPDF *mp);void FixInvDiagGConst(MixPDF *mp);void FixDiagGConst(MixPDF *mp);/*   Set the gConst for the specific mixture component.  In the   case of FullGConst, ldet is passed as a parameter since it   will often have just been calculated during a cov inversion.*/void FixGConsts(HLink hmm);/*   Sets all gConst values in the given HMM*/void FixAllGConsts(HMMSet *hset);/*   Sets all gConst values in all HMMs in set*/LogFloat MixLogWeight(HMMSet *hset, float weight); float MixWeight(HMMSet *hset, float weight);/*  Get the log-weight*//* ---------------------- XForm support code ---------------------- *//* EXPORT->LoadInputXForm: loads, or returns, the specified transform */InputXForm *LoadInputXForm(HMMSet *hset, char* macroname, char* fname);/* EXPORT->SaveInputXForm: outputs an individual transform */void SaveInputXForm(HMMSet *hset, InputXForm *xf, char *fname, Boolean binary);/* EXPORT->LoadOneXForm: loads, or returns, the specified transform */AdaptXForm *LoadOneXForm(HMMSet *hset, char* macroname, char* fname);/* EXPORT->SaveOneXForm: outputs an individual transform */void SaveOneXForm(HMMSet *hset, AdaptXForm *xform, char *fname, Boolean binary);/* EXPORT->SaveAllXForms: outputs all generated transforms */void SaveAllXForms(HMMSet *hset, char *fname, Boolean binary);/* EXPORT->LoadBaseClass: loads, or returns, the specified baseclass */BaseClass *LoadBaseClass(HMMSet *hset, char* macroname, char *fname);/* EXPORT->LoadRegTree: loads, or returns, the specified regression tree */RegTree *LoadRegTree(HMMSet *hset, char* macroname, char *fname);/* EXPORT-> CreateXFormMacro: creates a macro for a transform. */void CreateXFormMacro(HMMSet *hset,AdaptXForm *xform, char* macroname);/* EXPORT-> XFormKind2Str: Return string representation of enum XFormKind */char *XFormKind2Str(XFormKind xkind, char *buf);/* EXPORT-> AdaptKind2Str: Return string representation of enum AdaptKind */char *AdaptKind2Str(AdaptKind akind, char *buf);/* EXPORT-> BaseClassKind2Str: Return string representation of enum BaseClassKind */char *BaseClassKind2Str(BaseClassKind bkind, char *buf);/* EXPORT-> Str2BaseClassKind: parse the string into the correct baseclass */BaseClassKind Str2BaseClassKind(char *str);/* EXPORT-> Str2XFormKind: parse the string into the correct xform kind */XFormKind Str2XFormKind(char *str);/* EXPORT-> Str2AdaptKind: parse the string into the correct xform kind */AdaptKind Str2AdaptKind(char *str);#ifdef __cplusplus}#endif#endif  /* _HMODEL_H_ *//* ------------------------- End of HModel.h --------------------------- */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -