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.
16 #ifndef __SPEECHRECOGNITIONUTILITYBODY_H__
17 #define __SPEECHRECOGNITIONUTILITYBODY_H__
22 #include <mmf/common/mmfcontroller.h>
23 #include <mmf/common/speechrecognitioncustomcommands.h>
24 #include <mmf/common/speechrecognitiondataclient.h>
25 #include <speechrecognitionutility.h>
28 class CSpeechRecognitionUtility::CBody : public CBase, public MMMFControllerEventMonitorObserver
31 static CSpeechRecognitionUtility::CBody* NewL(TUid aClientUid, MSpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver);
32 static CSpeechRecognitionUtility::CBody* NewLC(TUid aClientUid, MSpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver);
35 TInt GetEngineProperties( const RArray<TInt>& aPropertyId, RArray<TInt>& aPropertyValue );
36 TInt AddPronunciation(TLexiconID aLexiconID, TModelBankID aModelBankID, TModelID aModelID, TPronunciationID& aPronunciationID);
37 TInt AddRule(TGrammarID aGrammarID, TLexiconID aLexiconID, TPronunciationID aPronunciationID, TRuleID& aRuleID);
40 TInt CreateGrammar(TGrammarID& aGrammarID);
41 TInt CreateLexicon(TLexiconID& aLexiconID);
42 TInt LoadModels(TModelBankID aModelBankID);
43 TInt LoadGrammar(TGrammarID aGrammarID);
45 TInt LoadLexicon(TLexiconID aLexiconID);
47 TInt GetUtteranceDuration(TModelBankID aModelBankID, TModelID aModelID, TTimeIntervalMicroSeconds32& aDuration);
48 TInt PlayUtterance(TModelBankID aModelBankID, TModelID aModelID);
49 TInt GetModelCount(TModelBankID aModelBankID, TInt& aModelCount);
52 TInt StartRecSession(TRecognitionMode aMode);
53 TInt Recognize(CSDClientResultSet& aResultSet);
55 TInt Record(TTimeIntervalMicroSeconds32 aRecordTime);
57 TInt RemoveGrammar(TGrammarID aGrammarID);
59 TInt RemovePronunciation(TLexiconID aLexiconID, TPronunciationID aPronunciationID);
61 TInt RemoveLexicon(TLexiconID aLexiconID);
63 TInt RemoveModel(TModelBankID aModelBankID, TModelID aModelID);
65 TInt RemoveRule(TGrammarID aGrammarID, TRuleID aRuleID);
66 TInt Train(TModelBankID aModelBankID, TModelID& aModelID);
67 TInt UnloadRule(TGrammarID aGrammarID, TRuleID aRuleID);
68 void SetEventHandler(MSpeechRecognitionUtilityObserver* aSpeechRecognitionUtilityObserver);
69 TInt GetAllPronunciationIDs(TLexiconID aLexiconID, RArray <TPronunciationID>& aPronunciationIDs);
70 TInt GetAllModelIDs(TModelBankID aModelBankID, RArray <TModelID>& aModelIDs);
71 TInt GetAllRuleIDs(TGrammarID aGrammarID, RArray <TRuleID>& aRuleIDs);
73 TInt GetAllLexiconIDs(RArray <TLexiconID>& aPronunciationIDs);
74 TInt GetAllModelBankIDs(RArray <TModelBankID>& aModelIDs);
75 TInt GetAllGrammarIDs(RArray <TGrammarID>& aRuleIDs);
77 TInt GetAllClientLexiconIDs(RArray <TLexiconID>& aPronunciationIDs);
78 TInt GetAllClientModelBankIDs(RArray <TModelBankID>& aModelIDs);
79 TInt GetAllClientGrammarIDs(RArray <TGrammarID>& aRuleIDs);
81 TInt GetRuleValidity(TGrammarID aGrammarID, TRuleID aRuleID, TBool& aValid);
83 TInt CreateModelBank(TModelBankID& aModelBankID);
84 TInt RemoveModelBank(TModelBankID aModelBankID);
85 TInt GetAvailableStorage(TInt& aAvailableStorage);
86 TInt LoadEngineParameters( const RArray<TInt>& aParameterId,
87 const RArray<TInt>& aParameterValue );
89 TInt SetAudioPriority( TInt aPriority, TInt aTrainPreference,
90 TInt aPlaybackPreference, TInt aRecognitionPreference );
92 void HandleEvent(const TMMFEvent& aEvent);
95 CBody(TUid aClientUid, MSpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver);
99 // member variable MMF controller
100 RMMFController iMMFController;
101 // member variable for custom commands
102 RSpeechRecognitionCustomCommands iSrCustomCommands;
103 // member variable pointer for observer class
104 MSpeechRecognitionUtilityObserver* iSpeechRecognitionUtilityObserver;
106 // member variable pointer for controller event monitor class
107 CMMFControllerEventMonitor* iControllerEventMonitor;
108 // used to indicate if an event is the result of an internal command
109 TBool iAsyncCallBusy;
111 // member variable pointer for array of rule IDs - not owned
112 RArray <TRuleID>* iRuleIDs;
113 // member variable pointer for array of pronunciation IDs - not owned
114 RArray <TPronunciationID>* iPronunciationIDs;
115 // member variable pointer for array of model IDs - not owned
116 RArray <TModelID>* iModelIDs;
118 // member variable pointer for array of Grammar IDs - not owned
119 RArray <TGrammarID>* iGrammarIDs;
120 // member variable pointer for array of Lexicon IDs - not owned
121 RArray <TLexiconID>* iLexiconIDs;
122 // member variable pointer for array of Model Bank IDs - not owned
123 RArray <TModelBankID>* iModelBankIDs;
126 // member variable for audio priority
128 // member variable for train preference
129 TMdaPriorityPreference iTrainPreference;
130 // member variable for playback preference
131 TMdaPriorityPreference iPlaybackPreference;
132 // member variable for recognition preference
133 TMdaPriorityPreference iRecognitionPreference;
135 CSDClientResultSet* iResultSet;
137 // settings used in the construction of the asr controlller
138 TMMFPrioritySettings iPrioritySettings;
144 #endif // __SPEECHRECOGNITIONUTILITY_H__