1 /*---------------------------------------------------------------------------* 2 * AcousticStateImpl.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 "SR_AcousticState.h" 21 #include "SR_AcousticStateImpl.h" 22 #include "plog.h" 23 #include "pmemory.h" 24 25 #define MTAG __FILE__ 26 27 ESR_ReturnCode SR_AcousticStateCreateImpl(SR_Recognizer* recognizer) 28 { 29 SR_AcousticStateImpl* impl; 30 SR_RecognizerImpl* recogImpl = (SR_RecognizerImpl*) recognizer; 31 32 if (recogImpl == NULL) 33 { 34 PLogError(L("ESR_INVALID_ARGUMENT")); 35 return ESR_INVALID_ARGUMENT; 36 } 37 impl = NEW(SR_AcousticStateImpl, MTAG); 38 if (impl == NULL) 39 { 40 PLogError(L("ESR_OUT_OF_MEMORY")); 41 return ESR_OUT_OF_MEMORY; 42 } 43 44 impl->Interface.load = &SR_AcousticStateLoadImpl; 45 impl->Interface.save = &SR_AcousticStateSaveImpl; 46 impl->Interface.destroy = &SR_AcousticStateDestroyImpl; 47 impl->Interface.reset = &SR_AcousticStateResetImpl; 48 impl->Interface.set = &SR_AcousticStateSetImpl; 49 impl->Interface.get = &SR_AcousticStateGetImpl; 50 51 recogImpl->acousticState = &impl->Interface; 52 return ESR_SUCCESS; 53 } 54 55 56 ESR_ReturnCode SR_AcousticStateGetImpl(SR_Recognizer* self, LCHAR *param_string, size_t* len ) 57 { 58 SR_RecognizerImpl* recogImpl = (SR_RecognizerImpl*) self; 59 60 return CA_GetCMSParameters(recogImpl->wavein, param_string, len ); 61 } 62 63 64 ESR_ReturnCode SR_AcousticStateSetImpl(SR_Recognizer* self, const LCHAR *param_string ) 65 { 66 SR_RecognizerImpl* recogImpl = (SR_RecognizerImpl*) self; 67 68 return CA_SetCMSParameters(recogImpl->wavein, param_string ); 69 } 70 71 72 ESR_ReturnCode SR_AcousticStateDestroyImpl(SR_Recognizer* recognizer) 73 { 74 SR_RecognizerImpl* recogImpl = (SR_RecognizerImpl*) recognizer; 75 SR_AcousticStateImpl* impl = (SR_AcousticStateImpl*) recogImpl->acousticState; 76 77 FREE(impl); 78 return ESR_SUCCESS; 79 } 80 81 ESR_ReturnCode SR_AcousticStateResetImpl(SR_Recognizer* recognizer) 82 { 83 SR_RecognizerImpl* recogImpl = (SR_RecognizerImpl*) recognizer; 84 CA_ReLoadCMSParameters(recogImpl->wavein, NULL); 85 return ESR_SUCCESS; 86 } 87 88 ESR_ReturnCode SR_AcousticStateLoadImpl(SR_Recognizer* self, const LCHAR* filename) 89 { 90 SR_RecognizerImpl* recogImpl = (SR_RecognizerImpl*) self; 91 92 CA_ReLoadCMSParameters(recogImpl->wavein, filename); 93 return ESR_SUCCESS; 94 } 95 96 ESR_ReturnCode SR_AcousticStateSaveImpl(SR_Recognizer* recognizer, const LCHAR* filename) 97 { 98 return ESR_NOT_IMPLEMENTED; 99 } 100