~ubuntu-branches/ubuntu/utopic/sphinxtrain/utopic

« back to all changes in this revision

Viewing changes to src/programs/init_gau/parse_cmd_ln.c

  • Committer: Package Import Robot
  • Author(s): Samuel Thibault
  • Date: 2013-01-02 04:10:21 UTC
  • Revision ID: package-import@ubuntu.com-20130102041021-ynsizmz33fx02hea
Tags: upstream-1.0.8
ImportĀ upstreamĀ versionĀ 1.0.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ====================================================================
 
2
 * Copyright (c) 1995-2000 Carnegie Mellon University.  All rights 
 
3
 * reserved.
 
4
 *
 
5
 * Redistribution and use in source and binary forms, with or without
 
6
 * modification, are permitted provided that the following conditions
 
7
 * are met:
 
8
 *
 
9
 * 1. Redistributions of source code must retain the above copyright
 
10
 *    notice, this list of conditions and the following disclaimer. 
 
11
 *
 
12
 * 2. Redistributions in binary form must reproduce the above copyright
 
13
 *    notice, this list of conditions and the following disclaimer in
 
14
 *    the documentation and/or other materials provided with the
 
15
 *    distribution.
 
16
 *
 
17
 * This work was supported in part by funding from the Defense Advanced 
 
18
 * Research Projects Agency and the National Science Foundation of the 
 
19
 * United States of America, and the CMU Sphinx Speech Consortium.
 
20
 *
 
21
 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 
 
22
 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
 
23
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
24
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
 
25
 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
26
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
 
27
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 
28
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
 
29
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 
30
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 
31
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
32
 *
 
33
 * ====================================================================
 
34
 *
 
35
 */
 
36
/*********************************************************************
 
37
 *
 
38
 * File: parse_cmd_ln.c
 
39
 * 
 
40
 * Description: 
 
41
 *      These routines define and parse the command line for init_gau.
 
42
 *
 
43
 * Author: 
 
44
 *      Eric H. Thayer (eht@cs.cmu.edu)
 
45
 *********************************************************************/
 
46
 
 
47
#include "parse_cmd_ln.h"
 
48
 
 
49
#include <sphinxbase/cmd_ln.h>
 
50
#include <sphinxbase/feat.h>
 
51
#include <s3/s3.h>
 
52
 
 
53
#include <sys_compat/misc.h>
 
54
 
 
55
#include <stdio.h>
 
56
#include <assert.h>
 
57
 
 
58
 
 
59
 
 
60
/* defines, parses and (partially) validates the arguments
 
61
   given on the command line */
 
62
 
 
63
int
 
64
parse_cmd_ln(int argc, char *argv[])
 
65
{
 
66
  uint32      isHelp;
 
67
  uint32      isExample;
 
68
 
 
69
  const char helpstr[] = 
 
70
"Description: (Copy from Rita's web manual) To initialize the means and variances, global values of \n\
 
71
 these parameters are first estimated and then copied into appropriate \n\
 
72
 positions in the parameter files. The global mean is computed using \n\
 
73
 all the vectors you have in your feature files. This is usually a \n\
 
74
 very large number, so the job is divided into many parts. At this \n\
 
75
 stage you tell the Sphinx how many parts you want it to divide this \n\
 
76
 operation into (depending on the computing facilities you have) and \n\
 
77
 the Sphinx \"accumulates\" or gathers up the vectors for each part \n\
 
78
 separately and writes it into an intermediate buffer on your \n\
 
79
 machine. The executable init_gau is used for this purpose.";
 
80
 
 
81
  const char examplestr[]=
 
82
"Example:\n\
 
83
\n\
 
84
init_gau -accumdir accumdir -ctlfn controlfn -part 1 -npart 1 -cepdir cepdir -feat 1s_12c_12d_3p_12dd -ceplen 13 ";
 
85
 
 
86
    static arg_t defn[] = {
 
87
        { "-help",
 
88
          ARG_BOOLEAN,
 
89
          "no",
 
90
          "Shows the usage of the tool"},
 
91
 
 
92
        { "-example",
 
93
          ARG_BOOLEAN,
 
94
          "no",
 
95
          "Shows example of how to use the tool"},
 
96
 
 
97
        { "-moddeffn",
 
98
          ARG_STRING,
 
99
          NULL,
 
100
          "Model definition file for the single density HMM's to initialize"},
 
101
        { "-ts2cbfn",
 
102
          ARG_STRING,
 
103
          NULL,
 
104
          "Tied-state-to-codebook mapping file"},
 
105
        { "-accumdir",
 
106
          ARG_STRING,
 
107
          NULL,
 
108
          "Where to write mean/var counts"},
 
109
        { "-meanfn",
 
110
          ARG_STRING,
 
111
          NULL,
 
112
          "Mean file for variance initialization"},
 
113
        { "-fullvar",
 
114
          ARG_BOOLEAN,
 
115
          "no",
 
116
          "Accumulate for full covariance matrices"},
 
117
        { "-ctlfn",
 
118
          ARG_STRING,
 
119
          NULL,
 
120
          "Control file of the training corpus"},
 
121
        { "-nskip",
 
122
          ARG_INT32,
 
123
          NULL,
 
124
          "# of lines to skip in the control file"},
 
125
        { "-runlen",
 
126
          ARG_INT32,
 
127
          NULL,
 
128
          "# of lines to process in the control file (after any skip)"},
 
129
        { "-part",
 
130
          ARG_INT32,
 
131
          NULL,
 
132
          "Identifies the corpus part number (range 1..NPART)" },
 
133
        { "-npart",
 
134
          ARG_INT32,
 
135
          NULL,
 
136
          "Partition the corpus into this many equal sized subsets" },
 
137
        { "-lsnfn",
 
138
          ARG_STRING,
 
139
          NULL,
 
140
          "All word transcripts for the training corpus (consistent order w/ -ctlfn!)"},
 
141
        { "-dictfn",
 
142
          ARG_STRING,
 
143
          NULL,
 
144
          "Dictionary for the content words"},
 
145
        { "-fdictfn",
 
146
          ARG_STRING,
 
147
          NULL,
 
148
          "Dictionary for the filler words"},
 
149
        { "-segdir",
 
150
          ARG_STRING,
 
151
          NULL,
 
152
          "Root directory of the training corpus state segmentation files."},
 
153
        { "-segext",
 
154
          ARG_STRING,
 
155
          "v8_seg",
 
156
          "Extension of the training corpus state segmentation files."},
 
157
 
 
158
        { "-scaleseg",
 
159
          ARG_BOOLEAN,
 
160
          "no",
 
161
          "Scale existing segmentation to fit new parameter stream length."},
 
162
        { "-cepdir",
 
163
          ARG_STRING,
 
164
          NULL,
 
165
          "Root directory of the training corpus cepstrum files."},
 
166
 
 
167
        { "-cepext",
 
168
          ARG_STRING,
 
169
          "mfc",
 
170
          "Extension of the training corpus cepstrum files."},
 
171
 
 
172
        cepstral_to_feature_command_line_macro(),
 
173
        {NULL, 0, NULL, NULL}
 
174
    };
 
175
 
 
176
    cmd_ln_parse(defn, argc, argv, 1);
 
177
 
 
178
    isHelp    = cmd_ln_int32("-help");
 
179
    isExample    = cmd_ln_int32("-example");
 
180
 
 
181
    if(isHelp){
 
182
      printf("%s\n\n",helpstr);
 
183
    }
 
184
 
 
185
    if(isExample){
 
186
      printf("%s\n\n",examplestr);
 
187
    }
 
188
 
 
189
    if(isHelp || isExample){
 
190
      E_INFO("User asked for help or example.\n");
 
191
      exit(0);
 
192
    }
 
193
 
 
194
    return 0;
 
195
}