• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*---------------------------------------------------------------------------*
2  *  rec_resu.c  *
3  *                                                                           *
4  *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
5  *                                                                           *
6  *  Licensed under the Apache License, Version 2.0 (the 'License');          *
7  *  you may not use this file except in compliance with the License.         *
8  *                                                                           *
9  *  You may obtain a copy of the License at                                  *
10  *      http://www.apache.org/licenses/LICENSE-2.0                           *
11  *                                                                           *
12  *  Unless required by applicable law or agreed to in writing, software      *
13  *  distributed under the License is distributed on an 'AS IS' BASIS,        *
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15  *  See the License for the specific language governing permissions and      *
16  *  limitations under the License.                                           *
17  *                                                                           *
18  *---------------------------------------------------------------------------*/
19 
20 #include <stdlib.h>
21 #include <string.h>
22 #ifndef _RTT
23 #include <stdio.h>
24 #endif
25 
26 #ifdef unix
27 #include <unistd.h>
28 #endif
29 #include <assert.h>
30 
31 
32 #include "simapi.h"
33 #include "portable.h"
34 #include "word_lattice.h"
35 
36 #define USE_PREDICT   0
37 #define FRAME_KNEE    100
38 #define FRAME_SCALE   13  /* 23 for c32 */
39 #define JUNK_SCALE    0.87  /* 0.8 for c32 */
40 
41 static const char rec_resu[] = "$Id: rec_resu.c,v 1.7.6.7 2007/10/15 18:06:24 dahan Exp $";
42 
CA_FullResultScore(CA_Recog * hRecog,int * score,int do_incsil)43 int CA_FullResultScore(CA_Recog *hRecog, int *score, int do_incsil)
44 {
45   bigcostdata cost;
46 
47   srec_get_top_choice_score(hRecog->recm, &cost, do_incsil);
48 
49   *score = cost;
50   return 0;
51 }
52 
53 
CA_FullResultLabel(CA_Recog * hRecog,char * label,int len)54 int CA_FullResultLabel(CA_Recog *hRecog, char *label, int len)
55 {
56   int rc;
57   TRY_CA_EXCEPT
58 
59   rc = srec_get_top_choice_transcription(hRecog->recm, label, len, 1);
60   if (rc != 0)
61     return REJECT_RESULT;
62 
63   return FULL_RESULT;
64   BEG_CATCH_CA_EXCEPT
65   END_CATCH_CA_EXCEPT(hRecog)
66 }
67 
CA_ResultStripSlotMarkers(char * text)68 ESR_ReturnCode CA_ResultStripSlotMarkers(char *text)
69 {
70   srec_result_strip_slot_markers(text);
71   return ESR_SUCCESS;
72 }
73 
CA_GetRecogID(CA_Recog * hRecog,int * id)74 ESR_ReturnCode CA_GetRecogID(CA_Recog *hRecog, int *id)
75 {
76   srec_get_bestcost_recog_id(hRecog->recm, id);
77   return ESR_SUCCESS;
78 }
79 
CA_FullResultWordIDs(CA_Recog * hRecog,wordID * wordIDs,size_t * len)80 ESR_ReturnCode CA_FullResultWordIDs(CA_Recog *hRecog, wordID *wordIDs, size_t* len)
81 {
82   return srec_get_top_choice_wordIDs(hRecog->recm, wordIDs, len);
83 }
84 
CA_ClearResults(CA_Recog * hRecog)85 void CA_ClearResults(CA_Recog *hRecog)
86 {
87   TRY_CA_EXCEPT
88   ASSERT(hRecog);
89 
90   srec_clear_results(hRecog->recm);
91   return;
92 
93   BEG_CATCH_CA_EXCEPT
94   END_CATCH_CA_EXCEPT(hRecog)
95 }
96 
97 
CA_RecognitionHasResults(CA_Recog * hRecog)98 int CA_RecognitionHasResults(CA_Recog *hRecog)
99 {
100   TRY_CA_EXCEPT
101   ASSERT(hRecog);
102 
103   if (!srec_has_results(hRecog->recm))
104     return False;
105   else
106     return True;
107 }
108 
CA_IsEndOfUtteranceByResults(CA_Recog * hRecog)109 int CA_IsEndOfUtteranceByResults(CA_Recog *hRecog)
110 {
111   TRY_CA_EXCEPT
112   ASSERT(hRecog);
113   return multi_srec_get_eos_status(hRecog->recm);
114 
115   BEG_CATCH_CA_EXCEPT
116   END_CATCH_CA_EXCEPT(hRecog)
117 }
118