|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32base.h> |
|
17 #include <mmf/common/mmfcontroller.h> |
|
18 #include <mmf/common/speechrecognitioncustomcommands.h> |
|
19 #include <mmf/common/speechrecognitiondataclient.h> |
|
20 |
|
21 #include <speechrecognitionutility.h> |
|
22 #include "SpeechRecognitionUtilityBody.h" |
|
23 |
|
24 _LIT(KMMFSpeechPanicCategory, "SpeechClient"); |
|
25 GLDEF_C void Panic(TInt aError) |
|
26 { |
|
27 User::Panic(KMMFSpeechPanicCategory, aError); |
|
28 } |
|
29 |
|
30 EXPORT_C CSpeechRecognitionUtility* CSpeechRecognitionUtility::NewL(MSpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver, TUid aClientUid) |
|
31 { |
|
32 CSpeechRecognitionUtility* s = CSpeechRecognitionUtility::NewLC(aSpeechRecognitionUtilityObserver, aClientUid); |
|
33 CleanupStack::Pop(s); |
|
34 return s; |
|
35 } |
|
36 |
|
37 EXPORT_C CSpeechRecognitionUtility* CSpeechRecognitionUtility::NewLC(MSpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver, TUid aClientUid) |
|
38 { |
|
39 CSpeechRecognitionUtility* s = new(ELeave) CSpeechRecognitionUtility; |
|
40 CleanupStack::PushL(s); |
|
41 s->iBody = CSpeechRecognitionUtility::CBody::NewL(aClientUid, aSpeechRecognitionUtilityObserver); |
|
42 return s; |
|
43 } |
|
44 |
|
45 CSpeechRecognitionUtility::CSpeechRecognitionUtility() |
|
46 { |
|
47 } |
|
48 |
|
49 EXPORT_C CSpeechRecognitionUtility::~CSpeechRecognitionUtility() |
|
50 { |
|
51 delete iBody; |
|
52 } |
|
53 |
|
54 EXPORT_C TInt CSpeechRecognitionUtility::GetEngineProperties(const RArray<TInt>& aArray1, RArray<TInt>& aArray2) |
|
55 { |
|
56 ASSERT(iBody); |
|
57 return iBody->GetEngineProperties(aArray1, aArray2); |
|
58 } |
|
59 |
|
60 EXPORT_C TInt CSpeechRecognitionUtility::AddPronunciation(TLexiconID aLexiconID, TModelBankID aModelBankID, TModelID aModelID, TPronunciationID& aPronunciationID) |
|
61 { |
|
62 ASSERT(iBody); |
|
63 return iBody->AddPronunciation(aLexiconID, aModelBankID, aModelID, aPronunciationID); |
|
64 } |
|
65 |
|
66 EXPORT_C TInt CSpeechRecognitionUtility::AddRule(TGrammarID aGrammarID, TLexiconID aLexiconID, TPronunciationID aPronunciationID, TRuleID& aRuleID) |
|
67 { |
|
68 ASSERT(iBody); |
|
69 return iBody->AddRule(aGrammarID, aLexiconID, aPronunciationID, aRuleID); |
|
70 } |
|
71 |
|
72 EXPORT_C void CSpeechRecognitionUtility::Cancel() |
|
73 { |
|
74 ASSERT(iBody); |
|
75 iBody->Cancel(); |
|
76 } |
|
77 |
|
78 EXPORT_C TInt CSpeechRecognitionUtility::CommitChanges() |
|
79 { |
|
80 ASSERT(iBody); |
|
81 return iBody->CommitChanges(); |
|
82 } |
|
83 |
|
84 EXPORT_C TInt CSpeechRecognitionUtility::CreateGrammar(TGrammarID& aGrammarID) |
|
85 { |
|
86 ASSERT(iBody); |
|
87 return iBody->CreateGrammar(aGrammarID); |
|
88 } |
|
89 |
|
90 EXPORT_C TInt CSpeechRecognitionUtility::CreateLexicon(TLexiconID& aLexiconID) |
|
91 { |
|
92 ASSERT(iBody); |
|
93 return iBody->CreateLexicon(aLexiconID); |
|
94 } |
|
95 |
|
96 EXPORT_C TInt CSpeechRecognitionUtility::LoadModels(TModelBankID aModelBankID) |
|
97 { |
|
98 ASSERT(iBody); |
|
99 return iBody->LoadModels(aModelBankID); |
|
100 } |
|
101 |
|
102 EXPORT_C TInt CSpeechRecognitionUtility::LoadGrammar(TGrammarID aGrammarID) |
|
103 { |
|
104 ASSERT(iBody); |
|
105 return iBody->LoadGrammar(aGrammarID); |
|
106 } |
|
107 |
|
108 EXPORT_C TInt CSpeechRecognitionUtility::LoadLexicon(TLexiconID aLexiconID) |
|
109 { |
|
110 ASSERT(iBody); |
|
111 return iBody->LoadLexicon(aLexiconID); |
|
112 } |
|
113 |
|
114 EXPORT_C TInt CSpeechRecognitionUtility::GetUtteranceDuration(TModelBankID aModelBankID, TModelID aModelID, TTimeIntervalMicroSeconds32& aDuration) |
|
115 { |
|
116 ASSERT(iBody); |
|
117 return iBody->GetUtteranceDuration(aModelBankID, aModelID, aDuration); |
|
118 } |
|
119 |
|
120 EXPORT_C TInt CSpeechRecognitionUtility::PlayUtterance(TModelBankID aModelBankID, TModelID aModelID) |
|
121 { |
|
122 ASSERT(iBody); |
|
123 return iBody->PlayUtterance(aModelBankID, aModelID); |
|
124 } |
|
125 |
|
126 EXPORT_C TInt CSpeechRecognitionUtility::GetModelCount(TModelBankID aModelBankID, TInt& aModelCount) |
|
127 { |
|
128 ASSERT(iBody); |
|
129 return iBody->GetModelCount(aModelBankID, aModelCount); |
|
130 } |
|
131 |
|
132 EXPORT_C TInt CSpeechRecognitionUtility::EndRecSession() |
|
133 { |
|
134 ASSERT(iBody); |
|
135 return iBody->EndRecSession(); |
|
136 } |
|
137 |
|
138 EXPORT_C TInt CSpeechRecognitionUtility::StartRecSession(TRecognitionMode aMode) |
|
139 { |
|
140 ASSERT(iBody); |
|
141 return iBody->StartRecSession(aMode); |
|
142 } |
|
143 |
|
144 EXPORT_C TInt CSpeechRecognitionUtility::Recognize(CSDClientResultSet& aResultSet) |
|
145 { |
|
146 ASSERT(iBody); |
|
147 return iBody->Recognize(aResultSet); |
|
148 } |
|
149 |
|
150 EXPORT_C TInt CSpeechRecognitionUtility::Record(TTimeIntervalMicroSeconds32 aRecordTime) |
|
151 { |
|
152 ASSERT(iBody); |
|
153 return iBody->Record(aRecordTime); |
|
154 } |
|
155 |
|
156 EXPORT_C TInt CSpeechRecognitionUtility::RemoveGrammar(TGrammarID aGrammarID) |
|
157 { |
|
158 ASSERT(iBody); |
|
159 return iBody->RemoveGrammar(aGrammarID); |
|
160 } |
|
161 |
|
162 EXPORT_C TInt CSpeechRecognitionUtility::RemovePronunciation(TLexiconID aLexiconID, TPronunciationID aPronunciationID) |
|
163 { |
|
164 ASSERT(iBody); |
|
165 return iBody->RemovePronunciation(aLexiconID, aPronunciationID); |
|
166 } |
|
167 |
|
168 EXPORT_C TInt CSpeechRecognitionUtility::RemoveLexicon(TLexiconID aLexiconID) |
|
169 { |
|
170 ASSERT(iBody); |
|
171 return iBody->RemoveLexicon(aLexiconID); |
|
172 } |
|
173 |
|
174 EXPORT_C TInt CSpeechRecognitionUtility::RemoveModel(TModelBankID aModelBankID, TModelID aModelID) |
|
175 { |
|
176 ASSERT(iBody); |
|
177 return iBody->RemoveModel(aModelBankID, aModelID); |
|
178 } |
|
179 |
|
180 EXPORT_C TInt CSpeechRecognitionUtility::RemoveRule(TGrammarID aGrammarID, TRuleID aRuleID) |
|
181 { |
|
182 ASSERT(iBody); |
|
183 return iBody->RemoveRule(aGrammarID, aRuleID); |
|
184 } |
|
185 EXPORT_C TInt CSpeechRecognitionUtility::Train(TModelBankID aModelBankID, TModelID& aModelID) |
|
186 { |
|
187 ASSERT(iBody); |
|
188 return iBody->Train(aModelBankID, aModelID); |
|
189 } |
|
190 |
|
191 EXPORT_C TInt CSpeechRecognitionUtility::UnloadRule(TGrammarID aGrammarID, TRuleID aRuleID) |
|
192 { |
|
193 ASSERT(iBody); |
|
194 return iBody->UnloadRule(aGrammarID, aRuleID); |
|
195 } |
|
196 |
|
197 EXPORT_C void CSpeechRecognitionUtility::SetEventHandler(MSpeechRecognitionUtilityObserver* aSpeechRecognitionUtilityObserver) |
|
198 { |
|
199 ASSERT(iBody); |
|
200 iBody->SetEventHandler(aSpeechRecognitionUtilityObserver); |
|
201 } |
|
202 |
|
203 EXPORT_C TInt CSpeechRecognitionUtility::GetAllPronunciationIDs(TLexiconID aLexiconID, RArray <TPronunciationID>& aPronunciationIDs) |
|
204 { |
|
205 ASSERT(iBody); |
|
206 return iBody->GetAllPronunciationIDs(aLexiconID, aPronunciationIDs); |
|
207 } |
|
208 |
|
209 EXPORT_C TInt CSpeechRecognitionUtility::GetAllModelIDs(TModelBankID aModelBankID, RArray <TModelID>& aModelIDs) |
|
210 { |
|
211 ASSERT(iBody); |
|
212 return iBody->GetAllModelIDs(aModelBankID, aModelIDs); |
|
213 } |
|
214 |
|
215 |
|
216 EXPORT_C TInt CSpeechRecognitionUtility::GetAllRuleIDs(TGrammarID aGrammarID, RArray <TRuleID>& aRuleIDs) |
|
217 { |
|
218 ASSERT(iBody); |
|
219 return iBody->GetAllRuleIDs(aGrammarID, aRuleIDs); |
|
220 } |
|
221 |
|
222 EXPORT_C TInt CSpeechRecognitionUtility::GetAllClientLexiconIDs(RArray <TLexiconID>& aLexiconIDs) |
|
223 { |
|
224 ASSERT(iBody); |
|
225 return iBody->GetAllClientLexiconIDs(aLexiconIDs); |
|
226 } |
|
227 |
|
228 EXPORT_C TInt CSpeechRecognitionUtility::GetAllClientModelBankIDs(RArray <TModelBankID>& aModelBankIDs) |
|
229 { |
|
230 ASSERT(iBody); |
|
231 return iBody->GetAllClientModelBankIDs(aModelBankIDs); |
|
232 } |
|
233 |
|
234 |
|
235 EXPORT_C TInt CSpeechRecognitionUtility::GetAllClientGrammarIDs(RArray <TGrammarID>& aGrammarIDs) |
|
236 { |
|
237 ASSERT(iBody); |
|
238 return iBody->GetAllClientGrammarIDs(aGrammarIDs); |
|
239 } |
|
240 |
|
241 EXPORT_C TInt CSpeechRecognitionUtility::GetAllLexiconIDs(RArray <TLexiconID>& aLexiconIDs) |
|
242 { |
|
243 ASSERT(iBody); |
|
244 return iBody->GetAllLexiconIDs(aLexiconIDs); |
|
245 } |
|
246 |
|
247 EXPORT_C TInt CSpeechRecognitionUtility::GetAllModelBankIDs(RArray <TModelBankID>& aModelBankIDs) |
|
248 { |
|
249 ASSERT(iBody); |
|
250 return iBody->GetAllModelBankIDs(aModelBankIDs); |
|
251 } |
|
252 |
|
253 |
|
254 EXPORT_C TInt CSpeechRecognitionUtility::GetAllGrammarIDs(RArray <TGrammarID>& aGrammarIDs) |
|
255 { |
|
256 ASSERT(iBody); |
|
257 return iBody->GetAllGrammarIDs(aGrammarIDs); |
|
258 } |
|
259 |
|
260 |
|
261 EXPORT_C TInt CSpeechRecognitionUtility::GetRuleValidity(TGrammarID aGrammarID, TRuleID aRuleID, TBool& aValid) |
|
262 { |
|
263 ASSERT(iBody); |
|
264 return iBody->GetRuleValidity(aGrammarID, aRuleID, aValid); |
|
265 } |
|
266 |
|
267 EXPORT_C TInt CSpeechRecognitionUtility::CreateModelBank(TModelBankID& aModelBankID) |
|
268 { |
|
269 ASSERT(iBody); |
|
270 return iBody->CreateModelBank(aModelBankID); |
|
271 } |
|
272 EXPORT_C TInt CSpeechRecognitionUtility::RemoveModelBank(TModelBankID aModelBankID) |
|
273 { |
|
274 ASSERT(iBody); |
|
275 return iBody->RemoveModelBank(aModelBankID); |
|
276 } |
|
277 |
|
278 EXPORT_C TInt CSpeechRecognitionUtility::GetAvailableStorage(TInt& aAvailableStorage) |
|
279 { |
|
280 ASSERT(iBody); |
|
281 return iBody->GetAvailableStorage(aAvailableStorage); |
|
282 } |
|
283 |
|
284 EXPORT_C TInt CSpeechRecognitionUtility::LoadEngineParameters(const RArray<TInt>& aParameterId, const RArray<TInt>& aParameterValue) |
|
285 { |
|
286 ASSERT(iBody); |
|
287 return iBody->LoadEngineParameters(aParameterId, aParameterValue); |
|
288 } |
|
289 |
|
290 EXPORT_C TInt CSpeechRecognitionUtility::SetAudioPriority(TInt aPriority, TInt aTrainPreference, TInt aPlaybackPreference, TInt aRecognitionPreference) |
|
291 { |
|
292 ASSERT(iBody); |
|
293 return iBody->SetAudioPriority(aPriority, aTrainPreference, aPlaybackPreference, aRecognitionPreference); |
|
294 } |
|
295 |
|
296 enum TDllReason {}; |
|
297 EXPORT_C TInt E32Dll(TDllReason /* aReason */) |
|
298 { |
|
299 return (KErrNone); |
|
300 } |