/** * <JA> * 第1パス:終了時に第1パスの結果を出力する(第1パス終了後、第2パスが * 始まる前に呼ばれる. 認識に失敗した場合は呼ばれない). * * @param seq [in] 第1パスの1位候補の単語列 * @param num [in] 上記の長さ * @param score [in] 1位の累積仮説スコア * @param LMscore [in] @a score のうち言語スコア * @param winfo [in] 単語辞書 * </JA> * <EN> * 1st pass: output final result of the 1st pass (will be called just after * the 1st pass ends and before the 2nd pass begins, and will not if search * failed). * * @param seq [in] word sequence of the best hypothesis at the 1st pass. * @param num [in] length of @a seq. * @param score [in] accumulated hypothesis score of @a seq. * @param LMscore [in] language score in @a score. * @param winfo [in] word dictionary. * </EN> */ static void result_pass1_final(Recog *recog, void *dummy) { int i; RecogProcess *r; boolean multi; if (out1_never) return; /* no output specified */ if (recog->process_list->next != NULL) multi = TRUE; else multi = FALSE; for(r=recog->process_list;r;r=r->next) { if (! r->live) continue; if (r->result.status < 0) continue; /* search already failed */ if (multi) { module_send(module_sd, "<RECOGOUT ID=\"SR%02d\" NAME=\"%s\">\n", r->config->id, r->config->name); } else { module_send(module_sd, "<RECOGOUT>\n"); } if (out1_score) { module_send(module_sd, " <SHYPO PASS=\"1\" SCORE=\"%f\">\n", r->result.pass1.score); } else { module_send(module_sd, " <SHYPO PASS=\"1\">\n", r->result.pass1.score); } for (i=0;i<r->result.pass1.word_num;i++) { module_send(module_sd, " <WHYPO"); msock_word_out1(r->result.pass1.word[i], r); module_send(module_sd, "/>\n"); } module_send(module_sd, " </SHYPO>\n</RECOGOUT>\n.\n"); } }
void result_pass1_current(Recog *recog, void *app_) { Application *app = (Application *)app_; int i; WORD_INFO *winfo; WORD_ID *seq; int num; RecogProcess *r; boolean multi; // std::cerr << "pass1 current" << std::endl; // app->setCvresultMsg("pass1 interrim"); if (recog->process_list->next != NULL) multi = TRUE; else multi = FALSE; for(r=recog->process_list;r;r=r->next) { if (! r->live) continue; if (! r->have_interim) continue; winfo = r->lm->winfo; seq = r->result.pass1.word; num = r->result.pass1.word_num; #if 0 if (multi) { fprintf(stderr, "<RECOGOUT ID=\"SR%02d\" NAME=\"%s\">\n", r->config->id, r->config->name); } else { fprintf(stderr, "<RECOGOUT>\n"); } fprintf(stderr, " <PHYPO PASS=\"1\" SCORE=\"%f\" FRAME=\"%d\" TIME=\"%ld\">\n", r->result.pass1.score, r->result.num_frame, time(NULL)); #endif #if 0 for (i=0;i<num;i++) { fprintf(stderr, " <WHYPO"); msock_word_out1(seq[i], r); fprintf(stderr, "/>\n"); } #else if (num == 3) { char *p = to_utf(winfo->woutput[seq[1]]);; if (p != NULL) { //char buf[1000]; double t = r->result.num_frame / 100.0; //sprintf(buf, "pass1: %s %5.3f", p , t); //std::string s(buf); //app->setCvresultMsg(s); app->onSpeechPass1Recognized(p, t); } } #endif #if 0 fprintf(stderr, " </PHYPO>\n</RECOGOUT>\n.\n"); #endif } }
/** * <JA> * 第1パス:途中結果を出力する(第1パスの一定時間ごとに呼ばれる) * * @param t [in] 現在の時間フレーム * @param seq [in] 現在の一位候補単語列 * @param num [in] @a seq の長さ * @param score [in] 上記のこれまでの累積スコア * @param LMscore [in] 上記の最後の単語の信頼度 * @param winfo [in] 単語辞書 * </JA> * <EN> * 1st pass: output current result while search (called periodically while 1st pass). * * @param t [in] current time frame * @param seq [in] current best word sequence at time @a t. * @param num [in] length of @a seq. * @param score [in] accumulated score of the current best sequence at @a t. * @param LMscore [in] confidence score of last word on the sequence * @param winfo [in] word dictionary * </EN> */ static void result_pass1_current(Recog *recog, void *dummy) { int i; WORD_INFO *winfo; WORD_ID *seq; int num; RecogProcess *r; boolean multi; if (out1_never) return; /* no output specified */ if (recog->process_list->next != NULL) multi = TRUE; else multi = FALSE; for(r=recog->process_list;r;r=r->next) { if (! r->live) continue; if (! r->have_interim) continue; winfo = r->lm->winfo; seq = r->result.pass1.word; num = r->result.pass1.word_num; if (multi) { module_send(module_sd, "<RECOGOUT ID=\"SR%02d\" NAME=\"%s\">\n", r->config->id, r->config->name); } else { module_send(module_sd, "<RECOGOUT>\n"); } if (out1_score) { module_send(module_sd, " <PHYPO PASS=\"1\" SCORE=\"%f\" FRAME=\"%d\" TIME=\"%ld\"/>\n", r->result.pass1.score, r->result.num_frame, time(NULL)); } else { module_send(module_sd, " <PHYPO PASS=\"1\" FRAME=\"%d\" TIME=\"%ld\"/>\n", r->result.num_frame, time(NULL)); } for (i=0;i<num;i++) { module_send(module_sd, " <WHYPO"); msock_word_out1(seq[i], r); module_send(module_sd, "/>\n"); } module_send(module_sd, " </PHYPO>\n</RECOGOUT>\n.\n"); } }