42 #pragma warning (disable: 4996)
62 #define IO_SUCCESS (0)
67 #define NUM_COEFF "13"
72 #define DISPLAY_SIZE "10"
73 #define STR_MAX_INT "2147483647"
75 static arg_t arg[] = {
80 "Log file (default stdout/stderr)"},
84 "Number of coefficients in the feature vector."},
88 "Number of displayed coefficients."},
92 "Whether header is shown."},
96 "Whether description will be shown."},
100 "The beginning frame 0-based."},
104 "The ending frame."},
108 "Input feature file."},
112 int read_cep(
char const *file,
float ***cep,
int *nframes,
int numcep);
115 main(
int argc,
char *argv[])
118 int32 noframe, vsize, dsize, column;
119 int32 frm_begin, frm_end;
120 int is_header, is_describe;
135 E_FATAL(
"-i : Input vector size should be larger than 0.\n");
137 E_FATAL(
"-d : Column size should be larger than 0\n");
139 E_FATAL(
"-b : Beginning frame should be larger than 0\n");
143 if (frm_begin >= frm_end)
145 (
"Ending frame (-e) should be larger than beginning frame (-b).\n");
148 E_FATAL(
"Input file was not specified with (-f)\n");
150 if (read_cep(cepfile, &cep, &noframe, vsize) == IO_ERR)
156 column = (vsize > dsize) ? dsize : vsize;
157 frm_end = (frm_end > noframe) ? noframe : frm_end;
159 E_INFO(
"Displaying %d out of %d columns per frame\n", column, vsize);
160 E_INFO(
"Total %d frames\n\n", noframe);
167 printf(
"\n%6s",
"frame#:");
170 for (j = 0; j < column; ++j) {
171 printf(
"%3s%3d%s ",
"c[", j,
"]");
176 offset += frm_begin * vsize;
177 for (i = frm_begin; i < frm_end; ++i) {
181 for (j = 0; j < column; ++j)
182 printf(
"%7.3f ", z[offset + j]);
196 read_cep(
char const *file,
float ***cep,
int *numframes,
int cepsize)
209 if ((fp = fopen(file,
"rb")) == NULL) {
215 if (fread(&n_float,
sizeof(
int), 1, fp) != 1) {
222 if ((
int) (n_float *
sizeof(
float) + 4) != statbuf.st_size) {
226 if ((
int) (n *
sizeof(
float) + 4) != statbuf.st_size) {
227 E_ERROR(
"Header size field: %d(%08x); filesize: %d(%08x)\n",
228 n_float, n_float, (
int) statbuf.st_size,
229 (
int) statbuf.st_size);
238 E_ERROR(
"Header size field: %d\n", n_float);
244 n = n_float / cepsize;
245 if (n * cepsize != n_float) {
246 E_ERROR(
"Header size field: %d; not multiple of %d\n",
252 mfcbuf = (
float **)
ckd_calloc_2d(n, cepsize,
sizeof(float32));
255 n_float = n * cepsize;
256 if ((
int) fread(mfcbuf[0],
sizeof(
float), n_float, fp) != n_float) {
257 E_ERROR(
"Error reading mfc data from the file '%s'", file);
262 for (i = 0; i < n_float; i++)
263 SWAP_FLOAT32(&(mfcbuf[0][i]));
273 #if defined(_WIN32_WCE)
274 #pragma comment(linker,"/entry:mainWCRTStartup")
277 int wmain(int32 argc,
wchar_t *wargv[]) {
283 argv = malloc(argc*
sizeof(
char*));
284 for (i=0; i<argc; i++){
285 wlen = lstrlenW(wargv[i]);
286 len = wcstombs(NULL, wargv[i], wlen);
287 argv[i] = malloc(len+1);
288 wcstombs(argv[i], wargv[i], wlen);
292 return main(argc, argv);
Command-line and other configurationparsing and handling.
Miscellaneous useful string functions.
#define ckd_calloc_2d(d1, d2, sz)
Macro for ckd_calloc_2d
#define E_INFO
Print logging information to standard error stream.
Sphinx's memory allocation/deallocation routines.
SPHINXBASE_EXPORT int32 stat_retry(const char *file, struct stat *statbuf)
There is no bitstream decoder, because a stream abstraction is too slow.
Cross platform binary IO to process files in sphinx3 format.
#define ARG_STRING
String argument (optional).
Basic type definitions used in Sphinx.
#define E_FATAL_SYSTEM
Print error text; Call perror(""); exit(errno);.
SPHINXBASE_EXPORT void cmd_ln_appl_exit(void)
Finalization routine corresponding to cmd_ln_appl_enter().
Implementation of logging routines.
Argument definition structure.
SPHINXBASE_EXPORT void print_appl_info(char *appl_name)
This function prints the hostname, the directory, compile time and date .
Print hostname, directory name, compile time and date.
#define E_FATAL
Exit with non-zero status after error message.
#define E_ERROR
Print error message to standard error stream.
SPHINXBASE_EXPORT void ckd_free_2d(void *ptr)
Free a 2-D array (ptr) previously allocated by ckd_calloc_2d.
#define E_ERROR_SYSTEM
Print error text; Call perror("");.
#define cmd_ln_str(name)
Retrieve a string from the global command line.
SPHINXBASE_EXPORT void cmd_ln_appl_enter(int argc, char *argv[], char const *default_argfn, const arg_t *defn)
Old application initialization routine for Sphinx3 code.
file IO related operations.
#define cmd_ln_int32(name)
Retrieve a 32-bit integer from the global command line.