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

📄 fea_print.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 2 页
字号:
/* *  This program was created by Richard Goldhor of Sensimetrics Corp., *  by modifying a program (fea_deriv) originally created by Entropic *  Speech, Inc. * *  This material contains proprietary software of Entropic Speech, Inc.    *  Any reproduction, distribution, or publication without the prior	    *  written permission of Entropic Speech, Inc. is strictly prohibited. *  Any public distribution of copies of this work authorized in writing by *  Entropic Speech, Inc. must bear the notice			 * 								 *      "Copyright (c) 1990 Entropic Speech, Inc.; All rights reserved." * * 				 *  Module Name:  fea_print * *  Written By:  Rich Goldhor * 	 *  Checked By: John Shore * *  Purpose:  print FEA FILE records in a convenient format * *  Secrets:  Don't I wish *   */#ifndef lint    static char *sccs_id = "@(#)fea_print.c	1.3	8/31/95	ESI";#endif#define VERSION "1.3"#define DATE "8/31/95"#include <stdio.h>#include <ctype.h>#include <esps/esps.h>#include <esps/unix.h>#include <esps/fea.h>#define SYNTAX \USAGE("fea_print [-r range] [-x debug-level] [-l layout] layoutfile infile.fea")#define REALLOC(typ,num,var) { \    if ((var) == NULL) \	(var) = (typ *) malloc((unsigned) (num) * sizeof(typ)); \    else (var) = (typ *) realloc((char *) (var), \				    (unsigned) (num) * sizeof(typ)); \    spsassert((var), "can't allocate memory."); \}#define Fflush (void) fflush#define	MAXSTRLEN	(1024)	/* Max chars in various strings. */#define	MAXPRINTVARS	(100)	/* Max # of variables to print per record. */extern  int	optind;extern	char	*optarg;/* *  E S P S *   R O U T I N E S *    R E F E R E N C E D */char	*get_cmd_line();char	*get_deriv_vec();int	lin_search();void	lrange_switch();char	*savestring();char    *fea_decode();char	*ProgName = "fea_print";int	debug_level = 0;		/* global debug flag */main(argc, argv)    int     argc;    char    **argv;{    int		c;	    /* used for parsing command line */    FILE 	   *sfp, *inp;			/* file pointers */    struct header  *ih;				/* pointers to structure */    char	   *sfstr, *instr, *lstr;	/* string pointers */    char	layout[MAXSTRLEN+1];    char	header1[MAXSTRLEN+1],header2[MAXSTRLEN+1],header3[MAXSTRLEN+1];    struct fea_data	*i_fea_rec;	/* input ESPS Feature file record */    int		rflag = 0;		/* range flag */    char 	*range;			/* string to hold range */    char	*format;		/* current format string. */    long	s_rec; 		/* starting record position */    long	e_rec;		/* ending record position */    long	n_rec;  	/* record counter */    int		i = 0;		/* indexing variables */    int		j;    char	*s;    char	field_line[256],	    /* one line from input file */		*keyword,	    	    /* keyword */                *KeyString,	    	    /* keyword value. */		*new_field_name;    int		line_num;	/* current line number in field file */    int		keyword_found = NO;	    /* keyword found or not */    int		component_found = NO;	    /* component field found or not */    int		component_error = NO;	    /* component field error status */    int		n_deriv = 0;	    /*  total number of fields to derive */    int		DSize;			/* Size of current data type. */    /* int 	*derived_type = NULL;	*/    char        *field_names[MAXPRINTVARS]; /* field names */    int		data_type[MAXPRINTVARS];	/* data type array */    char	*formats[MAXPRINTVARS];	/* input format strings. */    char	***srcfields = NULL;	/* array of field names */    int		ppcnt = 0;    char	*printptrs[MAXPRINTVARS];/* print arg pointers. */    int		printtypes[MAXPRINTVARS];	/* print arg types. */    char	*printfrms[MAXPRINTVARS];	/* print format strings. */    char	*vvec[MAXPRINTVARS];	/* vector of ptrs to data storage. */    /*  int	type; */    long	length;		/* length of derived vector */    char	*vec;		/* vector containing results *//* *  B E G I N *   P R O G R A M *//* Initialization. */layout[0] = '\0';header1[0] = header2[0] = header3[0] = '\0';lstr = NULL;/* get options from command line and set various flags */    while ((c = getopt(argc, argv, "r:x:l:")) != EOF)	switch (c)	{	case 'r': 	    rflag++;	    range = optarg;	    break;	case 'x': 	    debug_level = atoi(optarg);	    break;	case 'l': 	    lstr = optarg;	    break;	default:	    SYNTAX;	}/* user must supply two file names: the stylefile and infile.fea */    if (argc - optind != 2)	SYNTAX;/* now open the style file */    sfstr = argv[optind++];    if	(strcmp(sfstr, "-") == 0)	    sfp = stdin;    else    TRYOPEN (argv[0], sfstr, "r", sfp);/* open input file or make input stdin; read header; check type */    instr = argv[optind++];    if	(sfp == stdin && strcmp(instr, "-") == 0)	    {	    Fprintf(stderr,		    "%s: style and feature files can't BOTH be from stdin!\n",		    ProgName);	    exit(1);	    }    instr = eopen(ProgName, instr, "r", FT_FEA, NONE, &ih, &inp);    if (debug_level > 0)        Fprintf (stderr,            "%s: style file = %s, infile = %s, layout = %s.\n",	    ProgName, sfstr, instr, lstr);/* make sure the given range (if there is one) exists in file1 */    s_rec = 1;    e_rec = LONG_MAX;    if (rflag)        lrange_switch (range, &s_rec, &e_rec, 1);    if (debug_level > 1)        Fprintf (stderr,              "%s: range of %s starts at %ld and ends at %ld.\n",	     ProgName, instr, s_rec, e_rec);    if (s_rec < 1) {        Fprintf (stderr, 	    "%s: start record less than 1.\n", ProgName);        exit(1);    }    if ( s_rec > e_rec ) {        Fprintf (stderr, 	     "%s: start record greater than end record.\n", ProgName);        exit(1);    }    (void) fea_skiprec (inp, s_rec - 1, ih);    if (debug_level > 0) {	Fprintf (stderr, "%s: skipped %ld records.\n",	ProgName, s_rec - 1);    }/* Now begin processing fieldfile */    keyword_found = NO;    line_num = 0;    while (fgets (field_line, 256, sfp) != NULL) {	++line_num;	if (debug_level > 15) {	    Fprintf (stderr, "%s: field_line: %s", ProgName, field_line);	    Fflush (stderr);	}	/* Is this a blank line?	 * If so, break out if we've collected our components,	 * otherwise just go get the next line.	 */	if (strcmp(field_line, "\n") == 0)	   if	(component_found == YES)		break;	   else continue;	if ((new_field_name = strchr (field_line, '=')) != NULL) {	    /* keyword found */	    keyword_found = YES;	    keyword = strtok (field_line, " =");	    component_found = NO;	    /* Find out which keyword this is. */	    if (strcmp (keyword, "layout") == 0) {	        KeyString = layout;	    }	    else if (strcmp (keyword, "header1") == 0) {	        KeyString = header1;	    }	    else if (strcmp (keyword, "header2") == 0) {	        KeyString = header2;	    }	    else if (strcmp (keyword, "header3") == 0) {	        KeyString = header3;	    }	    else {		Fprintf (stderr,		"%s: unknown keyword \"%s\" found on line %d.\n",		ProgName, keyword, line_num);		exit(1);	    }	    /*	     * new_field_name points to the equal sign, advance the pointer	     * by one element.	     * Also, remove the terminating new line character.	     */	    new_field_name++;	    new_field_name[ strlen(new_field_name) - 1 ] = '\0';	    strcpy(KeyString, new_field_name);	    if (debug_level > 10) {		Fprintf (stderr, "\n%s: keyword = %s, value = %s.\n",			 ProgName, keyword, KeyString);	        Fflush (stderr);	    }	    if	(KeyString == layout)		    {		    /* This is a layout name.		     * It's the right one if it equals lstr,		     * or if no layout string was specified.		     */		    if	(lstr == NULL || strcmp(lstr, KeyString) == 0)			    {			    }		    else    {			    keyword_found = NO;			    layout[0] = '\0';			    header1[0] = header2[0] = header3[0] = '\0';			    while (fgets(field_line, 80, sfp) != NULL)				    {				    ++line_num;				    if	(strcmp(field_line, "\n") == 0) break;				    }			    }		    }	} else {

⌨️ 快捷键说明

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