00001
00017
00018
00019
00020
00021
00022
00023
00024 #include <julius.h>
00025
00026
00027
00028
00039 static void
00040 ttyout_status_process_online()
00041 {
00042
00043 }
00054 static void
00055 ttyout_status_process_offline()
00056 {
00057
00058 }
00059
00060
00061
00062
00063 static int wst;
00064
00075 static void
00076 ttyout_pass1_begin()
00077 {
00078 wst = 0;
00079
00080 j_printerr("\r \r");
00081 }
00082
00083
00106 static void
00107 ttyout_pass1_current(int t, WORD_ID *seq, int num, LOGPROB score, LOGPROB LMscore, WORD_INFO *winfo)
00108 {
00109 int i,bgn;
00110 int len;
00111
00112
00113 j_printf("\r");
00114
00115 len = 0;
00116 if (wst == 0) {
00117 len += 11;
00118 j_printf("pass1_best:");
00119 }
00120
00121 bgn = wst;
00122 for (i=bgn;i<num;i++) {
00123 len += strlen(winfo->woutput[seq[i]]) + 1;
00124 if (len > FILLWIDTH) {
00125 wst = i;
00126 j_printf("\n");
00127 len = 0;
00128 }
00129 j_printf(" %s",winfo->woutput[seq[i]]);
00130 }
00131
00132 j_flushprint();
00133 }
00134
00158 static void
00159 ttyout_pass1_final(WORD_ID *seq, int num, LOGPROB score, LOGPROB LMscore, WORD_INFO *winfo)
00160 {
00161 int i,j;
00162 static char buf[MAX_HMMNAME_LEN];
00163
00164
00165 j_printf("\n");
00166 j_printf("pass1_best:");
00167 for (i=0;i<num;i++) {
00168 j_printf(" %s",winfo->woutput[seq[i]]);
00169 }
00170 j_printf("\n");
00171
00172 if (verbose_flag) {
00173
00174 j_printf("pass1_best_wordseq:");
00175 for (i=0;i<num;i++) {
00176 j_printf(" %s",winfo->wname[seq[i]]);
00177 }
00178 j_printf("\n");
00179
00180 j_printf("pass1_best_phonemeseq:");
00181 for (i=0;i<num;i++) {
00182 for (j=0;j<winfo->wlen[seq[i]];j++) {
00183 center_name(winfo->wseq[seq[i]][j]->name, buf);
00184 j_printf(" %s", buf);
00185 }
00186 if (i < num-1) j_printf(" |");
00187 }
00188 j_printf("\n");
00189 if (debug2_flag) {
00190
00191 j_printf("pass1_best_HMMseq_logical:");
00192 for (i=0;i<num;i++) {
00193 for (j=0;j<winfo->wlen[seq[i]];j++) {
00194 j_printf(" %s", winfo->wseq[seq[i]][j]->name);
00195 }
00196 if (i < num-1) j_printf(" |");
00197 }
00198 j_printf("\n");
00199 }
00200 }
00201
00202 j_printf("pass1_best_score: %f", score);
00203 #ifdef USE_NGRAM
00204 if (separate_score_flag) {
00205 j_printf(" (AM: %f LM: %f)", score-LMscore, LMscore);
00206 }
00207 #endif
00208 j_printf("\n");
00209 }
00210
00221 static void
00222 ttyout_pass1_end()
00223 {
00224
00225 j_printf("\n");
00226 }
00227
00228
00229
00230
00245 static void
00246 put_hypo_woutput(NODE *hypo, WORD_INFO *winfo)
00247 {
00248 int i,w;
00249
00250 if (hypo != NULL) {
00251 for (i=hypo->seqnum-1;i>=0;i--) {
00252 w = hypo->seq[i];
00253 j_printf(" %s",winfo->woutput[w]);
00254 }
00255 }
00256 j_printf("\n");
00257 }
00258
00273 static void
00274 put_hypo_wname(NODE *hypo, WORD_INFO *winfo)
00275 {
00276 int i,w;
00277
00278 if (hypo != NULL) {
00279 for (i=hypo->seqnum-1;i>=0;i--) {
00280 w = hypo->seq[i];
00281 j_printf(" %s",winfo->wname[w]);
00282 }
00283 }
00284 j_printf("\n");
00285 }
00286
00301 static void
00302 put_hypo_phoneme(NODE *hypo, WORD_INFO *winfo)
00303 {
00304 int i,j,w;
00305 static char buf[MAX_HMMNAME_LEN];
00306
00307 if (hypo != NULL) {
00308 for (i=hypo->seqnum-1;i>=0;i--) {
00309 w = hypo->seq[i];
00310 for (j=0;j<winfo->wlen[w];j++) {
00311 center_name(winfo->wseq[w][j]->name, buf);
00312 j_printf(" %s", buf);
00313 }
00314 if (i > 0) j_printf(" |");
00315 }
00316 }
00317 j_printf("\n");
00318 }
00319 #ifdef CONFIDENCE_MEASURE
00320
00332 #ifdef CM_MULTIPLE_ALPHA
00333 static void
00334 put_hypo_cmscore(NODE *hypo, int id)
00335 {
00336 int i;
00337 int j;
00338
00339 if (hypo != NULL) {
00340 for (i=hypo->seqnum-1;i>=0;i--) {
00341 j_printf(" %5.3f", hypo->cmscore[i][id]);
00342 }
00343 }
00344 j_printf("\n");
00345 }
00346 #else
00347 static void
00348 put_hypo_cmscore(NODE *hypo)
00349 {
00350 int i;
00351
00352 if (hypo != NULL) {
00353 for (i=hypo->seqnum-1;i>=0;i--) {
00354 j_printf(" %5.3f", hypo->cmscore[i]);
00355 }
00356 }
00357 j_printf("\n");
00358 }
00359 #endif
00360 #endif
00361
00378 static void
00379 ttyout_pass2(NODE *hypo, int rank, WORD_INFO *winfo)
00380 {
00381 char ec[5] = {0x1b, '[', '1', 'm', 0};
00382
00383 if (debug2_flag) {
00384 j_printf("\n%s",ec);
00385 }
00386 j_printf("sentence%d:",rank);
00387 put_hypo_woutput(hypo, winfo);
00388 if (verbose_flag) {
00389 j_printf("wseq%d:",rank);
00390 put_hypo_wname(hypo, winfo);
00391 j_printf("phseq%d:", rank);
00392 put_hypo_phoneme(hypo, winfo);
00393 #ifdef CONFIDENCE_MEASURE
00394 #ifdef CM_MULTIPLE_ALPHA
00395 {
00396 int i;
00397 for(i=0;i<cm_alpha_num;i++) {
00398 j_printf("cmscore%d[%f]:", rank, cm_alpha_bgn + i * cm_alpha_step);
00399 put_hypo_cmscore(hypo, i);
00400 }
00401 }
00402 #else
00403 j_printf("cmscore%d:", rank);
00404 put_hypo_cmscore(hypo);
00405 #endif
00406 #endif
00407 }
00408 if (debug2_flag) {
00409 ec[2] = '0';
00410 j_printf("%s\n",ec);
00411 }
00412 if (verbose_flag) {
00413 j_printf("score%d: %f",rank, (hypo != NULL) ? hypo->score : LOG_ZERO);
00414 #ifdef USE_NGRAM
00415 if (separate_score_flag) {
00416 if (hypo == NULL) {
00417 j_printf(" (AM: %f LM: %f)", LOG_ZERO, LOG_ZERO);
00418 } else {
00419 j_printf(" (AM: %f LM: %f)", hypo->score - hypo->totallscore, hypo->totallscore);
00420 }
00421 }
00422 #endif
00423 j_printf("\n");
00424 #ifdef USE_DFA
00425
00426
00427 if (multigram_get_all_num() > 1) {
00428 j_printf("grammar%d: %d\n", rank, multigram_get_gram_from_category(winfo->wton[hypo->seq[0]]));
00429 }
00430 #endif
00431 }
00432 j_flushprint();
00433 }
00434
00447 static void
00448 ttyout_pass2_begin()
00449 {
00450
00451 }
00452
00463 static void
00464 ttyout_pass2_end()
00465 {
00466 #ifdef SP_BREAK_CURRENT_FRAME
00467 if (rest_param != NULL) {
00468 if (verbose_flag) {
00469 j_printf("Segmented by short pause, continue to next...\n");
00470 } else {
00471 j_printf("-->\n");
00472 }
00473 }
00474 j_flushprint();
00475 #endif
00476 }
00477
00478 #ifdef GRAPHOUT
00479
00480
00481
00482
00483 #define TEXTWIDTH 70
00484
00499 static void
00500 ttyout_graph(WordGraph *root, WORD_INFO *winfo)
00501 {
00502 WordGraph *wg;
00503 int k, tw1, tw2, i;
00504
00505 j_printf("-------------------------- begin wordgraph show -------------------------\n");
00506 for(wg=root;wg;wg=wg->next) {
00507 tw1 = (TEXTWIDTH * wg->lefttime) / peseqlen;
00508 tw2 = (TEXTWIDTH * wg->righttime) / peseqlen;
00509 j_printf("%4d:", wg->id);
00510 for(i=0;i<tw1;i++) j_printf(" ");
00511 j_printf(" %s\n", wchmm->winfo->woutput[wg->wid]);
00512 j_printf("%4d:", wg->lefttime);
00513 for(i=0;i<tw1;i++) j_printf(" ");
00514 j_printf("|");
00515 for(i=tw1+1;i<tw2;i++) j_printf("-");
00516 j_printf("|\n");
00517 }
00518 j_printf("-------------------------- end wordgraph show ---------------------------\n");
00519 }
00520
00521 #endif
00522
00523
00524
00525
00538 static void
00539 ttyout_pass2_failed(WORD_INFO *winfo)
00540 {
00541 j_printf("second pass failed, the first pass was:\n");
00542 ttyout_pass2((NODE *)NULL, 0, winfo);
00543 }
00544
00559 static void
00560 ttyout_rejected(const char *s)
00561 {
00562 j_printf("input rejected: %s\n", s);
00563 }
00564
00565
00566
00567
00578 void
00579 ttyout_status_recready()
00580 {
00581 if (speech_input == SP_MIC || speech_input == SP_NETAUDIO) {
00582
00583 j_printerr("<<< please speak >>>");
00584 }
00585 }
00596 void
00597 ttyout_status_recstart()
00598 {
00599
00600 }
00611 void
00612 ttyout_status_recend()
00613 {
00614
00615 }
00628 void
00629 ttyout_status_param(HTK_Param *param)
00630 {
00631 if (verbose_flag) {
00632 put_param_info(param);
00633 }
00634 }
00635
00636
00637
00638
00649 void
00650 setup_result_tty()
00651 {
00652 status_process_online = ttyout_status_process_online;
00653 status_process_offline = ttyout_status_process_offline;
00654 status_recready = ttyout_status_recready;
00655 status_recstart = ttyout_status_recstart;
00656 status_recend = ttyout_status_recend;
00657 status_param = ttyout_status_param;
00658 result_pass1_begin = ttyout_pass1_begin;
00659 result_pass1_current = ttyout_pass1_current;
00660 result_pass1_final = ttyout_pass1_final;
00661 result_pass1_end = ttyout_pass1_end;
00662 result_pass2_begin = ttyout_pass2_begin;
00663 result_pass2 = ttyout_pass2;
00664 result_pass2_end = ttyout_pass2_end;
00665 result_pass2_failed = ttyout_pass2_failed;
00666 result_rejected = ttyout_rejected;
00667 result_gmm = ttyout_gmm;
00668 #ifdef GRAPHOUT
00669 result_graph = ttyout_graph;
00670 #endif
00671 }