00001
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "app.h"
00027
00028 extern boolean outfile_enabled;
00029
00030 void
00031 main_recognition_stream_loop(Recog *recog)
00032 {
00033 Jconf *jconf;
00034 int file_counter;
00035 int ret;
00036 FILE *mfclist;
00037 static char speechfilename[MAXPATHLEN];
00038
00039 jconf = recog->jconf;
00040
00041
00042 file_counter = 0;
00043
00044 if (jconf->input.speech_input == SP_MFCFILE) {
00045 if (jconf->input.inputlist_filename != NULL) {
00046
00047 if ((mfclist = fopen(jconf->input.inputlist_filename, "r")) == NULL) {
00048 fprintf(stderr, "Error: cannot open inputlist \"%s\"\n", jconf->input.inputlist_filename);
00049 return;
00050 }
00051 }
00052 }
00053
00054
00056
00057 for (;;) {
00058
00059 printf("\n");
00060 if (verbose_flag) printf("------\n");
00061 fflush(stdout);
00062
00063
00064
00065
00066 if (jconf->input.speech_input == SP_MFCFILE) {
00067
00068 VERMES("### read analyzed parameter\n");
00069 if (jconf->input.inputlist_filename != NULL) {
00070 do {
00071 if (getl_fp(speechfilename, MAXPATHLEN, mfclist) == NULL) {
00072 fclose(mfclist);
00073 fprintf(stderr, "%d files processed\n", file_counter);
00074 #ifdef REPORT_MEMORY_USAGE
00075 print_mem();
00076 #endif
00077 return;
00078 }
00079 } while (speechfilename[0] == '\0' || speechfilename[0] == '#');
00080 } else {
00081 if (get_line_from_stdin(speechfilename, MAXPATHLEN, "enter MFCC filename->") == NULL) {
00082 fprintf(stderr, "%d files processed\n", file_counter);
00083 #ifdef REPORT_MEMORY_USAGE
00084 print_mem();
00085 #endif
00086 return;
00087 }
00088 }
00089 if (verbose_flag) printf("\ninput MFCC file: %s\n", speechfilename);
00090 if (outfile_enabled) outfile_set_fname(speechfilename);
00091
00092
00093 ret = j_open_stream(recog, speechfilename);
00094 switch(ret) {
00095 case 0:
00096 break;
00097 case -1:
00098
00099 continue;
00100 case -2:
00101 return;
00102 }
00103
00104
00105 do {
00106
00107 ret = j_recognize_stream(recog);
00108
00109 switch(ret) {
00110 case 1:
00111
00112
00113
00114 break;
00115 case 0:
00116
00117 break;
00118 case -1:
00119 return;
00120 }
00121 } while (ret == 1);
00122
00123
00124 file_counter++;
00125
00126 } else {
00127
00128 VERMES("### read waveform input\n");
00129
00130 ret = j_open_stream(recog, NULL);
00131 switch(ret) {
00132 case 0:
00133 break;
00134 case -1:
00135
00136 continue;
00137 case -2:
00138 if (jconf->input.speech_input == SP_RAWFILE) {
00139 fprintf(stderr, "%d files processed\n", file_counter);
00140 } else if (jconf->input.speech_input == SP_STDIN) {
00141 fprintf(stderr, "reached end of input on stdin\n");
00142 } else {
00143 fprintf(stderr, "failed to begin input stream\n");
00144 }
00145 return;
00146 }
00147 if (outfile_enabled) {
00148 outfile_set_fname(j_get_current_filename());
00149 }
00150
00151 ret = j_recognize_stream(recog);
00152
00153
00154
00155
00156
00157
00158
00159 if (ret == -1) {
00160 return;
00161 }
00162
00163
00164
00165 if (jconf->input.speech_input == SP_RAWFILE) {
00166 file_counter++;
00167 }
00168 }
00169 }
00170
00171 }