• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*---------------------------------------------------------------------------*
2  *  utt_data.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 "../clib/fpi_tgt.inl"
35 
36 static const char utt_data[] = "$Id: utt_data.c,v 1.8.6.6 2007/10/15 18:06:24 dahan Exp $";
37 
38 
CA_SeekStartOfUtterance(CA_Utterance * hUtt)39 int CA_SeekStartOfUtterance(CA_Utterance *hUtt)
40 {
41   TRY_CA_EXCEPT
42   int gap = 0;
43 
44   ASSERT(hUtt);
45 
46   if (utterance_started(&hUtt->data))
47   {
48     if ((gap = getBlockGap(hUtt->data.gen_utt.frame)) > 0)
49       (void) setRECframePtr(hUtt->data.gen_utt.frame, gap, 1);
50     if (hUtt->data.gen_utt.frame->holdOffPeriod > 0)
51       setRECframePtr(hUtt->data.gen_utt.frame, -MIN(hUtt->data.gen_utt.frame->holdOffPeriod, getFrameGap(hUtt->data.gen_utt.frame)), 1);
52     while (!(rec_frame_voicing_status(hUtt->data.gen_utt.frame) & VOICE_BIT))
53     {
54       incRECframePtr(hUtt->data.gen_utt.frame);
55       if (getFrameGap(hUtt->data.gen_utt.frame) == 0)
56         break;
57     }
58     setRECframePtr(hUtt->data.gen_utt.frame, MIN(hUtt->data.gen_utt.start_windback, getBlockGap(hUtt->data.gen_utt.frame)), 1);
59 #ifdef SREC_ENGINE_VERBOSE_LOGGING
60     PLogMessage("L:  Frame start rewound to %d (%d, %d)", hUtt->data.gen_utt.frame->pullTime,
61                 hUtt->data.gen_utt.start_windback,
62                 getBlockGap(hUtt->data.gen_utt.frame));
63 #endif
64     hUtt->data.gen_utt.last_push = NULL;
65     return hUtt->data.gen_utt.start_windback;
66   }
67   else
68     return 0;
69 
70   BEG_CATCH_CA_EXCEPT
71   END_CATCH_CA_EXCEPT(hUtt)
72 }
73 
CA_GetUnprocessedFramesInUtterance(CA_Utterance * hUtt)74 int CA_GetUnprocessedFramesInUtterance(CA_Utterance *hUtt)
75 {
76   TRY_CA_EXCEPT
77   ASSERT(hUtt);
78   return (getFrameGap(hUtt->data.gen_utt.frame));
79 
80   BEG_CATCH_CA_EXCEPT
81   END_CATCH_CA_EXCEPT(hUtt)
82 }
83 
84 
85