• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*---------------------------------------------------------------------------*
2  *  acc_basi.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 #include "simapi.h"
32 #include "portable.h"
33 
34 #ifdef SET_RCSID
35 static const char *rcsid = 0 ? (const char *) &rcsid :
36                            "$Id: acc_basi.c,v 1.4.6.11 2008/03/07 19:46:45 dahan Exp $";
37 #endif
38 
CA_AllocateAcoustic(void)39 CA_Acoustic *CA_AllocateAcoustic(void)
40 {
41   CA_Acoustic *hAcoust = NULL;
42 
43   TRY_CA_EXCEPT;
44 
45   hAcoust = (CA_Acoustic *) CALLOC_CLR(1,
46             sizeof(CA_Acoustic), "ca.hAcoust");
47   hAcoust->is_loaded = False;
48   hAcoust->pattern_setup_count = 0;
49   hAcoust->ca_rtti = CA_ACOUSTIC_SIGNATURE;
50   BEG_CATCH_CA_EXCEPT;
51   END_CATCH_CA_EXCEPT(hAcoust);
52   return (hAcoust);
53 }
54 
55 
CA_FreeAcoustic(CA_Acoustic * hAcoust)56 void CA_FreeAcoustic(CA_Acoustic *hAcoust)
57 {
58   TRY_CA_EXCEPT
59 
60   ASSERT(hAcoust);
61   FREE((char *) hAcoust);
62   return;
63 
64   BEG_CATCH_CA_EXCEPT
65   END_CATCH_CA_EXCEPT(hAcoust)
66 }
67 
CA_LoadAcousticSub(CA_Acoustic * hAcoust,char * subname,CA_AcoustInputParams * hAcoustInp)68 int CA_LoadAcousticSub(CA_Acoustic *hAcoust, char *subname, CA_AcoustInputParams *hAcoustInp)
69 {
70 //#ifndef _RTT
71 //  int     load_genome = 0;
72 //#endif
73 
74   if (hAcoustInp == 0)
75   {
76     /* SpeechWorks image format! */
77     hAcoust->swimodel = load_swimodel(subname);
78     hAcoust->is_loaded = ESR_TRUE;
79     return 1;
80   }
81   else
82   {
83     SERVICE_ERROR(FEATURE_NOT_SUPPORTED);
84     return 0;
85   }
86 }
87 
CA_UnloadAcoustic(CA_Acoustic * hAcoust)88 void CA_UnloadAcoustic(CA_Acoustic *hAcoust)
89 {
90   TRY_CA_EXCEPT
91   ASSERT(hAcoust);
92 
93   if (hAcoust->is_loaded == False)
94     SERVICE_ERROR(ACOUSTIC_NOT_LOADED);
95   if (hAcoust->swimodel)
96   {
97     free_swimodel(hAcoust->swimodel);
98     hAcoust->swimodel = 0;
99     hAcoust->is_loaded = False;
100     return;
101   }
102 	else
103 		SERVICE_ERROR(ACOUSTIC_NOT_LOADED);
104   return;
105 
106   BEG_CATCH_CA_EXCEPT
107   END_CATCH_CA_EXCEPT(hAcoust)
108 }
109