First public contribution.
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include <mmf/common/mmfcontroller.h>
18 #include <mmf/common/speechrecognitioncustomcommands.h>
19 #include <mmf/common/speechrecognitiondataclient.h>
21 #include <speechrecognitionutility.h>
22 #include "SpeechRecognitionUtilityBody.h"
24 _LIT(KMMFSpeechPanicCategory, "SpeechClient");
25 GLDEF_C void Panic(TInt aError)
27 User::Panic(KMMFSpeechPanicCategory, aError);
30 EXPORT_C CSpeechRecognitionUtility* CSpeechRecognitionUtility::NewL(MSpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver, TUid aClientUid)
32 CSpeechRecognitionUtility* s = CSpeechRecognitionUtility::NewLC(aSpeechRecognitionUtilityObserver, aClientUid);
37 EXPORT_C CSpeechRecognitionUtility* CSpeechRecognitionUtility::NewLC(MSpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver, TUid aClientUid)
39 CSpeechRecognitionUtility* s = new(ELeave) CSpeechRecognitionUtility;
40 CleanupStack::PushL(s);
41 s->iBody = CSpeechRecognitionUtility::CBody::NewL(aClientUid, aSpeechRecognitionUtilityObserver);
45 CSpeechRecognitionUtility::CSpeechRecognitionUtility()
49 EXPORT_C CSpeechRecognitionUtility::~CSpeechRecognitionUtility()
54 EXPORT_C TInt CSpeechRecognitionUtility::GetEngineProperties(const RArray<TInt>& aArray1, RArray<TInt>& aArray2)
57 return iBody->GetEngineProperties(aArray1, aArray2);
60 EXPORT_C TInt CSpeechRecognitionUtility::AddPronunciation(TLexiconID aLexiconID, TModelBankID aModelBankID, TModelID aModelID, TPronunciationID& aPronunciationID)
63 return iBody->AddPronunciation(aLexiconID, aModelBankID, aModelID, aPronunciationID);
66 EXPORT_C TInt CSpeechRecognitionUtility::AddRule(TGrammarID aGrammarID, TLexiconID aLexiconID, TPronunciationID aPronunciationID, TRuleID& aRuleID)
69 return iBody->AddRule(aGrammarID, aLexiconID, aPronunciationID, aRuleID);
72 EXPORT_C void CSpeechRecognitionUtility::Cancel()
78 EXPORT_C TInt CSpeechRecognitionUtility::CommitChanges()
81 return iBody->CommitChanges();
84 EXPORT_C TInt CSpeechRecognitionUtility::CreateGrammar(TGrammarID& aGrammarID)
87 return iBody->CreateGrammar(aGrammarID);
90 EXPORT_C TInt CSpeechRecognitionUtility::CreateLexicon(TLexiconID& aLexiconID)
93 return iBody->CreateLexicon(aLexiconID);
96 EXPORT_C TInt CSpeechRecognitionUtility::LoadModels(TModelBankID aModelBankID)
99 return iBody->LoadModels(aModelBankID);
102 EXPORT_C TInt CSpeechRecognitionUtility::LoadGrammar(TGrammarID aGrammarID)
105 return iBody->LoadGrammar(aGrammarID);
108 EXPORT_C TInt CSpeechRecognitionUtility::LoadLexicon(TLexiconID aLexiconID)
111 return iBody->LoadLexicon(aLexiconID);
114 EXPORT_C TInt CSpeechRecognitionUtility::GetUtteranceDuration(TModelBankID aModelBankID, TModelID aModelID, TTimeIntervalMicroSeconds32& aDuration)
117 return iBody->GetUtteranceDuration(aModelBankID, aModelID, aDuration);
120 EXPORT_C TInt CSpeechRecognitionUtility::PlayUtterance(TModelBankID aModelBankID, TModelID aModelID)
123 return iBody->PlayUtterance(aModelBankID, aModelID);
126 EXPORT_C TInt CSpeechRecognitionUtility::GetModelCount(TModelBankID aModelBankID, TInt& aModelCount)
129 return iBody->GetModelCount(aModelBankID, aModelCount);
132 EXPORT_C TInt CSpeechRecognitionUtility::EndRecSession()
135 return iBody->EndRecSession();
138 EXPORT_C TInt CSpeechRecognitionUtility::StartRecSession(TRecognitionMode aMode)
141 return iBody->StartRecSession(aMode);
144 EXPORT_C TInt CSpeechRecognitionUtility::Recognize(CSDClientResultSet& aResultSet)
147 return iBody->Recognize(aResultSet);
150 EXPORT_C TInt CSpeechRecognitionUtility::Record(TTimeIntervalMicroSeconds32 aRecordTime)
153 return iBody->Record(aRecordTime);
156 EXPORT_C TInt CSpeechRecognitionUtility::RemoveGrammar(TGrammarID aGrammarID)
159 return iBody->RemoveGrammar(aGrammarID);
162 EXPORT_C TInt CSpeechRecognitionUtility::RemovePronunciation(TLexiconID aLexiconID, TPronunciationID aPronunciationID)
165 return iBody->RemovePronunciation(aLexiconID, aPronunciationID);
168 EXPORT_C TInt CSpeechRecognitionUtility::RemoveLexicon(TLexiconID aLexiconID)
171 return iBody->RemoveLexicon(aLexiconID);
174 EXPORT_C TInt CSpeechRecognitionUtility::RemoveModel(TModelBankID aModelBankID, TModelID aModelID)
177 return iBody->RemoveModel(aModelBankID, aModelID);
180 EXPORT_C TInt CSpeechRecognitionUtility::RemoveRule(TGrammarID aGrammarID, TRuleID aRuleID)
183 return iBody->RemoveRule(aGrammarID, aRuleID);
185 EXPORT_C TInt CSpeechRecognitionUtility::Train(TModelBankID aModelBankID, TModelID& aModelID)
188 return iBody->Train(aModelBankID, aModelID);
191 EXPORT_C TInt CSpeechRecognitionUtility::UnloadRule(TGrammarID aGrammarID, TRuleID aRuleID)
194 return iBody->UnloadRule(aGrammarID, aRuleID);
197 EXPORT_C void CSpeechRecognitionUtility::SetEventHandler(MSpeechRecognitionUtilityObserver* aSpeechRecognitionUtilityObserver)
200 iBody->SetEventHandler(aSpeechRecognitionUtilityObserver);
203 EXPORT_C TInt CSpeechRecognitionUtility::GetAllPronunciationIDs(TLexiconID aLexiconID, RArray <TPronunciationID>& aPronunciationIDs)
206 return iBody->GetAllPronunciationIDs(aLexiconID, aPronunciationIDs);
209 EXPORT_C TInt CSpeechRecognitionUtility::GetAllModelIDs(TModelBankID aModelBankID, RArray <TModelID>& aModelIDs)
212 return iBody->GetAllModelIDs(aModelBankID, aModelIDs);
216 EXPORT_C TInt CSpeechRecognitionUtility::GetAllRuleIDs(TGrammarID aGrammarID, RArray <TRuleID>& aRuleIDs)
219 return iBody->GetAllRuleIDs(aGrammarID, aRuleIDs);
222 EXPORT_C TInt CSpeechRecognitionUtility::GetAllClientLexiconIDs(RArray <TLexiconID>& aLexiconIDs)
225 return iBody->GetAllClientLexiconIDs(aLexiconIDs);
228 EXPORT_C TInt CSpeechRecognitionUtility::GetAllClientModelBankIDs(RArray <TModelBankID>& aModelBankIDs)
231 return iBody->GetAllClientModelBankIDs(aModelBankIDs);
235 EXPORT_C TInt CSpeechRecognitionUtility::GetAllClientGrammarIDs(RArray <TGrammarID>& aGrammarIDs)
238 return iBody->GetAllClientGrammarIDs(aGrammarIDs);
241 EXPORT_C TInt CSpeechRecognitionUtility::GetAllLexiconIDs(RArray <TLexiconID>& aLexiconIDs)
244 return iBody->GetAllLexiconIDs(aLexiconIDs);
247 EXPORT_C TInt CSpeechRecognitionUtility::GetAllModelBankIDs(RArray <TModelBankID>& aModelBankIDs)
250 return iBody->GetAllModelBankIDs(aModelBankIDs);
254 EXPORT_C TInt CSpeechRecognitionUtility::GetAllGrammarIDs(RArray <TGrammarID>& aGrammarIDs)
257 return iBody->GetAllGrammarIDs(aGrammarIDs);
261 EXPORT_C TInt CSpeechRecognitionUtility::GetRuleValidity(TGrammarID aGrammarID, TRuleID aRuleID, TBool& aValid)
264 return iBody->GetRuleValidity(aGrammarID, aRuleID, aValid);
267 EXPORT_C TInt CSpeechRecognitionUtility::CreateModelBank(TModelBankID& aModelBankID)
270 return iBody->CreateModelBank(aModelBankID);
272 EXPORT_C TInt CSpeechRecognitionUtility::RemoveModelBank(TModelBankID aModelBankID)
275 return iBody->RemoveModelBank(aModelBankID);
278 EXPORT_C TInt CSpeechRecognitionUtility::GetAvailableStorage(TInt& aAvailableStorage)
281 return iBody->GetAvailableStorage(aAvailableStorage);
284 EXPORT_C TInt CSpeechRecognitionUtility::LoadEngineParameters(const RArray<TInt>& aParameterId, const RArray<TInt>& aParameterValue)
287 return iBody->LoadEngineParameters(aParameterId, aParameterValue);
290 EXPORT_C TInt CSpeechRecognitionUtility::SetAudioPriority(TInt aPriority, TInt aTrainPreference, TInt aPlaybackPreference, TInt aRecognitionPreference)
293 return iBody->SetAudioPriority(aPriority, aTrainPreference, aPlaybackPreference, aRecognitionPreference);
297 EXPORT_C TInt E32Dll(TDllReason /* aReason */)