📄 readparams.3
字号:
.\" Copyright (c) 1986-1990 Entropic Speech, Inc..\" Copyright (c) 1991 Entropic Research Laboratory, Inc.; All rights reserved.\" @(#)readparams.3 1.11 02 May 1997 ESI/ERL.ds ]W (c) 1991 Entropic Research Laboratory, Inc..TH READ_PARAMS 3\-ESPSu 02 May 1997.SH "NAME"read_params - read parameters from either an ESPS Parameter or Common file.SH "SYNOPSIS".B #include <esps/param.h>.brextern int debug_level;.br.B int.br.B read_params (param_file, flag, check_file).br.B char *param_file;.br.B int flag;.br.B char *check_file;.SH "DESCRIPTION".PP.I read_paramsreads an ESPS Parameter file \fIparam_file\fP, processes ESPS Common,and produces a symbol table. ESPS Parameter files are written in aC-like language; they are processed by \fIlex\fP (see below and [1]for more information)..PPAfter the symbol table has been created (by \fIread_params\fP), symbolvalues can be obtained by calls to \fIgetsym\fP(3\-\s-1ESPS\s+1).Other information about the parameters can be obtained from\fIsymtype\fP(3\-\s-1ESPS\s+1), \fIsymsize\fP(3\-\s-1ESPS\s+1),\fIsymlist\fP(3\-\s-1ESPS\s+1), .br\fIsymdefinite\fP(3\-\s-1ESPS\s+1),\fIsymchoices\fP(3\-\s-1ESPS\s+1), \fIsymrange\fP(3\-\s-1ESPS\s+1),and \fIsymprompt\fP(3\-\s-1ESPS\s+1)..PPIf the value of \fIflag\fR is \s-2\fBSC_NOCOMMON\fR\s+2 then only\fIparam_file\fR is processed..PPIf \fIparam_file\fR is null, then \fIread_params\fP uses the ESPSdefault parameter file name "params". If \fIparam_file\fP isnon-NULL, and if \fIread_params\fP is unable to find a corresponding,readable parameter file, a warning is printed. By default,\fIread_params\fP uses \fIfind_esps_file\fP (3\-\s-1ESPS\s+1) tosearch for \fIparam_file\fP along the path ".:$ESPS_BASE/lib/params".This default search path can be overridden by setting the \fIunix\fPenvironment variable ESPS_PARAMS_PATH..PPIf \fIflag\fR is \s-2\fBSC_CHECK_FILE\fR\s+2, if an ESPS Common fileexists, and if Common processing is enabled (see ESPS COMMON, below),then the Common file is processed if \fIcheck_file\fR matches thevalue of the \fIfilename\fR entry in the Common file or if\fIcheck_file\fR is NULL. If a Common file is processed,\fIread_params\fP compares the last modification time of the ESPSCommon and \fIparam_file\fR. The parameter values in the younger ofthe two files takes precedence. Parameter values not occurring in theESPS Common file are read from the ESPS Parameter file. Note that, inthe case of indefinite assignment ("?=" or "=?" used as the assignmentoperator in the parameter file), Common processing will still occurfor the assigned default value. If the value from Common takes precedence, it will be this value that is shown as the default when a runtime prompt is generated by a call to .br\fIgetsym\fP (3\-\s-1ESPS\s+1). .PPThe \fIunix\fP environment variable ESPS_VERBOSE is used to controlthe extent of parameter processing feedback messages issued by\fIread_params\fP. There are three significant settings: 0, 1, and 2.If it is equal to 0, no feedback is provided. If ESPS_VERBOSE is 1,programs report the value of any parameters taken from ESPS common.If it is 2 or greater, programs report the values of parameters takenfrom ESPS common, the name of the actual parameter file used (if any),and the values of parameters taken from the parameter file. IfESPS_VERBOSE is not set, a value of 2 is assumed. Note that parameterfile selection is affected by ESPS_PARAMS_PATH (as described above)..PPRegardless of ESPS_VERBOSE, if \fIdebug_level\fP is non-zero,\fIread_params\fP will warn if a parameter file cannot be found(including the default "params"), will report the name of anyparameter file found, and will report if ESPS Common is processed,.SH PARAMETER FILE FORMAT.PPParameter files and common files are written in a C-like language.Parameters may have six types: integer, real (stored as doubleprecision values), string, character, array of integer, and array ofreal..PPFor each parameter, the parameter file contains the following: .IPparameter type.IPparameter name.IPdefinite assigned value (operator "=") or indefinite assigned value(operator "?=").IP(optional) prompt string.IP(optional) parameter limitations (discrete choices or range of values).PPIf the assigned value for a parameter is indefinite (indicated by theassignment operator "?=" or "=?"), then the user will be prompted forthe value to be used. The prompt will occur at runtime when thecorresponding \fIgetsym\fP (3\-\s-1ESPS\s+1) call is made. If theoptional prompt string was supplied in the parameter file, that stringwill be used as the prompt; otherwise the parameter name will be used.If the user enters a RETURN in answer to the prompt, the default valuewill be used..PPIf the optional parameter limitations are supplied, they are appendedto the prompt string that is used for indefinite assignments. Whilethey are not enforced by the .br\fIgetsym\fP (3\-\s-1ESPS\s+1) routines,the limitations are available to user programs by means of\fIsymchoices\fP (3\-\s-1ESPS\s+1) and .br\fIsymrange\fP (3\-\s-1ESPS\s+1). .PPHere is an example of a parameter file:.nf.ft CWint order ?= 10 : "Model order"; # ask for promptint verbose = no;#preemphasis specificationint preflg = yes;float pre_num = { 0.9, -0.5 }, # zeros of preemph filter pre_den = { 0.99, -0.99 }, # poles of preemph filter scale = 0.25;# prompt for framelengthint frmlen ?= 150: "Length of analysis window";# prompt for frame shift - show permitted rangeint nshft ?= 180: "Distance between frames":[0,360];# method for autocorrelation computation; ask for prompt and show 3 choicesstring method ?= "BURG":"Enter analysis method":{"BURG", "AUTOC", "COVAR"};.ft LR.fi.PPA simplified grammar follows. In this grammar, parentheses indicate that thecontents may be repeated zero or more times. Square brackets indicate thatthe contents are optional (zero or one repetitions). Vertical bars indicate"or". CHRVAL, STRVAL, FLOVAL, and INTVAL represent legal C tokens forcharacters, strings, real values, and integers respectively. IDENTrepresents any legal C variable name, other than one of the reservedkeywords. Case is significant, and all characters of names are significant(the restriction imposed by LEX, which builds the lexical analyzer, is about200 characters). Most C escape sequences like '\en' are supported incharacter and string constants. Character constants like '^b', meaningcontrol-b, are also supported. However, octal and hexadecimal numbers arenot supported. Multiline strings are not supported..nf.ft CWfile :== ( statement )statement :== type decl ( \fR'\fP,\fR'\fP decl ) \fR'\fP;\fR'\fPtype :== "int" | "float" | "char" | "string" | "char *"decl :== IDENT assop value [prompt] [limits]value :== CHRVAL | STRVAL | FLOVAL | INTVAL | arrayarray :== \fR'\fP{\fR'\fP num ( \fR'\fP,\fR'\fP num ) \fR'\fP}\fR'\fPnum :== INTVAL | FLOVALprompt :== \fR'\fP:\fR'\fP STRVALlimits :== choices | rangechoices :== \fR'\fP:\fR'\fP strarraystrarray :== \fR'\fP{\fR'\fP STRVAL ( \fR'\fP,\fR'\fP STRVAL) \fR'\fP}\fR'\fPrange :== \fR'\fP:\fR'\fP \fR'\fP[\fR'\fP min \fR'\fP,\fR'\fP max \fR'\fP]\fR'\fP min :== nummax :== numassop :== \fR'\fP=\fR'\fP | \fR'\fP=\fR'\fP \fR'\fP?\fR'\fP | \fR'\fP?\fR'\fP \fR'\fP=\fR'\fP.ft LR.fiThe following keywords are reserved: int, char, string, float, yes,no, true, false. The keywords "yes" and "true" are treated as integerconqstants with value one (the C convention for expressing logicaltrue); the keywords "no" and "false" are integer constants with valuezero..PPThe comment convention is different from C. It is the same as for theC shell. A '#' character indicates that the rest of the line is acomment, unless it is contained in a character or string constant.This makes it easier to comment out lines..PPNote that it is an error to provide a range for a string parameter,but it is OK to provide choices for a numeric parameter. .SH ESPS COMMON.PPESPS Common processing may be disabled by setting the environment variableUSE_ESPS_COMMON to "off". The default ESPS Common file is .espscom in the user's home directory. This may be overidden by settingthe environment variable ESPSCOM to the desired path. If ESPS_VERBOSEis set to 1 or greater, \fIread_params\fP will report the values of any parameters take from Common. .PPUpon successful completion, \fIread_params\fR returns 0.If it could not read the parameter file, \-1 is returned.If it could not read the common file, \-2 is returned.If it could not read either then \-3 is returned..SH "EXAMPLE".nfHere is a typical ESPS Parameter file:# This line is a commentint start = 0: "First point";int nan = 1000: "Number of points";string decrem = "no";float harmonic_mult = -99.0;read_params ("params",SC_NOCOMMON,NULL); /* read default parameter file */ /* in this case process only "params" */start = getsym_i ("start"); /* read symbol from symbol table */.fi.SH DIAGNOSTICS.PP.SH "BUGS".PP.SH FILES.PP~/.espscom \- the default ESPS common file..SH "SEE ALSO".PP\fIgetsym\fP(3\-\s-1ESPS\s+1), \fIgetsymdef\fP(3\-\s-1ESPS\s+1),\fIputsym\fP(3\-\s-1ESPS\s+1), .br\fIfputsym\fP(3\-\s-1ESPS\s+1),\fIsymtype\fP(3\-\s-1ESPS\s+1), \fIsymsize\fP(3\-\s-1ESPS\s+1),.br\fIsymlist\fP(3\-\s-1ESPS\s+1), \fIsymdefinite\fP(3\-\s-1ESPS\s+1),\fIsymchoices\fP(3\-\s-1ESPS\s+1), \fIsymrange\fP(3\-\s-1ESPS\s+1),\fIsymprompt\fP(3\-\s-1ESPS\s+1), \fIsymerr_exit\fP(3\-\s-1ESPS\s+1), \fIfind_esps_file\fP(3\-\s-1ESPS\s+1), \fIespsenv\fP(1\-\s-1ESPS\s+1).SH "REFERENCES"[1] ETM-S-86-12:jtb, Parameter Files in the Speech Processing System.SH "AUTHOR"Joe Buck, Man page by Ajaipal S. Virdy; modifications by Alan Parkerand John Shore
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -