📄 hshell.h
字号:
/* ----------------------------------------------------------- *//* *//* ___ *//* |_| | |_/ SPEECH *//* | | | | \ RECOGNITION *//* ========= SOFTWARE */ /* *//* *//* ----------------------------------------------------------- *//* developed at: *//* *//* Speech Vision and Robotics group *//* Cambridge University Engineering Department *//* http://svr-www.eng.cam.ac.uk/ *//* *//* Entropic Cambridge Research Laboratory *//* (now part of Microsoft) *//* *//* ----------------------------------------------------------- *//* Copyright: Microsoft Corporation *//* 1995-2000 Redmond, Washington USA *//* http://www.microsoft.com *//* *//* 2001-2002 Cambridge University *//* Engineering Department *//* *//* Use of this software is governed by a License Agreement *//* ** See the file License for the Conditions of Use ** *//* ** This banner notice must not be removed ** *//* *//* ----------------------------------------------------------- *//* File: HShell.h: Interface to the Shell *//* ----------------------------------------------------------- *//* !HVER!HShell: 3.3 [CUED 28/04/05] */#ifndef _HSHELL_H_#define _HSHELL_H_#include <stdio.h> /* Standard Libraries */#include <stdlib.h>#include <stdarg.h>#include <string.h>#include <ctype.h>#include <math.h>#include <limits.h>#ifdef WIN32 /* WIN32 modification */#include <time.h>#include <Winsock2.h>#else#include <sys/time.h>#endif#include <errno.h>#include <signal.h>#include <assert.h>#ifdef CYGWIN#include <asm/socket.h>#endif#ifdef __cplusplusextern "C" {#endif#if !defined UNIX && !defined WIN32 && !defined MPW &&!defined VMS#define UNIX /* Choices are UNIX, WIN32, MPW, VMS */#endif#ifdef UNIX#include <unistd.h>#include <time.h>#endif#define MAXSTRLEN 256 /* max length of a string */#define MAXFNAMELEN 1034 /* max length of a file name */#define SMAX 5 /* max num data streams + 1 */#define MAXGLOBS 256 /* max num global config parms */#define SING_QUOTE '\'' /* character used as quote */#define DBL_QUOTE '"' /* character used as quote */#define ESCAPE_CHAR '\\' /* character used as escape */#ifdef UNIX#include <sys/types.h>#include <sys/ioctl.h>#endif#undef FALSE#undef TRUEtypedef int int32;typedef enum {FAIL=-1, SUCCESS=0} ReturnStatus;/* Boolean type definition */typedef enum {FALSE=0, TRUE=1} Boolean;typedef double HTime; /* time in 100ns units */typedef enum{ /* Input filters for various types of file */ WaveFilter, /* waveforms input via HWave */ ParmFilter, /* parameter files input via HParm */ LangModFilter, /* language model files input via HLM */ HMMListFilter, /* HMM lists input via HModel */ HMMDefFilter, /* HMM definition files input via HModel */ LabelsFilter, /* Label files input via HLabel */ NetFilter, /* Network file input via HNet */ DictFilter, /* Dictionary file input via HDict */ LGramFilter, /* NGram Input via LGBase */ LWMapFilter, /* LM Word Map Input via LWMap */ LCMapFilter, /* LM Class Map Input */ LMTextFilter, /* LM source text input via LGPrep */ NoFilter, /* Direct input - no pipe */ WaveOFilter, /* waveforms output via HWave */ ParmOFilter, /* parameter files output via HParm */ LangModOFilter, /* language model files output via HLM */ HMMListOFilter, /* HMM lists output via HModel */ HMMDefOFilter, /* HMM definition files output via HModel */ LabelsOFilter, /* Label files output via HLabel */ NetOFilter, /* Network file output via HNet */ DictOFilter, /* Dictionary file output via HDict */ LGramOFilter, /* NGram Output via LGBase */ LWMapOFilter, /* LM Word Map Output via LWMap */ LCMapOFilter, /* LM Class Map Output */ NoOFilter /* Direct output - no pipe */}IOFilter;typedef struct { /* Defines a source file with position tracking */ char name[256]; /* file name for error messages */ FILE *f; /* input stream */ Boolean isPipe; /* input is a pipe */ Boolean pbValid; /* true if putback holds char */ Boolean wasQuoted; /* true if ReadString returned quoted string */ Boolean wasNewline; /* true if SkipWhiteSpace went over newline */ int putback; /* put back character */ int chcount; /* num chars from start */} Source;typedef enum{ /* Type of configuration parameter */ StrCKind, /* string, optionally in dble quotes */ IntCKind, /* integer value - coercable to float */ FltCKind, /* float value */ BoolCKind, /* Boolean: T,F,True,False */ AnyCKind /* dont care */} ConfKind;typedef union { /* union of possible config param kinds */ char *s; int i; double f; Boolean b;}ConfVal;typedef struct { /* Configuration Parameter */ char *user; /* name of module/tool to use this param */ char *name; /* name of param - upper case always */ ConfKind kind; /* kind of config param value */ ConfVal val; /* value */ Boolean seen; /* set true when read by any module */} ConfParam;/* ---------------- Termination and error handling ------------------- */void Exit(int exitcode);/* Exit from tool (and print termination diagnostics if required).*/void HError(int errcode, char *message, ...);/* Print the given message in 'printf' style, then if err > 0 terminate returning errcode as status.*/void HRError(int errcode, char *message, ...);/* New function - print error message on stderr and don't abort.*//* ------------------------ Initialisation --------------------------- */ReturnStatus SetScriptFile(char *fn); /* Allows more than one script file to be used by an HTK Tool For example, with the -S and -f options in HDistance*/extern Boolean vaxOrder; /* Global variable indicating VAX-order architecture for storing numbers */ReturnStatus InitShell(int argc, char *argv[], char *ver, char *sccs);/* Called from main to initialise module and store command line parameters for subsequent access by following xxxArg routines. The following standard command line options are processed immediately by InitShell and then deleted from the command line: -A print command line arguments -C configfile load given configuration file -D display config parameters -S scriptfile append the given script file -V print version and sccs info and abort ver and sccs are the HTK version info ver and sccs info for the current tool.*/void Register(char *ver, char *sccs);/* Register module version and sccs info. This information is used by PrintVersion. It is called by each module's Init routine.*/char * RegisterExtFileName(char *s);/* Record details of fn extended attributed if any in circular buffer */Boolean InfoPrinted(void);/* Returns true if Shell has printed out information via one of the special commands -A, -B or -V. This MUST be called immediately after Initialising all modules since it executes a pending -V request, if any.*/void PrintStdOpts(char *opts);/* Print standard command line options - as above. Additional standard options (ie capital letter options not implemented directly by the shell) must be listed in opts from the following set: -B Save HMM macro files as binary -F fmt Set source format to fmt -G fmt Set source label format to fmt -H mmf Load HMM macro file mmf -I mlf Load master label file mlf -L dir Dir holding label files -M Dir to write HMM macro files -O Set target data format to fmt -P Set target label format to fmt -Q Print command summary -X ext Set label file extension to ext Only exception to this is -T which is always printed.*//* ------------- Configuration Parameter File Handling --------------- */void PrintConfig(void);/* Print the current configuration and usage*/int GetConfig(char *user, Boolean incGlob, ConfParam **list, int max);/* Store a list of upto max configuration parameters whose user name matches the user and return the number of parameters stored. If list is NULL then just return the number of parameters that would have been stored. If incGlob then global parameters are included. If user is NULL then all parameters are returned. If max is exceeded then an error occurs.*/Boolean HasConfParm(ConfParam **list, int size, char *name);Boolean GetConfStr(ConfParam **list,int size,char *name, char *str);Boolean GetConfBool(ConfParam **list,int size,char *name, Boolean *b);Boolean GetConfInt(ConfParam **list,int size,char *name, int *ival);Boolean GetConfFlt(ConfParam **list,int size,char *name, double *fval);/* Access routines for the array of size ConfParam elements returned by GetConfig. Returns true if name is found. Generates an error if kind is different*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -