static int32 cmdline_parse (int argc, char *argv[])
{
    int32 i;
    char *logfile;
    
    E_INFO("Parsing command line:\n");
    for (i = 0; i < argc; i++) {
	if (argv[i][0] == '-')
	    printf ("\\\n\t");
	printf ("%s ", argv[i]);
    }
    printf ("\n\n");
    fflush (stdout);

    cmd_ln_parse (argc, argv);

    if (cmd_ln_validate() == FALSE) {
	E_FATAL("Unable to validate command line arguments\n");
    }

    logfp = NULL;
    if ((logfile = (char *)cmd_ln_access("-logfn")) != NULL) {
	if ((logfp = fopen(logfile, "w")) == NULL) {
	    E_ERROR("fopen(%s,w) failed; logging to stdout/stderr\n");
	} else {
	    orig_stdout = *stdout;	/* Hack!! To avoid hanging problem under Linux */
	    orig_stderr = *stderr;	/* Hack!! To avoid hanging problem under Linux */
	    *stdout = *logfp;
	    *stderr = *logfp;
	    
	    E_INFO("Command line:\n");
	    for (i = 0; i < argc; i++) {
		if (argv[i][0] == '-')
		    printf ("\\\n\t");
		printf ("%s ", argv[i]);
	    }
	    printf ("\n\n");
	    fflush (stdout);
	}
    }
    
    E_INFO("Configuration in effect:\n");
    cmd_ln_print_configuration();
    printf ("\n");
    
    return 0;
}
示例#2
0
int
parse_cmd_ln(int argc, char *argv[])
{
  uint32      isHelp;
  uint32      isExample;

#include "cmd_ln_defn.h"

    cmd_ln_define(defn);

    if (argc == 1) {
	cmd_ln_print_definitions();
	exit(1);
    }

    cmd_ln_parse(argc, argv);

    isHelp    = *(uint32 *) cmd_ln_access("-help");
    isExample    = *(uint32 *) cmd_ln_access("-example");


    if(isHelp){
      printf("%s\n\n",helpstr);
    }

    if(isExample){
      printf("%s\n\n",examplestr);
    }

    if(isHelp || isExample){
      E_INFO("User asked for help or example.\n");
      exit(1);
    }

    if(!isHelp && !isExample){
      if (cmd_ln_validate() == FALSE) {
        E_FATAL("Unable to validate command line arguments\n");
      }

      cmd_ln_print_configuration();
    }

    return 0;
}
示例#3
0
int32 parse_cmd_ln(int argc, char *argv[])
{
  uint32      isHelp;
  uint32      isExample;

  const char helpstr[]=
"Description: \n\
Convert s3 model definition file and s3 mixture weight file to a s2 senddump file.";

  const char examplestr[]=
"Example: \n\
\n\
mk_s2sendump -moddeffn s3mdef -mixwfn s3mixw -sendumpfn s2dir/sendump\n";

    static arg_def_t defn[] = {
	{ "-help",
	  CMD_LN_BOOLEAN,
	  CMD_LN_NO_VALIDATION,
	  "no",
	  "Shows the usage of the tool"},

	{ "-example",
	  CMD_LN_BOOLEAN,
	  CMD_LN_NO_VALIDATION,
	  "no",
	  "Shows example of how to use the tool"},

	{ "-moddeffn",
	      CMD_LN_STRING,
	      CMD_LN_NO_VALIDATION,
	      CMD_LN_NO_DEFAULT,
	      "The model definition file for the model inventory to train" },
	{ "-mixwfn",
	      CMD_LN_STRING,
	      CMD_LN_NO_VALIDATION,
	      CMD_LN_NO_DEFAULT,
	      "The mixture weight parameter file name"},
	{ "-sendumpfn",
	      CMD_LN_STRING,
	      CMD_LN_NO_VALIDATION,
	      CMD_LN_NO_DEFAULT,
	      "Output sendump file name"},
	{ "-pocketsphinx",
	  CMD_LN_BOOLEAN,
	  CMD_LN_NO_VALIDATION,
	  "no",
	  "Write a PocketSphinx-format senone dump file"},
	{ "-mwfloor",
	  CMD_LN_FLOAT32,
	  CMD_LN_NO_VALIDATION,
	  "0.00001",
	  "Mixing weight smoothing floor" },

	{ NULL,
	      CMD_LN_UNDEF,
	      CMD_LN_NO_VALIDATION,
	      CMD_LN_NO_DEFAULT,
	      NULL }
    };

    cmd_ln_define(defn);

    if (argc == 1) {
	cmd_ln_print_definitions();
	exit(1);
    }

    cmd_ln_parse(argc, argv);

    isHelp    = *(uint32 *) cmd_ln_access("-help");
    isExample    = *(uint32 *) cmd_ln_access("-example");


    if(isHelp){
      printf("%s\n\n",helpstr);
    }

    if(isExample){
      printf("%s\n\n",examplestr);
    }

    if(isHelp || isExample){
      E_INFO("User asked for help or example.\n");
      exit(1);
    }
    if(!isHelp && !isExample){
      cmd_ln_print_configuration();
    }

    return 0;
}
示例#4
0
int
parse_cmd_ln(int argc, char *argv[])
{
  uint32      isHelp;
  uint32      isExample;

  const char helpstr[]=
"Description : \n\
  Create a model definition file with tied state from model definition file without tied states. ";

  const char examplestr[]=
"Example: \n\
  tiestate -imoddeffn imdef -omoddeffn omdef -treedir trees -psetfn questions \n\
\n\
  This is an example of the input and output format, Find more details at, \n\
  http://www.speech.cs.cmu.edu/sphinxman";

    static arg_def_t defn[] = {
	{ "-help",
	  CMD_LN_BOOLEAN,
	  CMD_LN_NO_VALIDATION,
	  "no",
	  "Shows the usage of the tool"},

	{ "-example",
	  CMD_LN_BOOLEAN,
	  CMD_LN_NO_VALIDATION,
	  "no",
	  "Shows example of how to use the tool"},

	{ "-imoddeffn",
	  CMD_LN_STRING,
	  CMD_LN_NO_VALIDATION,
	  CMD_LN_NO_DEFAULT,
	  "Untied-state model definition file"},

	{ "-omoddeffn",
	  CMD_LN_STRING,
	  CMD_LN_NO_VALIDATION,
	  CMD_LN_NO_DEFAULT,
	  "Tied-state model definition file"},

	{ "-treedir",
	  CMD_LN_STRING,
	  CMD_LN_NO_VALIDATION,
	  CMD_LN_NO_DEFAULT,
	  "SPHINX-III tree directory containing pruned trees"},

	{ "-psetfn",
	  CMD_LN_STRING,
	  CMD_LN_NO_VALIDATION,
	  CMD_LN_NO_DEFAULT,
	  "Phone set definiton file" },

	{ "-allphones",
	  CMD_LN_BOOLEAN,
	  CMD_LN_NO_VALIDATION,
	  "no",
	  "Use a single tree for each state of all phones"},
	  
	{ NULL, CMD_LN_UNDEF, CMD_LN_NO_VALIDATION, CMD_LN_NO_DEFAULT, NULL }
    };

    cmd_ln_define(defn);

    if (argc == 1) {
	cmd_ln_print_definitions();
	exit(1);
    }

    cmd_ln_parse(argc, argv);

    if (cmd_ln_validate() == FALSE) {
	E_FATAL("Unable to validate command line arguments\n");
    }

    isHelp    = *(uint32 *) cmd_ln_access("-help");
    isExample    = *(uint32 *) cmd_ln_access("-example");


    if(isHelp){
      printf("%s\n\n",helpstr);
    }

    if(isExample){
      printf("%s\n\n",examplestr);
    }

    if(isHelp || isExample){
      E_INFO("User asked for help or example.\n");
      exit(1);
    }
    if(!isHelp && !isExample){
      cmd_ln_print_configuration();
    }

    return 0;
}
示例#5
0
int
parse_cmd_ln(int argc, char *argv[])
{
    uint32      isHelp;
    uint32      isExample;

    const char helpstr[] =
        "Description: \nThis program computes a mixture gaussian distribution for a set of \nspeech cepstral files for use with CDCN. The first mode is computed on only\nthe silence portions of the speech to comply with the requirements of the \nalgorithm.";

    const char examplestr[]=
        "Example: \n\
\n\
cdcn_stats -cepext mfc \n\
        -ctlfn stuff.ctl \n\
        -outfn output.cdcn.dist \n\
        -nmodes 32 \n\
        -noisewidth 1.5 \n\
        -tmpfn CDCN.tmp \n\
        -ceplen 13 \n\
        -stride 10 ";

    static arg_def_t defn[] = {
        {   "-help",
            CMD_LN_BOOLEAN,
            CMD_LN_NO_VALIDATION,
            "no",
            "Shows the usage of the tool"
        },

        {   "-example",
            CMD_LN_BOOLEAN,
            CMD_LN_NO_VALIDATION,
            "no",
            "Shows example of how to use the tool"
        },

        {   "-ctlfn",
            CMD_LN_STRING,
            CMD_LN_NO_VALIDATION,
            CMD_LN_NO_DEFAULT,
            "The control file name (enumerates utts in corpus)"
        },
        {   "-outfn",
            CMD_LN_STRING,
            CMD_LN_NO_VALIDATION,
            CMD_LN_NO_DEFAULT,
            "The output distribution file name"
        },
        {   "-cepdir",
            CMD_LN_STRING,
            CMD_LN_NO_VALIDATION,
            CMD_LN_NO_DEFAULT,
            "Root directory of the cepstrum files"
        },
        {   "-cepext",
            CMD_LN_STRING,
            CMD_LN_NO_VALIDATION,
            "mfc",
            "Extension of the cepstrum files"
        },

        {   "-maxframes",
            CMD_LN_INT32,
            CMD_LN_NO_VALIDATION,
            "-1",
            "Maximum number of frames to read (or -1 for unlimited)"
        },

        {   "-cbfn",
            CMD_LN_STRING,
            CMD_LN_NO_VALIDATION,
            CMD_LN_NO_DEFAULT,
            "A previous codebook to restart EM training from"
        },

        {   "-nmodes",
            CMD_LN_INT32,
            CMD_LN_NO_VALIDATION,
            "32",
            "# of Gaussians to train"
        },
        {   "-noisewidth",
            CMD_LN_FLOAT32,
            CMD_LN_NO_VALIDATION,
            "1.5",
            "Width of noise band"
        },
        {   "-ceplen",
            CMD_LN_INT32,
            CMD_LN_NO_VALIDATION,
            "13",
            "# of coefficients per cepstrum frame"
        },
        {   "-stride",
            CMD_LN_INT32,
            CMD_LN_NO_VALIDATION,
            "1",
            "Take every -stride'th frame when computing distribution"
        },

        {   "-vqiter",
            CMD_LN_INT32,
            CMD_LN_NO_VALIDATION,
            "5",
            "Max # of interations of VQ to get initial codebook"
        },
        {   "-vqthresh",
            CMD_LN_FLOAT32,
            CMD_LN_NO_VALIDATION,
            "1e-6",
            "Convergence ratio for VQ"
        },
        {   "-emiter",
            CMD_LN_INT32,
            CMD_LN_NO_VALIDATION,
            "10",
            "# of interations of EM to estimate distributions"
        },
        {   "-emthresh",
            CMD_LN_FLOAT32,
            CMD_LN_NO_VALIDATION,
            "1e-6",
            "Convergence ratio for EM"
        },

        {   "-tmpfn",
            CMD_LN_STRING,
            CMD_LN_NO_VALIDATION,
            "CDCN.DIST.TEMP",
            "The temporary file name"
        },

        { NULL, CMD_LN_UNDEF, CMD_LN_NO_VALIDATION, CMD_LN_NO_DEFAULT, NULL }
    };

    cmd_ln_define(defn);

    if (argc == 1) {
        cmd_ln_print_definitions();
        exit(1);
    }

    cmd_ln_parse(argc, argv);

    if (cmd_ln_validate() == FALSE) {
        E_FATAL("Unable to validate command line arguments\n");
    }

    isHelp    = *(uint32 *) cmd_ln_access("-help");
    isExample    = *(uint32 *) cmd_ln_access("-example");


    if(isHelp) {
        printf("%s\n\n",helpstr);
    }

    if(isExample) {
        printf("%s\n\n",examplestr);
    }

    if(isHelp || isExample) {
        E_INFO("User asked for help or example.\n");
        exit(1);
    }
    if(!isHelp && !isExample) {
        cmd_ln_print_configuration();
    }


    return 0;
}