sl@0
|
1 |
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "CustomMmfASRController.h"
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <mmfcontrollerimplementationuids.hrh>
|
sl@0
|
19 |
#include "customcontrollertestconstants.h"
|
sl@0
|
20 |
#include "Database/testdatabaseconstants.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
/*
|
sl@0
|
23 |
TMmfAsrControllerPanics is an enumeration with the following entries:
|
sl@0
|
24 |
|
sl@0
|
25 |
EBadArgument indicates a bad argument
|
sl@0
|
26 |
EBadState indicates a state viaolation
|
sl@0
|
27 |
EBadInvariant indicates an invariant violation
|
sl@0
|
28 |
EBadReset indicates failed reset
|
sl@0
|
29 |
EPostConditionViolation indicates a post condition violation
|
sl@0
|
30 |
|
sl@0
|
31 |
*/
|
sl@0
|
32 |
enum TMmfAsrControllerPanics
|
sl@0
|
33 |
{
|
sl@0
|
34 |
EBadArgument,
|
sl@0
|
35 |
EBadState,
|
sl@0
|
36 |
EBadInvariant,
|
sl@0
|
37 |
EPreConditionViolation,
|
sl@0
|
38 |
EPostConditionViolation,
|
sl@0
|
39 |
EDeprecatedFunction
|
sl@0
|
40 |
};
|
sl@0
|
41 |
|
sl@0
|
42 |
/**
|
sl@0
|
43 |
* Panic
|
sl@0
|
44 |
* This method generates a panic
|
sl@0
|
45 |
* @param "TInt"
|
sl@0
|
46 |
* @xxxx
|
sl@0
|
47 |
*/
|
sl@0
|
48 |
void Panic(TMmfAsrControllerPanics aPanicCode)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
_LIT(KMMFAsrControllerPanicCategory, "MMFAsrTestController");
|
sl@0
|
51 |
User::Panic(KMMFAsrControllerPanicCategory, aPanicCode);
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
|
sl@0
|
55 |
/**
|
sl@0
|
56 |
*
|
sl@0
|
57 |
* NewL
|
sl@0
|
58 |
*
|
sl@0
|
59 |
*/
|
sl@0
|
60 |
CMMFController* CCustomMmfASRController::NewL()
|
sl@0
|
61 |
{
|
sl@0
|
62 |
CCustomMmfASRController* self = new(ELeave) CCustomMmfASRController;
|
sl@0
|
63 |
CleanupStack::PushL(self);
|
sl@0
|
64 |
self->ConstructL();
|
sl@0
|
65 |
CleanupStack::Pop( self );
|
sl@0
|
66 |
return STATIC_CAST( CMMFController*, self );
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
|
sl@0
|
70 |
/**
|
sl@0
|
71 |
*
|
sl@0
|
72 |
* SetState
|
sl@0
|
73 |
* @param aState
|
sl@0
|
74 |
*
|
sl@0
|
75 |
*/
|
sl@0
|
76 |
void CCustomMmfASRController::SetState( TControllerState aState )
|
sl@0
|
77 |
{
|
sl@0
|
78 |
iState=aState;
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
/**
|
sl@0
|
82 |
*
|
sl@0
|
83 |
* ConstructL
|
sl@0
|
84 |
*
|
sl@0
|
85 |
*/
|
sl@0
|
86 |
void CCustomMmfASRController::ConstructL()
|
sl@0
|
87 |
{
|
sl@0
|
88 |
//[ Construct custom command parsers]
|
sl@0
|
89 |
CSpeechRecognitionCustomCommandParser* asrParser = CSpeechRecognitionCustomCommandParser::NewL(*this);
|
sl@0
|
90 |
CleanupStack::PushL(asrParser);
|
sl@0
|
91 |
AddCustomCommandParserL(*asrParser);
|
sl@0
|
92 |
CleanupStack::Pop( asrParser ); //asrParser
|
sl@0
|
93 |
|
sl@0
|
94 |
SetState( ESTraining ); //state of the controller
|
sl@0
|
95 |
iRecognitionMode = ESdMode; // recognition mode which is nonzero for now
|
sl@0
|
96 |
iRecordTime = 0; // the duration of the recording for both recognition and trainning
|
sl@0
|
97 |
|
sl@0
|
98 |
iRecognizeComplete = EFalse;
|
sl@0
|
99 |
iLoadedGrammarID = 0;
|
sl@0
|
100 |
iLoadedLexiconID = 0;
|
sl@0
|
101 |
iLoadedModelBankID = 0;
|
sl@0
|
102 |
|
sl@0
|
103 |
RFs fsSession;
|
sl@0
|
104 |
RFile file;
|
sl@0
|
105 |
User::LeaveIfError(fsSession.Connect());
|
sl@0
|
106 |
CleanupClosePushL(fsSession);
|
sl@0
|
107 |
TInt err = file.Open(fsSession, KFileNameTestDatabase, EFileRead);
|
sl@0
|
108 |
file.Close();
|
sl@0
|
109 |
if(err == KErrNone)
|
sl@0
|
110 |
{
|
sl@0
|
111 |
iDatabase = CSDDatabase::NewL(KFileNameTestDatabase);
|
sl@0
|
112 |
}
|
sl@0
|
113 |
else if(err == KErrNotFound)
|
sl@0
|
114 |
{
|
sl@0
|
115 |
iDatabase = CSDDatabase::NewL(KFileNameTestDatabase, EFalse);
|
sl@0
|
116 |
}
|
sl@0
|
117 |
else if(err == KErrPathNotFound)
|
sl@0
|
118 |
{
|
sl@0
|
119 |
TParse fullFileName;
|
sl@0
|
120 |
if(fullFileName.Set(KFileNameTestDatabase, NULL, NULL) == KErrNone)
|
sl@0
|
121 |
{
|
sl@0
|
122 |
err = fsSession. MkDirAll(fullFileName.DriveAndPath());
|
sl@0
|
123 |
if(err == KErrNone)
|
sl@0
|
124 |
{
|
sl@0
|
125 |
iDatabase = CSDDatabase::NewL(KFileNameTestDatabase,EFalse);
|
sl@0
|
126 |
}
|
sl@0
|
127 |
else
|
sl@0
|
128 |
{
|
sl@0
|
129 |
User::LeaveIfError(err);
|
sl@0
|
130 |
}
|
sl@0
|
131 |
}
|
sl@0
|
132 |
}
|
sl@0
|
133 |
else
|
sl@0
|
134 |
{
|
sl@0
|
135 |
User::LeaveIfError(err);
|
sl@0
|
136 |
}
|
sl@0
|
137 |
CleanupStack::PopAndDestroy(); //fsSession
|
sl@0
|
138 |
}
|
sl@0
|
139 |
|
sl@0
|
140 |
|
sl@0
|
141 |
|
sl@0
|
142 |
/**
|
sl@0
|
143 |
*
|
sl@0
|
144 |
* ~CCustomMmfAudioController
|
sl@0
|
145 |
*
|
sl@0
|
146 |
*/
|
sl@0
|
147 |
CCustomMmfASRController::~CCustomMmfASRController()
|
sl@0
|
148 |
{
|
sl@0
|
149 |
delete iDatabase;
|
sl@0
|
150 |
}
|
sl@0
|
151 |
|
sl@0
|
152 |
/**
|
sl@0
|
153 |
*
|
sl@0
|
154 |
* CCustomMmfAudioController
|
sl@0
|
155 |
*
|
sl@0
|
156 |
*/
|
sl@0
|
157 |
CCustomMmfASRController::CCustomMmfASRController()
|
sl@0
|
158 |
{
|
sl@0
|
159 |
}
|
sl@0
|
160 |
|
sl@0
|
161 |
/**
|
sl@0
|
162 |
*
|
sl@0
|
163 |
* CustomCommand
|
sl@0
|
164 |
*
|
sl@0
|
165 |
*/
|
sl@0
|
166 |
void CCustomMmfASRController::CustomCommand(TMMFMessage& /*aMessage*/)
|
sl@0
|
167 |
{
|
sl@0
|
168 |
// The custom command is the final stopping off point
|
sl@0
|
169 |
// in the command processing chain and in this case it does
|
sl@0
|
170 |
// nothing!
|
sl@0
|
171 |
}
|
sl@0
|
172 |
|
sl@0
|
173 |
/**
|
sl@0
|
174 |
* AddDataSourceL
|
sl@0
|
175 |
*
|
sl@0
|
176 |
* Adds a data source to the controller
|
sl@0
|
177 |
*
|
sl@0
|
178 |
* @param aSource
|
sl@0
|
179 |
* Preconditions:
|
sl@0
|
180 |
* We are stopped
|
sl@0
|
181 |
* Source does not already exist
|
sl@0
|
182 |
* Postconditions:
|
sl@0
|
183 |
* iDataSource != NULL
|
sl@0
|
184 |
* iDataSourceAdded == ETrue
|
sl@0
|
185 |
*
|
sl@0
|
186 |
*/
|
sl@0
|
187 |
void CCustomMmfASRController::AddDataSourceL(MDataSource& /*aSource*/)
|
sl@0
|
188 |
{
|
sl@0
|
189 |
//[This function is deprecated and should not have been called]
|
sl@0
|
190 |
Panic(EDeprecatedFunction);
|
sl@0
|
191 |
}
|
sl@0
|
192 |
|
sl@0
|
193 |
/**
|
sl@0
|
194 |
* AddDataSinkL
|
sl@0
|
195 |
*
|
sl@0
|
196 |
* Adds a data sink to the controller
|
sl@0
|
197 |
*
|
sl@0
|
198 |
* @param aSink
|
sl@0
|
199 |
*
|
sl@0
|
200 |
*/
|
sl@0
|
201 |
void CCustomMmfASRController::AddDataSinkL(MDataSink& )
|
sl@0
|
202 |
{
|
sl@0
|
203 |
//[This function is deprecated and should not have been called]
|
sl@0
|
204 |
Panic(EDeprecatedFunction);
|
sl@0
|
205 |
}
|
sl@0
|
206 |
|
sl@0
|
207 |
/**
|
sl@0
|
208 |
* PrimeL
|
sl@0
|
209 |
*
|
sl@0
|
210 |
* If Prime fails the client should reset the controller
|
sl@0
|
211 |
* because as noted below this code is not transactional.
|
sl@0
|
212 |
*
|
sl@0
|
213 |
*/
|
sl@0
|
214 |
void CCustomMmfASRController::PrimeL()
|
sl@0
|
215 |
{
|
sl@0
|
216 |
//[This function is deprecated and should not have been called]
|
sl@0
|
217 |
Panic(EDeprecatedFunction);
|
sl@0
|
218 |
}
|
sl@0
|
219 |
|
sl@0
|
220 |
/**
|
sl@0
|
221 |
* ResetL
|
sl@0
|
222 |
* This method resets the controller
|
sl@0
|
223 |
*
|
sl@0
|
224 |
*/
|
sl@0
|
225 |
void CCustomMmfASRController::ResetL()
|
sl@0
|
226 |
{
|
sl@0
|
227 |
//[This function is deprecated and should not have been called]
|
sl@0
|
228 |
Panic(EDeprecatedFunction);
|
sl@0
|
229 |
}
|
sl@0
|
230 |
|
sl@0
|
231 |
/**
|
sl@0
|
232 |
*
|
sl@0
|
233 |
* PlayL
|
sl@0
|
234 |
*
|
sl@0
|
235 |
*/
|
sl@0
|
236 |
void CCustomMmfASRController::PlayL()
|
sl@0
|
237 |
{
|
sl@0
|
238 |
//[This function is deprecated and should not have been called]
|
sl@0
|
239 |
Panic(EDeprecatedFunction);
|
sl@0
|
240 |
}
|
sl@0
|
241 |
|
sl@0
|
242 |
/**
|
sl@0
|
243 |
* PauseL
|
sl@0
|
244 |
*
|
sl@0
|
245 |
*/
|
sl@0
|
246 |
void CCustomMmfASRController::PauseL()
|
sl@0
|
247 |
{
|
sl@0
|
248 |
//[This function is deprecated and should not have been called]
|
sl@0
|
249 |
Panic(EDeprecatedFunction);
|
sl@0
|
250 |
}
|
sl@0
|
251 |
|
sl@0
|
252 |
/**
|
sl@0
|
253 |
* StopL
|
sl@0
|
254 |
*
|
sl@0
|
255 |
*/
|
sl@0
|
256 |
void CCustomMmfASRController::StopL()
|
sl@0
|
257 |
{
|
sl@0
|
258 |
//[This function is deprecated and should not have been called]
|
sl@0
|
259 |
Panic(EDeprecatedFunction);
|
sl@0
|
260 |
}
|
sl@0
|
261 |
|
sl@0
|
262 |
/**
|
sl@0
|
263 |
* PositionL
|
sl@0
|
264 |
* Preconditions:
|
sl@0
|
265 |
* The Controller is in the state EPrimed
|
sl@0
|
266 |
* @return TTimeIntervalMicroSeconds
|
sl@0
|
267 |
*
|
sl@0
|
268 |
*/
|
sl@0
|
269 |
TTimeIntervalMicroSeconds CCustomMmfASRController::PositionL() const
|
sl@0
|
270 |
{
|
sl@0
|
271 |
//[This function is deprecated and should not have been called]
|
sl@0
|
272 |
Panic(EDeprecatedFunction);
|
sl@0
|
273 |
TTimeIntervalMicroSeconds position(0);
|
sl@0
|
274 |
return position;
|
sl@0
|
275 |
}
|
sl@0
|
276 |
|
sl@0
|
277 |
/**
|
sl@0
|
278 |
* SetPositionL
|
sl@0
|
279 |
*
|
sl@0
|
280 |
* @param aPosition
|
sl@0
|
281 |
*
|
sl@0
|
282 |
*/
|
sl@0
|
283 |
void CCustomMmfASRController::SetPositionL(const TTimeIntervalMicroSeconds& )
|
sl@0
|
284 |
{
|
sl@0
|
285 |
//[This function is deprecated and should not have been called]
|
sl@0
|
286 |
Panic(EDeprecatedFunction);
|
sl@0
|
287 |
}
|
sl@0
|
288 |
|
sl@0
|
289 |
/**
|
sl@0
|
290 |
*
|
sl@0
|
291 |
* MSrAddPronunciationL
|
sl@0
|
292 |
* @param aLexiconID
|
sl@0
|
293 |
* @param aModelID
|
sl@0
|
294 |
* @param aPronunciationID
|
sl@0
|
295 |
* Add pronunciation to the lexicon
|
sl@0
|
296 |
* @precondition lexicon is loaded
|
sl@0
|
297 |
* @precondition lexicon has specified id
|
sl@0
|
298 |
* @post condition lexicon has pronunciation
|
sl@0
|
299 |
*
|
sl@0
|
300 |
*/
|
sl@0
|
301 |
void CCustomMmfASRController::MSrAddPronunciationL( TLexiconID aLexiconID, TModelBankID aModelBankID,
|
sl@0
|
302 |
TModelID aModelID, TPronunciationID& aPronunciationID )
|
sl@0
|
303 |
{
|
sl@0
|
304 |
//[ assert the InVariant ]
|
sl@0
|
305 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
306 |
|
sl@0
|
307 |
//[ precondition that are in training mode ]
|
sl@0
|
308 |
__ASSERT_ALWAYS( State() == ESTraining, Panic(EBadState) );
|
sl@0
|
309 |
|
sl@0
|
310 |
//[ add new pronunciation ]
|
sl@0
|
311 |
TInt err = KErrNone;
|
sl@0
|
312 |
|
sl@0
|
313 |
CSDDatabase::TPronunciationData pronunciationData=CSDDatabase::TPronunciationData();
|
sl@0
|
314 |
pronunciationData.iModelBankID = aModelBankID;
|
sl@0
|
315 |
pronunciationData.iModelID = aModelID;
|
sl@0
|
316 |
|
sl@0
|
317 |
TRAP(err, aPronunciationID = iDatabase->CreatePronunciationL(aLexiconID, pronunciationData));
|
sl@0
|
318 |
|
sl@0
|
319 |
TMMFEvent addPronunciationComplete( KUidAsrEventAddPronunciation, err );
|
sl@0
|
320 |
SendEventToClient( addPronunciationComplete );
|
sl@0
|
321 |
|
sl@0
|
322 |
// [ assert the Invariant ]
|
sl@0
|
323 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
324 |
|
sl@0
|
325 |
}
|
sl@0
|
326 |
|
sl@0
|
327 |
|
sl@0
|
328 |
|
sl@0
|
329 |
void CCustomMmfASRController::MSrSetClientUid( TUid aClientUid)
|
sl@0
|
330 |
{
|
sl@0
|
331 |
//[ assert the InVariant ]
|
sl@0
|
332 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
333 |
|
sl@0
|
334 |
iDatabase->SetClientUid(aClientUid);
|
sl@0
|
335 |
|
sl@0
|
336 |
}
|
sl@0
|
337 |
|
sl@0
|
338 |
|
sl@0
|
339 |
/**
|
sl@0
|
340 |
*
|
sl@0
|
341 |
* MSrAddRule
|
sl@0
|
342 |
* @param aGrammarID
|
sl@0
|
343 |
* @param aLexiconID
|
sl@0
|
344 |
* @param aPronunciationID
|
sl@0
|
345 |
* @param aRuleID
|
sl@0
|
346 |
* @postcondition grammar has rule
|
sl@0
|
347 |
*/
|
sl@0
|
348 |
void CCustomMmfASRController::MSrAddRuleL(
|
sl@0
|
349 |
TGrammarID aGrammarID, TLexiconID aLexiconID,
|
sl@0
|
350 |
TPronunciationID aPronunciationID, TRuleID& aRuleID )
|
sl@0
|
351 |
{
|
sl@0
|
352 |
//[ assert the InVariant ]
|
sl@0
|
353 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
354 |
|
sl@0
|
355 |
//[ precondition that are in training mode ]
|
sl@0
|
356 |
__ASSERT_ALWAYS( State() == ESTraining, Panic(EBadState) );
|
sl@0
|
357 |
|
sl@0
|
358 |
|
sl@0
|
359 |
//[ if the grammar has the rule ]
|
sl@0
|
360 |
TInt err = KErrNone;
|
sl@0
|
361 |
CSDDatabase::TRuleData ruleData=CSDDatabase::TRuleData();
|
sl@0
|
362 |
ruleData.iLexiconID = aLexiconID;
|
sl@0
|
363 |
ruleData.iPronunciationID = aPronunciationID;
|
sl@0
|
364 |
|
sl@0
|
365 |
TRAP( err, aRuleID = iDatabase->CreateRuleL( aGrammarID, ruleData));
|
sl@0
|
366 |
|
sl@0
|
367 |
|
sl@0
|
368 |
TMMFEvent event( KUidAsrEventAddRule, err );
|
sl@0
|
369 |
SendEventToClient( event );
|
sl@0
|
370 |
|
sl@0
|
371 |
// [ assert the Invariant ]
|
sl@0
|
372 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
373 |
|
sl@0
|
374 |
}
|
sl@0
|
375 |
|
sl@0
|
376 |
|
sl@0
|
377 |
/**
|
sl@0
|
378 |
*
|
sl@0
|
379 |
* MSrCancel
|
sl@0
|
380 |
*
|
sl@0
|
381 |
*/
|
sl@0
|
382 |
void CCustomMmfASRController::MSrCancel()
|
sl@0
|
383 |
{
|
sl@0
|
384 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
385 |
// Send back a test event to the client to indicate this has been called, note this is test controller specific event
|
sl@0
|
386 |
TMMFEvent testCancelEvent( KUidTestASRCancel, KErrNone );
|
sl@0
|
387 |
SendEventToClient( testCancelEvent );
|
sl@0
|
388 |
}
|
sl@0
|
389 |
|
sl@0
|
390 |
/**
|
sl@0
|
391 |
*
|
sl@0
|
392 |
* MSrCommitChangesL
|
sl@0
|
393 |
*
|
sl@0
|
394 |
*/
|
sl@0
|
395 |
void CCustomMmfASRController::MSrCommitChangesL()
|
sl@0
|
396 |
{
|
sl@0
|
397 |
//[ assert the Invariant ]
|
sl@0
|
398 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
399 |
|
sl@0
|
400 |
iDatabase->CommitChangesL();
|
sl@0
|
401 |
|
sl@0
|
402 |
// [ assert the invariant ]
|
sl@0
|
403 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
404 |
}
|
sl@0
|
405 |
|
sl@0
|
406 |
/**
|
sl@0
|
407 |
*
|
sl@0
|
408 |
* MSrCreateGrammarL
|
sl@0
|
409 |
* Creates a Grammar and makes it the currently loaded grammar
|
sl@0
|
410 |
* @param aGrammarID
|
sl@0
|
411 |
* @precondition State == ESTraining
|
sl@0
|
412 |
* @postcondition iAsrSchema has grammar with id aGrammarID
|
sl@0
|
413 |
*
|
sl@0
|
414 |
*/
|
sl@0
|
415 |
void CCustomMmfASRController::MSrCreateGrammarL( TGrammarID& aGrammarID )
|
sl@0
|
416 |
{
|
sl@0
|
417 |
//[ assert the Invariant ]
|
sl@0
|
418 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
419 |
|
sl@0
|
420 |
//[ precondition that we are in trainning state ]
|
sl@0
|
421 |
__ASSERT_ALWAYS( State() == ESTraining, Panic(EBadState) );
|
sl@0
|
422 |
|
sl@0
|
423 |
aGrammarID = iDatabase->CreateGrammarL();
|
sl@0
|
424 |
|
sl@0
|
425 |
TMMFEvent event( KUidAsrEventCreateGrammar, KErrNone );
|
sl@0
|
426 |
SendEventToClient( event );
|
sl@0
|
427 |
|
sl@0
|
428 |
//[ assert the invariant ]
|
sl@0
|
429 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
430 |
}
|
sl@0
|
431 |
|
sl@0
|
432 |
/**
|
sl@0
|
433 |
*
|
sl@0
|
434 |
* MSrCreateLexiconL
|
sl@0
|
435 |
* @param aLexiconID
|
sl@0
|
436 |
* Creates a Lexicon with Id aLexiconId
|
sl@0
|
437 |
*
|
sl@0
|
438 |
*/
|
sl@0
|
439 |
void CCustomMmfASRController::MSrCreateLexiconL( TLexiconID& aLexiconID )
|
sl@0
|
440 |
{
|
sl@0
|
441 |
//[ assert the Invariant ]
|
sl@0
|
442 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
443 |
|
sl@0
|
444 |
//[ precondition that we are in trainning state ]
|
sl@0
|
445 |
__ASSERT_ALWAYS( State() == ESTraining, Panic(EBadState) );
|
sl@0
|
446 |
|
sl@0
|
447 |
//[ create the Lexicon ]
|
sl@0
|
448 |
aLexiconID = iDatabase->CreateLexiconL();
|
sl@0
|
449 |
|
sl@0
|
450 |
TMMFEvent event( KUidAsrEventCreateLexicon, KErrNone );
|
sl@0
|
451 |
SendEventToClient( event );
|
sl@0
|
452 |
|
sl@0
|
453 |
//[ assert the invariant ]
|
sl@0
|
454 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
455 |
|
sl@0
|
456 |
}
|
sl@0
|
457 |
|
sl@0
|
458 |
/**
|
sl@0
|
459 |
*
|
sl@0
|
460 |
* MSrCreateModelBankL
|
sl@0
|
461 |
* @param aModelBankID
|
sl@0
|
462 |
* @precondition state == ESTraining
|
sl@0
|
463 |
* @precondition invariant holds
|
sl@0
|
464 |
* @postcondition currentModelbank id == modelbank id
|
sl@0
|
465 |
*
|
sl@0
|
466 |
*/
|
sl@0
|
467 |
void CCustomMmfASRController::MSrCreateModelBankL( TModelBankID& aModelBankID )
|
sl@0
|
468 |
{
|
sl@0
|
469 |
//[ assert the Invariant ]
|
sl@0
|
470 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
471 |
|
sl@0
|
472 |
//[ precondition that we are in trainning state ]
|
sl@0
|
473 |
__ASSERT_ALWAYS( State() == ESTraining, Panic(EBadState) );
|
sl@0
|
474 |
|
sl@0
|
475 |
//[ create the new ModelBank]
|
sl@0
|
476 |
TRAPD(err, aModelBankID = iDatabase->CreateModelBankL());
|
sl@0
|
477 |
|
sl@0
|
478 |
TMMFEvent event( KUidAsrEventCreateModelBank, err);
|
sl@0
|
479 |
SendEventToClient( event );
|
sl@0
|
480 |
|
sl@0
|
481 |
//[ assert the invariant ]
|
sl@0
|
482 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
483 |
}
|
sl@0
|
484 |
|
sl@0
|
485 |
/**
|
sl@0
|
486 |
*
|
sl@0
|
487 |
* MSrEndRecSessionL
|
sl@0
|
488 |
* End a recognition session
|
sl@0
|
489 |
* @precondition State is ESRecognition
|
sl@0
|
490 |
* @postcondition State is Idle
|
sl@0
|
491 |
*/
|
sl@0
|
492 |
void CCustomMmfASRController::MSrEndRecSessionL()
|
sl@0
|
493 |
{
|
sl@0
|
494 |
//[ The Invariant must hold ]
|
sl@0
|
495 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
496 |
//[ precondition that the state is recognise ]
|
sl@0
|
497 |
__ASSERT_ALWAYS( State() == ESRecognition, Panic(EBadState) );
|
sl@0
|
498 |
//[ transitionn to Idle state ]
|
sl@0
|
499 |
SetState( ESTraining );
|
sl@0
|
500 |
|
sl@0
|
501 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
502 |
}
|
sl@0
|
503 |
|
sl@0
|
504 |
/**
|
sl@0
|
505 |
*
|
sl@0
|
506 |
* MSrGetAllModelIDsL
|
sl@0
|
507 |
* Gets all the model ids in a model bank
|
sl@0
|
508 |
* @precondition iModelBank is loaded
|
sl@0
|
509 |
* @postcondition model ids are returned
|
sl@0
|
510 |
* @postcondition invariant holds
|
sl@0
|
511 |
*/
|
sl@0
|
512 |
void CCustomMmfASRController::MSrGetAllModelIDsL( TModelBankID aModelBankID, RArray<TModelID>& aModelIDs )
|
sl@0
|
513 |
{
|
sl@0
|
514 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
515 |
|
sl@0
|
516 |
TRAPD(err, iDatabase->GetAllModelIDsL(aModelBankID, aModelIDs));
|
sl@0
|
517 |
|
sl@0
|
518 |
TMMFEvent event( KUidAsrEventGetAllModelIDs, err );
|
sl@0
|
519 |
SendEventToClient( event );
|
sl@0
|
520 |
|
sl@0
|
521 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
522 |
}
|
sl@0
|
523 |
|
sl@0
|
524 |
/**
|
sl@0
|
525 |
*
|
sl@0
|
526 |
* MSrGetAllPronunciationIDsL
|
sl@0
|
527 |
* @precondition InVariant holds
|
sl@0
|
528 |
* @postcondition InVariantHolds
|
sl@0
|
529 |
*/
|
sl@0
|
530 |
void CCustomMmfASRController::MSrGetAllPronunciationIDsL( TLexiconID aLexiconID, RArray<TPronunciationID>& aPronunciationIDs )
|
sl@0
|
531 |
{
|
sl@0
|
532 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
533 |
|
sl@0
|
534 |
TRAPD(err, iDatabase->GetAllPronunciationIDsL(aLexiconID, aPronunciationIDs));
|
sl@0
|
535 |
|
sl@0
|
536 |
TMMFEvent event( KUidAsrEventGetAllPronunciationIDs, err );
|
sl@0
|
537 |
SendEventToClient( event );
|
sl@0
|
538 |
|
sl@0
|
539 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
540 |
|
sl@0
|
541 |
}
|
sl@0
|
542 |
|
sl@0
|
543 |
/**
|
sl@0
|
544 |
*
|
sl@0
|
545 |
* MSrGetAllRuleIDsL
|
sl@0
|
546 |
* Get all the rule ids contained in the grammar
|
sl@0
|
547 |
* @param aLexiconID
|
sl@0
|
548 |
* @param aRuleIDs
|
sl@0
|
549 |
* @precondition Invariant holds
|
sl@0
|
550 |
* @precondition Lexicon is Loaded
|
sl@0
|
551 |
* @postcondition Invariant holds
|
sl@0
|
552 |
*/
|
sl@0
|
553 |
void CCustomMmfASRController::MSrGetAllRuleIDsL( TLexiconID aLexiconID, RArray<TRuleID>& aRuleIDs )
|
sl@0
|
554 |
{
|
sl@0
|
555 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
556 |
|
sl@0
|
557 |
TRAPD(err, iDatabase->GetAllRuleIDsL(aLexiconID, aRuleIDs));
|
sl@0
|
558 |
|
sl@0
|
559 |
TMMFEvent event( KUidAsrEventGetAllRuleIDs, err );
|
sl@0
|
560 |
SendEventToClient( event );
|
sl@0
|
561 |
|
sl@0
|
562 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
563 |
}
|
sl@0
|
564 |
|
sl@0
|
565 |
|
sl@0
|
566 |
void CCustomMmfASRController::MSrGetAllClientModelBankIDsL(RArray<TModelBankID>& aModelBankIDs )
|
sl@0
|
567 |
{
|
sl@0
|
568 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
569 |
|
sl@0
|
570 |
TRAPD(err, iDatabase->GetAllModelBankIDsL(aModelBankIDs,ETrue));
|
sl@0
|
571 |
|
sl@0
|
572 |
TMMFEvent event( KUidAsrEventGetAllClientModelBankIDs, err );
|
sl@0
|
573 |
SendEventToClient( event );
|
sl@0
|
574 |
|
sl@0
|
575 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
576 |
}
|
sl@0
|
577 |
|
sl@0
|
578 |
void CCustomMmfASRController::MSrGetAllClientLexiconIDsL(RArray<TLexiconID>& aLexiconIDs )
|
sl@0
|
579 |
{
|
sl@0
|
580 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
581 |
|
sl@0
|
582 |
TRAPD(err, iDatabase->GetAllLexiconIDsL(aLexiconIDs, ETrue));
|
sl@0
|
583 |
|
sl@0
|
584 |
TMMFEvent event( KUidAsrEventGetAllClientLexiconIDs, err );
|
sl@0
|
585 |
SendEventToClient( event );
|
sl@0
|
586 |
|
sl@0
|
587 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
588 |
|
sl@0
|
589 |
}
|
sl@0
|
590 |
|
sl@0
|
591 |
void CCustomMmfASRController::MSrGetAllClientGrammarIDsL(RArray<TGrammarID>& aGrammarIDs )
|
sl@0
|
592 |
{
|
sl@0
|
593 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
594 |
|
sl@0
|
595 |
TRAPD(err, iDatabase->GetAllGrammarIDsL(aGrammarIDs, ETrue));
|
sl@0
|
596 |
|
sl@0
|
597 |
TMMFEvent event( KUidAsrEventGetAllClientGrammarIDs, err );
|
sl@0
|
598 |
SendEventToClient( event );
|
sl@0
|
599 |
|
sl@0
|
600 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
601 |
}
|
sl@0
|
602 |
|
sl@0
|
603 |
void CCustomMmfASRController::MSrGetAllModelBankIDsL(RArray<TModelBankID>& aModelBankIDs )
|
sl@0
|
604 |
{
|
sl@0
|
605 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
606 |
|
sl@0
|
607 |
TRAPD(err, iDatabase->GetAllModelBankIDsL(aModelBankIDs));
|
sl@0
|
608 |
|
sl@0
|
609 |
TMMFEvent event( KUidAsrEventGetAllModelBankIDs, err );
|
sl@0
|
610 |
SendEventToClient( event );
|
sl@0
|
611 |
|
sl@0
|
612 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
613 |
}
|
sl@0
|
614 |
|
sl@0
|
615 |
void CCustomMmfASRController::MSrGetAllLexiconIDsL(RArray<TLexiconID>& aLexiconIDs )
|
sl@0
|
616 |
{
|
sl@0
|
617 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
618 |
|
sl@0
|
619 |
TRAPD(err, iDatabase->GetAllLexiconIDsL(aLexiconIDs));
|
sl@0
|
620 |
|
sl@0
|
621 |
TMMFEvent event( KUidAsrEventGetAllLexiconIDs, err );
|
sl@0
|
622 |
SendEventToClient( event );
|
sl@0
|
623 |
|
sl@0
|
624 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
625 |
|
sl@0
|
626 |
}
|
sl@0
|
627 |
|
sl@0
|
628 |
void CCustomMmfASRController::MSrGetAllGrammarIDsL(RArray<TGrammarID>& aGrammarIDs )
|
sl@0
|
629 |
{
|
sl@0
|
630 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
631 |
|
sl@0
|
632 |
TRAPD(err, iDatabase->GetAllGrammarIDsL(aGrammarIDs));
|
sl@0
|
633 |
|
sl@0
|
634 |
TMMFEvent event( KUidAsrEventGetAllGrammarIDs, err );
|
sl@0
|
635 |
SendEventToClient( event );
|
sl@0
|
636 |
|
sl@0
|
637 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
638 |
}
|
sl@0
|
639 |
|
sl@0
|
640 |
|
sl@0
|
641 |
/**
|
sl@0
|
642 |
*
|
sl@0
|
643 |
* MSrGetAvailableStorageL
|
sl@0
|
644 |
* gets the available storage
|
sl@0
|
645 |
* For this simulation the function always returns zero space available
|
sl@0
|
646 |
* @parameter aCount
|
sl@0
|
647 |
* @precondition Invariant holds
|
sl@0
|
648 |
*
|
sl@0
|
649 |
*/
|
sl@0
|
650 |
void CCustomMmfASRController::MSrGetAvailableStorageL( TInt& aCount )
|
sl@0
|
651 |
{
|
sl@0
|
652 |
//[ assert the invariant ]
|
sl@0
|
653 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
654 |
|
sl@0
|
655 |
//[ for now we will return no space available ]
|
sl@0
|
656 |
aCount = 0;
|
sl@0
|
657 |
|
sl@0
|
658 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
659 |
}
|
sl@0
|
660 |
|
sl@0
|
661 |
/**
|
sl@0
|
662 |
*
|
sl@0
|
663 |
* MSrGetEnginePropertiesL
|
sl@0
|
664 |
* @param aProperties
|
sl@0
|
665 |
* @precondition Invariant holds
|
sl@0
|
666 |
*
|
sl@0
|
667 |
*/
|
sl@0
|
668 |
void CCustomMmfASRController::MSrGetEnginePropertiesL( const RArray<TInt>& aPropertyId,
|
sl@0
|
669 |
RArray<TInt>& aPropertyValue )
|
sl@0
|
670 |
{
|
sl@0
|
671 |
//[ assert the invariant ]
|
sl@0
|
672 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
673 |
|
sl@0
|
674 |
//[ empty the src array ]
|
sl@0
|
675 |
aPropertyValue.Reset();
|
sl@0
|
676 |
|
sl@0
|
677 |
//[ for all the ids specified ]
|
sl@0
|
678 |
for( TInt count = 0; count < aPropertyId.Count(); count++ )
|
sl@0
|
679 |
{
|
sl@0
|
680 |
//[ we are just faking this for the moment ]
|
sl@0
|
681 |
aPropertyValue.Append( count );
|
sl@0
|
682 |
}
|
sl@0
|
683 |
|
sl@0
|
684 |
//[assert there are properties for all the ids]
|
sl@0
|
685 |
__ASSERT_ALWAYS( aPropertyValue.Count() == aPropertyId.Count(), Panic(EPostConditionViolation) );
|
sl@0
|
686 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
687 |
}
|
sl@0
|
688 |
|
sl@0
|
689 |
/**
|
sl@0
|
690 |
*
|
sl@0
|
691 |
* MSrLoadEngineParametersL
|
sl@0
|
692 |
*
|
sl@0
|
693 |
*/
|
sl@0
|
694 |
void CCustomMmfASRController::MSrLoadEngineParametersL( const RArray<TInt>& aParameterId,
|
sl@0
|
695 |
const RArray<TInt>& aParameterValue )
|
sl@0
|
696 |
{
|
sl@0
|
697 |
TBool pass = ETrue;
|
sl@0
|
698 |
if (aParameterId.Count()!=KNumParameters ||
|
sl@0
|
699 |
aParameterValue.Count()!=KNumParameters)
|
sl@0
|
700 |
pass = EFalse;
|
sl@0
|
701 |
else
|
sl@0
|
702 |
{
|
sl@0
|
703 |
TInt i;
|
sl@0
|
704 |
for (i=0;i<aParameterId.Count() && pass;i++)
|
sl@0
|
705 |
if (aParameterId[i]!=KParameterIDs[i])
|
sl@0
|
706 |
pass = EFalse;
|
sl@0
|
707 |
|
sl@0
|
708 |
for (i=0;i<aParameterValue.Count() && pass;i++)
|
sl@0
|
709 |
if (aParameterValue[i]!=KParameterValues[i])
|
sl@0
|
710 |
pass = EFalse;
|
sl@0
|
711 |
|
sl@0
|
712 |
|
sl@0
|
713 |
}
|
sl@0
|
714 |
if (pass)
|
sl@0
|
715 |
{
|
sl@0
|
716 |
TMMFEvent event( KUidTestASRLoadParameters, KErrNone );
|
sl@0
|
717 |
SendEventToClient(event);
|
sl@0
|
718 |
}
|
sl@0
|
719 |
else
|
sl@0
|
720 |
{
|
sl@0
|
721 |
TMMFEvent event( KUidTestASRLoadParameters, KErrArgument );
|
sl@0
|
722 |
SendEventToClient(event);
|
sl@0
|
723 |
}
|
sl@0
|
724 |
}
|
sl@0
|
725 |
|
sl@0
|
726 |
/**
|
sl@0
|
727 |
*
|
sl@0
|
728 |
* MSrGetModelCountL
|
sl@0
|
729 |
* @param aModelBankID
|
sl@0
|
730 |
* @param aCount
|
sl@0
|
731 |
* @precondition Invariant holds
|
sl@0
|
732 |
* @precondition model is loaded
|
sl@0
|
733 |
* @postcondition Invariant holds
|
sl@0
|
734 |
* @postcondition modelcount >=0
|
sl@0
|
735 |
*/
|
sl@0
|
736 |
void CCustomMmfASRController::MSrGetModelCountL( TModelBankID aModelBankID, TInt& aCount )
|
sl@0
|
737 |
{
|
sl@0
|
738 |
//[ assert the invariant ]
|
sl@0
|
739 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
740 |
|
sl@0
|
741 |
RArray<TPronunciationID> ids;
|
sl@0
|
742 |
CleanupClosePushL(ids);
|
sl@0
|
743 |
TRAPD(err, iDatabase->GetAllModelIDsL(aModelBankID,ids));
|
sl@0
|
744 |
|
sl@0
|
745 |
if (err==KErrNone)
|
sl@0
|
746 |
aCount = ids.Count();
|
sl@0
|
747 |
|
sl@0
|
748 |
CleanupStack::PopAndDestroy(&ids);
|
sl@0
|
749 |
|
sl@0
|
750 |
TMMFEvent event( KUidAsrEventGetModelCount, err );
|
sl@0
|
751 |
SendEventToClient( event );
|
sl@0
|
752 |
|
sl@0
|
753 |
|
sl@0
|
754 |
//[ assert the invariant ]
|
sl@0
|
755 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
756 |
}
|
sl@0
|
757 |
|
sl@0
|
758 |
|
sl@0
|
759 |
|
sl@0
|
760 |
/**
|
sl@0
|
761 |
*
|
sl@0
|
762 |
* MSrGetRuleValidityL
|
sl@0
|
763 |
* @param aGrammarID
|
sl@0
|
764 |
* @param aRuleID
|
sl@0
|
765 |
* @param aValid
|
sl@0
|
766 |
* @precondition InVariantHolds
|
sl@0
|
767 |
* @precondition state is training or state is recognition
|
sl@0
|
768 |
* @precondition grammar is loaded
|
sl@0
|
769 |
* @postcondition InVariantHolds
|
sl@0
|
770 |
*/
|
sl@0
|
771 |
void CCustomMmfASRController::MSrGetRuleValidityL( TGrammarID aGrammarID, TRuleID aRuleID, TBool& aValid )
|
sl@0
|
772 |
{
|
sl@0
|
773 |
//[ assert the invariant ]
|
sl@0
|
774 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
775 |
//[ precondition the schema exists ]
|
sl@0
|
776 |
|
sl@0
|
777 |
CSDDatabase::RSDRuleTable ruleTable(*iDatabase);
|
sl@0
|
778 |
CleanupClosePushL(ruleTable);
|
sl@0
|
779 |
ruleTable.OpenL(aGrammarID);
|
sl@0
|
780 |
TRAPD(err, aValid = ruleTable.IsRuleValidL(aRuleID));
|
sl@0
|
781 |
CleanupStack::PopAndDestroy(&ruleTable);
|
sl@0
|
782 |
|
sl@0
|
783 |
TMMFEvent event( KUidAsrEventGetRuleValidity, err );
|
sl@0
|
784 |
SendEventToClient( event );
|
sl@0
|
785 |
|
sl@0
|
786 |
//[ assert the invariant ]
|
sl@0
|
787 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
788 |
}
|
sl@0
|
789 |
|
sl@0
|
790 |
/**
|
sl@0
|
791 |
*
|
sl@0
|
792 |
* MSrGetUtteranceDurationL
|
sl@0
|
793 |
* @param aModelBankID
|
sl@0
|
794 |
* @param aModelID
|
sl@0
|
795 |
* @param aDuration
|
sl@0
|
796 |
* @param aFromMemory
|
sl@0
|
797 |
*
|
sl@0
|
798 |
*/
|
sl@0
|
799 |
void CCustomMmfASRController::MSrGetUtteranceDurationL( TModelBankID aModelBankID, TModelID aModelID,
|
sl@0
|
800 |
TTimeIntervalMicroSeconds32& aDuration)
|
sl@0
|
801 |
{
|
sl@0
|
802 |
//[ assert the Invariant ]
|
sl@0
|
803 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
804 |
|
sl@0
|
805 |
CSDDatabase::TModelData modelData = CSDDatabase::TModelData();
|
sl@0
|
806 |
|
sl@0
|
807 |
TInt err;
|
sl@0
|
808 |
TRAP(err, iDatabase->GetModelDataL(aModelBankID, aModelID, modelData));
|
sl@0
|
809 |
if (err==KErrNone)
|
sl@0
|
810 |
{
|
sl@0
|
811 |
aDuration = modelData.iUtteranceDurationMicroSeconds;
|
sl@0
|
812 |
}
|
sl@0
|
813 |
|
sl@0
|
814 |
TMMFEvent event( KUidAsrEventGetUtteranceDuration, err );
|
sl@0
|
815 |
SendEventToClient( event );
|
sl@0
|
816 |
|
sl@0
|
817 |
|
sl@0
|
818 |
//[ assert the Invariant ]
|
sl@0
|
819 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
820 |
}
|
sl@0
|
821 |
|
sl@0
|
822 |
/**
|
sl@0
|
823 |
*
|
sl@0
|
824 |
* MSrLoadGrammarL
|
sl@0
|
825 |
* @param aGrammarID
|
sl@0
|
826 |
* @precondition aGrammarId is supported by the test controller
|
sl@0
|
827 |
* @postcondition aGrammarId == id of loaded grammar
|
sl@0
|
828 |
*/
|
sl@0
|
829 |
void CCustomMmfASRController::MSrLoadGrammarL( TGrammarID aGrammarID )
|
sl@0
|
830 |
{
|
sl@0
|
831 |
//[ assert the Invariant ]
|
sl@0
|
832 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
833 |
|
sl@0
|
834 |
//[ must be in trainning or recognition state ]
|
sl@0
|
835 |
__ASSERT_ALWAYS( (State() == ESRecognition ) || ( State() == ESTraining ), Panic(EBadState) );
|
sl@0
|
836 |
|
sl@0
|
837 |
TInt err = KErrNone;
|
sl@0
|
838 |
if (iDatabase->GrammarExistsL(aGrammarID))
|
sl@0
|
839 |
{
|
sl@0
|
840 |
iLoadedGrammarID = aGrammarID;
|
sl@0
|
841 |
}
|
sl@0
|
842 |
else
|
sl@0
|
843 |
err = KErrNotFound;
|
sl@0
|
844 |
|
sl@0
|
845 |
TMMFEvent event( KUidAsrEventLoadGrammar, err );
|
sl@0
|
846 |
SendEventToClient( event );
|
sl@0
|
847 |
|
sl@0
|
848 |
//[ assert the Invariant ]
|
sl@0
|
849 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
850 |
}
|
sl@0
|
851 |
|
sl@0
|
852 |
/**
|
sl@0
|
853 |
*
|
sl@0
|
854 |
* MSrLoadLexiconL
|
sl@0
|
855 |
* @param aLexiconID
|
sl@0
|
856 |
* @precondition Invariant Holds
|
sl@0
|
857 |
* @precondition state is Training or Recognition
|
sl@0
|
858 |
* @precondition controller supports the lexicon
|
sl@0
|
859 |
* @postcondition iLexicon has id aLexiconId
|
sl@0
|
860 |
* @psotcondition InVariant holds
|
sl@0
|
861 |
*/
|
sl@0
|
862 |
void CCustomMmfASRController::MSrLoadLexiconL( TLexiconID aLexiconID )
|
sl@0
|
863 |
{
|
sl@0
|
864 |
//[ assert the Invariant ]
|
sl@0
|
865 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
866 |
|
sl@0
|
867 |
//[ must be in trainning or recognition state ]
|
sl@0
|
868 |
__ASSERT_ALWAYS( (State() == ESRecognition ) || ( State() == ESTraining ), Panic(EBadState));
|
sl@0
|
869 |
|
sl@0
|
870 |
TInt err = KErrNone;
|
sl@0
|
871 |
if (iDatabase->LexiconExistsL(aLexiconID))
|
sl@0
|
872 |
{
|
sl@0
|
873 |
iLoadedLexiconID = aLexiconID;
|
sl@0
|
874 |
}
|
sl@0
|
875 |
else
|
sl@0
|
876 |
err = KErrNotFound;
|
sl@0
|
877 |
|
sl@0
|
878 |
TMMFEvent event( KUidAsrEventLoadLexicon, err );
|
sl@0
|
879 |
SendEventToClient( event );
|
sl@0
|
880 |
|
sl@0
|
881 |
//[ assert the Invariant ]
|
sl@0
|
882 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
883 |
}
|
sl@0
|
884 |
|
sl@0
|
885 |
/**
|
sl@0
|
886 |
*
|
sl@0
|
887 |
* MSrLoadModelsL
|
sl@0
|
888 |
* @param aModelBankID
|
sl@0
|
889 |
* @precondition InVariant holds
|
sl@0
|
890 |
* @precondition state is training or recognition
|
sl@0
|
891 |
* @precondition model bank is is supported by the controller
|
sl@0
|
892 |
* @postcondition modelbank id is equal to aModelBankId
|
sl@0
|
893 |
* @postcondition InVariant holds
|
sl@0
|
894 |
*/
|
sl@0
|
895 |
void CCustomMmfASRController::MSrLoadModelsL( TModelBankID aModelBankID )
|
sl@0
|
896 |
{
|
sl@0
|
897 |
//[ assert the Invariant ]
|
sl@0
|
898 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
899 |
|
sl@0
|
900 |
//[ must be in trainning or recognition state ]
|
sl@0
|
901 |
__ASSERT_ALWAYS( (State() == ESRecognition ) || ( State() == ESTraining ), Panic(EBadState));
|
sl@0
|
902 |
|
sl@0
|
903 |
TInt err = KErrNone;
|
sl@0
|
904 |
if (iDatabase->ModelBankExistsL(aModelBankID))
|
sl@0
|
905 |
{
|
sl@0
|
906 |
iLoadedModelBankID = aModelBankID;
|
sl@0
|
907 |
}
|
sl@0
|
908 |
else
|
sl@0
|
909 |
err = KErrNotFound;
|
sl@0
|
910 |
|
sl@0
|
911 |
TMMFEvent event( KUidAsrEventLoadModels, err );
|
sl@0
|
912 |
SendEventToClient( event );
|
sl@0
|
913 |
|
sl@0
|
914 |
//[ assert the Invariant ]
|
sl@0
|
915 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
916 |
|
sl@0
|
917 |
}
|
sl@0
|
918 |
|
sl@0
|
919 |
/**
|
sl@0
|
920 |
*
|
sl@0
|
921 |
* MSrPlayUtteranceL
|
sl@0
|
922 |
* @param aModelBankID
|
sl@0
|
923 |
* @param aModelID
|
sl@0
|
924 |
* @param aPlayFromMemory
|
sl@0
|
925 |
* Always plays froms memory
|
sl@0
|
926 |
*/
|
sl@0
|
927 |
void CCustomMmfASRController::MSrPlayUtteranceL( TModelBankID aModelBankID, TModelID aModelID )
|
sl@0
|
928 |
{
|
sl@0
|
929 |
//[ assert the InVariant ]
|
sl@0
|
930 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
931 |
|
sl@0
|
932 |
if (!iDatabase->ModelExistsL(aModelBankID, aModelID))
|
sl@0
|
933 |
{
|
sl@0
|
934 |
User::Leave(KErrNotFound);
|
sl@0
|
935 |
}
|
sl@0
|
936 |
else
|
sl@0
|
937 |
{
|
sl@0
|
938 |
TMMFEvent aPlayStarted( KUidAsrEventPlayStarted, KErrNone );
|
sl@0
|
939 |
SendEventToClient( aPlayStarted );
|
sl@0
|
940 |
|
sl@0
|
941 |
TMMFEvent aPlayComplete( KUidAsrEventPlay, KErrNone );
|
sl@0
|
942 |
SendEventToClient( aPlayComplete );
|
sl@0
|
943 |
}
|
sl@0
|
944 |
|
sl@0
|
945 |
//[ assert the InVariant ]
|
sl@0
|
946 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
947 |
}
|
sl@0
|
948 |
|
sl@0
|
949 |
/**
|
sl@0
|
950 |
*
|
sl@0
|
951 |
* MSrRecognizeL
|
sl@0
|
952 |
* @param aResultSet
|
sl@0
|
953 |
*
|
sl@0
|
954 |
*/
|
sl@0
|
955 |
void CCustomMmfASRController::MSrRecognizeL( CSDClientResultSet& aResultSet )
|
sl@0
|
956 |
{
|
sl@0
|
957 |
//[ assert the Invariant ]
|
sl@0
|
958 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
959 |
|
sl@0
|
960 |
//[ Precondition that we are in a recognition session ]
|
sl@0
|
961 |
if( State() != ESRecognition )
|
sl@0
|
962 |
{
|
sl@0
|
963 |
TMMFEvent recognitionFailed( KUidAsrEventRecognition, KErrNotReady );
|
sl@0
|
964 |
SendEventToClient( recognitionFailed );
|
sl@0
|
965 |
return;
|
sl@0
|
966 |
}
|
sl@0
|
967 |
|
sl@0
|
968 |
TMMFEvent recognitionReady( KUidAsrEventRecognitionReady,KErrNone );
|
sl@0
|
969 |
SendEventToClient( recognitionReady );
|
sl@0
|
970 |
|
sl@0
|
971 |
//[ return a result set ]
|
sl@0
|
972 |
iMaxResults = aResultSet.MaxResults();
|
sl@0
|
973 |
iResultSet = &aResultSet;
|
sl@0
|
974 |
|
sl@0
|
975 |
iRecognizeComplete = ETrue;
|
sl@0
|
976 |
|
sl@0
|
977 |
//[ assert the Invariant ]
|
sl@0
|
978 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
979 |
}
|
sl@0
|
980 |
|
sl@0
|
981 |
/*
|
sl@0
|
982 |
*
|
sl@0
|
983 |
* MSrRecordL
|
sl@0
|
984 |
* @param aRecordTime
|
sl@0
|
985 |
* @precondition InVariant holds
|
sl@0
|
986 |
* @postcondition
|
sl@0
|
987 |
*/
|
sl@0
|
988 |
void CCustomMmfASRController::MSrRecordL( TTimeIntervalMicroSeconds32 aRecordTime )
|
sl@0
|
989 |
{
|
sl@0
|
990 |
//[ assert the invariant ]
|
sl@0
|
991 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
992 |
|
sl@0
|
993 |
//[ remember the record time
|
sl@0
|
994 |
// and for the purpose of simulation recording takes zero time ]
|
sl@0
|
995 |
iRecordTime = aRecordTime ;
|
sl@0
|
996 |
|
sl@0
|
997 |
TMMFEvent aRecordStartedEvent( KUidAsrEventRecordStarted, KErrNone );
|
sl@0
|
998 |
SendEventToClient( aRecordStartedEvent );
|
sl@0
|
999 |
|
sl@0
|
1000 |
TMMFEvent aEndOfUtteranceEvent( KUidAsrEventEouDetected, KErrNone );
|
sl@0
|
1001 |
SendEventToClient( aEndOfUtteranceEvent );
|
sl@0
|
1002 |
|
sl@0
|
1003 |
if( iRecognizeComplete )
|
sl@0
|
1004 |
{
|
sl@0
|
1005 |
iRecognizeComplete = EFalse;
|
sl@0
|
1006 |
|
sl@0
|
1007 |
for (TInt i=0;i<iMaxResults && i<KMaxAvailableResults;i++)
|
sl@0
|
1008 |
{
|
sl@0
|
1009 |
CSDClientResult& result = CONST_CAST(CSDClientResult&, iResultSet->At(i));
|
sl@0
|
1010 |
result.SetGrammarID(KResultsGrammarID[i]);
|
sl@0
|
1011 |
result.SetRuleID(KResultsRuleID[i]);
|
sl@0
|
1012 |
}
|
sl@0
|
1013 |
|
sl@0
|
1014 |
TMMFEvent recognitionComplete( KUidAsrEventRecognition, KErrNone );
|
sl@0
|
1015 |
SendEventToClient( recognitionComplete );
|
sl@0
|
1016 |
}
|
sl@0
|
1017 |
|
sl@0
|
1018 |
//[ assert the invaraint ]
|
sl@0
|
1019 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1020 |
}
|
sl@0
|
1021 |
|
sl@0
|
1022 |
/**
|
sl@0
|
1023 |
*
|
sl@0
|
1024 |
* MSrRemoveGrammarL
|
sl@0
|
1025 |
* Interpreted as unload from memory here
|
sl@0
|
1026 |
*
|
sl@0
|
1027 |
*/
|
sl@0
|
1028 |
void CCustomMmfASRController::MSrRemoveGrammarL( TGrammarID aGrammarID )
|
sl@0
|
1029 |
{
|
sl@0
|
1030 |
//[ assert the invaraint ]
|
sl@0
|
1031 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));
|
sl@0
|
1032 |
|
sl@0
|
1033 |
|
sl@0
|
1034 |
if (iLoadedGrammarID == aGrammarID)
|
sl@0
|
1035 |
{
|
sl@0
|
1036 |
TMMFEvent event( KUidAsrEventRemoveGrammar, KErrInUse );
|
sl@0
|
1037 |
SendEventToClient( event );
|
sl@0
|
1038 |
}
|
sl@0
|
1039 |
else
|
sl@0
|
1040 |
{
|
sl@0
|
1041 |
TRAPD(err, iDatabase->RemoveGrammarL(aGrammarID));
|
sl@0
|
1042 |
//[ send message to client of success ]
|
sl@0
|
1043 |
TMMFEvent event( KUidAsrEventRemoveGrammar, err );
|
sl@0
|
1044 |
SendEventToClient( event );
|
sl@0
|
1045 |
}
|
sl@0
|
1046 |
|
sl@0
|
1047 |
//[ assert the invaraint ]
|
sl@0
|
1048 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1049 |
}
|
sl@0
|
1050 |
|
sl@0
|
1051 |
/**
|
sl@0
|
1052 |
*
|
sl@0
|
1053 |
* MSrRemoveLexiconL
|
sl@0
|
1054 |
* @param aLexiconID
|
sl@0
|
1055 |
* slightly different interpretation here
|
sl@0
|
1056 |
*/
|
sl@0
|
1057 |
void CCustomMmfASRController::MSrRemoveLexiconL( TLexiconID aLexiconID )
|
sl@0
|
1058 |
{
|
sl@0
|
1059 |
//[ assert the invaraint ]
|
sl@0
|
1060 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1061 |
|
sl@0
|
1062 |
|
sl@0
|
1063 |
if (iLoadedLexiconID == aLexiconID)
|
sl@0
|
1064 |
{
|
sl@0
|
1065 |
TMMFEvent event( KUidAsrEventRemoveLexicon, KErrInUse );
|
sl@0
|
1066 |
SendEventToClient( event );
|
sl@0
|
1067 |
}
|
sl@0
|
1068 |
else
|
sl@0
|
1069 |
{
|
sl@0
|
1070 |
TRAPD(err, iDatabase->RemoveLexiconL(aLexiconID));
|
sl@0
|
1071 |
//[ send message to client of success ]
|
sl@0
|
1072 |
TMMFEvent event( KUidAsrEventRemoveLexicon, err );
|
sl@0
|
1073 |
SendEventToClient( event );
|
sl@0
|
1074 |
}
|
sl@0
|
1075 |
|
sl@0
|
1076 |
//[ assert the invaraint ]
|
sl@0
|
1077 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1078 |
|
sl@0
|
1079 |
|
sl@0
|
1080 |
}
|
sl@0
|
1081 |
|
sl@0
|
1082 |
/**
|
sl@0
|
1083 |
*
|
sl@0
|
1084 |
* MSrRemoveModelBankL
|
sl@0
|
1085 |
*
|
sl@0
|
1086 |
*
|
sl@0
|
1087 |
*/
|
sl@0
|
1088 |
void CCustomMmfASRController::MSrRemoveModelBankL( TModelBankID aModelBankID )
|
sl@0
|
1089 |
{
|
sl@0
|
1090 |
//[ assert the invaraint ]
|
sl@0
|
1091 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1092 |
|
sl@0
|
1093 |
|
sl@0
|
1094 |
if (iLoadedModelBankID == aModelBankID)
|
sl@0
|
1095 |
{
|
sl@0
|
1096 |
TMMFEvent event( KUidAsrEventRemoveModelBank, KErrInUse );
|
sl@0
|
1097 |
SendEventToClient( event );
|
sl@0
|
1098 |
}
|
sl@0
|
1099 |
else
|
sl@0
|
1100 |
{
|
sl@0
|
1101 |
TRAPD(err, iDatabase->RemoveModelBankL(aModelBankID));
|
sl@0
|
1102 |
//[ send message to client of success ]
|
sl@0
|
1103 |
TMMFEvent event( KUidAsrEventRemoveModelBank, err );
|
sl@0
|
1104 |
SendEventToClient( event );
|
sl@0
|
1105 |
}
|
sl@0
|
1106 |
|
sl@0
|
1107 |
//[ assert the invaraint ]
|
sl@0
|
1108 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1109 |
|
sl@0
|
1110 |
}
|
sl@0
|
1111 |
|
sl@0
|
1112 |
/**
|
sl@0
|
1113 |
*
|
sl@0
|
1114 |
* MSrRemoveModelL
|
sl@0
|
1115 |
* @param aModelBankID
|
sl@0
|
1116 |
* @param aModeID
|
sl@0
|
1117 |
* @precondition InVariant holds
|
sl@0
|
1118 |
* @precondition model bank exists
|
sl@0
|
1119 |
* @precondition modelbank contains the model
|
sl@0
|
1120 |
* @postcondition model bank does not contain model
|
sl@0
|
1121 |
*
|
sl@0
|
1122 |
*/
|
sl@0
|
1123 |
void CCustomMmfASRController::MSrRemoveModelL( TModelBankID aModelBankID, TModelID aModelID )
|
sl@0
|
1124 |
{
|
sl@0
|
1125 |
//[ assert the invariant ]
|
sl@0
|
1126 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1127 |
|
sl@0
|
1128 |
if (iLoadedModelBankID == aModelBankID)
|
sl@0
|
1129 |
{
|
sl@0
|
1130 |
TMMFEvent event( KUidAsrEventRemoveModelBank, KErrInUse );
|
sl@0
|
1131 |
SendEventToClient( event );
|
sl@0
|
1132 |
}
|
sl@0
|
1133 |
else
|
sl@0
|
1134 |
{
|
sl@0
|
1135 |
TInt err = KErrNone;
|
sl@0
|
1136 |
if (!iDatabase->ModelBankExistsL(aModelBankID))
|
sl@0
|
1137 |
err = KErrNotFound;
|
sl@0
|
1138 |
else
|
sl@0
|
1139 |
{
|
sl@0
|
1140 |
CSDDatabase::RSDModelTable view(*iDatabase);
|
sl@0
|
1141 |
CleanupClosePushL(view);
|
sl@0
|
1142 |
view.OpenL(aModelBankID);
|
sl@0
|
1143 |
if (view.FindModelL(aModelID))
|
sl@0
|
1144 |
{
|
sl@0
|
1145 |
view.RemoveModelL(aModelID);
|
sl@0
|
1146 |
}
|
sl@0
|
1147 |
else
|
sl@0
|
1148 |
err = KErrNotFound;
|
sl@0
|
1149 |
|
sl@0
|
1150 |
CleanupStack::PopAndDestroy(&view);
|
sl@0
|
1151 |
}
|
sl@0
|
1152 |
//[ send message to client of success ]
|
sl@0
|
1153 |
TMMFEvent event( KUidAsrEventRemoveModel, err );
|
sl@0
|
1154 |
SendEventToClient( event );
|
sl@0
|
1155 |
}
|
sl@0
|
1156 |
|
sl@0
|
1157 |
//[ assert the invaraint ]
|
sl@0
|
1158 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1159 |
}
|
sl@0
|
1160 |
|
sl@0
|
1161 |
/**
|
sl@0
|
1162 |
*
|
sl@0
|
1163 |
* MSrRemovePronunciationL
|
sl@0
|
1164 |
* @param aLexiconID
|
sl@0
|
1165 |
* @param aPronunciationID
|
sl@0
|
1166 |
* @precondition lexicon exists
|
sl@0
|
1167 |
* @precondition lexicon has id specified
|
sl@0
|
1168 |
* @postconfition lexicon does not have pronunication
|
sl@0
|
1169 |
*
|
sl@0
|
1170 |
*/
|
sl@0
|
1171 |
void CCustomMmfASRController::MSrRemovePronunciationL( TLexiconID aLexiconID, TPronunciationID aPronunciationID )
|
sl@0
|
1172 |
{
|
sl@0
|
1173 |
//[ assert the invaraint ]
|
sl@0
|
1174 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1175 |
|
sl@0
|
1176 |
if (iLoadedLexiconID == aLexiconID)
|
sl@0
|
1177 |
{
|
sl@0
|
1178 |
TMMFEvent event( KUidAsrEventRemovePronunciation, KErrInUse );
|
sl@0
|
1179 |
SendEventToClient( event );
|
sl@0
|
1180 |
}
|
sl@0
|
1181 |
else
|
sl@0
|
1182 |
{
|
sl@0
|
1183 |
TInt err = KErrNone;
|
sl@0
|
1184 |
if (!iDatabase->LexiconExistsL(aLexiconID))
|
sl@0
|
1185 |
err = KErrNotFound;
|
sl@0
|
1186 |
else
|
sl@0
|
1187 |
{
|
sl@0
|
1188 |
CSDDatabase::RSDPronunciationTable view(*iDatabase);
|
sl@0
|
1189 |
CleanupClosePushL(view);
|
sl@0
|
1190 |
view.OpenL(aLexiconID);
|
sl@0
|
1191 |
if (view.FindPronunciationL(aPronunciationID))
|
sl@0
|
1192 |
{
|
sl@0
|
1193 |
view.RemovePronunciationL(aPronunciationID);
|
sl@0
|
1194 |
}
|
sl@0
|
1195 |
else
|
sl@0
|
1196 |
err = KErrNotFound;
|
sl@0
|
1197 |
|
sl@0
|
1198 |
CleanupStack::PopAndDestroy(&view);
|
sl@0
|
1199 |
}
|
sl@0
|
1200 |
//[ send message to client of success ]
|
sl@0
|
1201 |
TMMFEvent event( KUidAsrEventRemovePronunciation, err );
|
sl@0
|
1202 |
SendEventToClient( event );
|
sl@0
|
1203 |
}
|
sl@0
|
1204 |
|
sl@0
|
1205 |
//[ assert the invaraint ]
|
sl@0
|
1206 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1207 |
}
|
sl@0
|
1208 |
|
sl@0
|
1209 |
/**
|
sl@0
|
1210 |
*
|
sl@0
|
1211 |
* MSrRemoveRuleL
|
sl@0
|
1212 |
* @param aLexiconID
|
sl@0
|
1213 |
* @param aRuleID
|
sl@0
|
1214 |
* @precondition InVariant holds
|
sl@0
|
1215 |
* @precondition grammar is loaded
|
sl@0
|
1216 |
* @precondition grammar has id specified
|
sl@0
|
1217 |
* @postcondition grammar does not contain rule
|
sl@0
|
1218 |
*
|
sl@0
|
1219 |
*/
|
sl@0
|
1220 |
void CCustomMmfASRController::MSrRemoveRuleL( TGrammarID aGrammarID, TRuleID aRuleID )
|
sl@0
|
1221 |
{
|
sl@0
|
1222 |
//[ assert the invaraint ]
|
sl@0
|
1223 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1224 |
|
sl@0
|
1225 |
if (iLoadedGrammarID == aGrammarID)
|
sl@0
|
1226 |
{
|
sl@0
|
1227 |
TMMFEvent event( KUidAsrEventRemoveRule, KErrInUse );
|
sl@0
|
1228 |
SendEventToClient( event );
|
sl@0
|
1229 |
}
|
sl@0
|
1230 |
else
|
sl@0
|
1231 |
{
|
sl@0
|
1232 |
TInt err = KErrNone;
|
sl@0
|
1233 |
if (!iDatabase->GrammarExistsL(aGrammarID))
|
sl@0
|
1234 |
err = KErrNotFound;
|
sl@0
|
1235 |
else
|
sl@0
|
1236 |
{
|
sl@0
|
1237 |
CSDDatabase::RSDRuleTable view(*iDatabase);
|
sl@0
|
1238 |
CleanupClosePushL(view);
|
sl@0
|
1239 |
view.OpenL(aGrammarID);
|
sl@0
|
1240 |
if (view.FindRuleL(aRuleID))
|
sl@0
|
1241 |
{
|
sl@0
|
1242 |
view.RemoveRuleL(aRuleID);
|
sl@0
|
1243 |
}
|
sl@0
|
1244 |
else
|
sl@0
|
1245 |
err = KErrNotFound;
|
sl@0
|
1246 |
|
sl@0
|
1247 |
CleanupStack::PopAndDestroy(&view);
|
sl@0
|
1248 |
}
|
sl@0
|
1249 |
//[ send message to client of success ]
|
sl@0
|
1250 |
TMMFEvent event( KUidAsrEventRemoveRule, err );
|
sl@0
|
1251 |
SendEventToClient( event );
|
sl@0
|
1252 |
}
|
sl@0
|
1253 |
|
sl@0
|
1254 |
//[ assert the invaraint ]
|
sl@0
|
1255 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1256 |
}
|
sl@0
|
1257 |
|
sl@0
|
1258 |
/**
|
sl@0
|
1259 |
*
|
sl@0
|
1260 |
* MSrStartRecSessionL
|
sl@0
|
1261 |
* @param aMode
|
sl@0
|
1262 |
* @precondition mode is valid
|
sl@0
|
1263 |
*
|
sl@0
|
1264 |
*/
|
sl@0
|
1265 |
void CCustomMmfASRController::MSrStartRecSessionL( TRecognitionMode aMode )
|
sl@0
|
1266 |
{
|
sl@0
|
1267 |
//[ assert the invariant holds ]
|
sl@0
|
1268 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1269 |
|
sl@0
|
1270 |
//[ precondition the mode is valid ]
|
sl@0
|
1271 |
if( (aMode < ESdMode ) || ( aMode > ESdSiMode) )
|
sl@0
|
1272 |
{
|
sl@0
|
1273 |
User::Leave( KErrArgument );
|
sl@0
|
1274 |
}
|
sl@0
|
1275 |
|
sl@0
|
1276 |
//[ it does not matter which state we are in we can
|
sl@0
|
1277 |
// always transition to recognition ]
|
sl@0
|
1278 |
SetState( ESRecognition );
|
sl@0
|
1279 |
|
sl@0
|
1280 |
//[ set the recognition mode ]
|
sl@0
|
1281 |
iRecognitionMode = aMode ;
|
sl@0
|
1282 |
|
sl@0
|
1283 |
//[ assert the Invariant holds ]
|
sl@0
|
1284 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1285 |
|
sl@0
|
1286 |
//[ assert the post condition that the mode has been en
|
sl@0
|
1287 |
__ASSERT_ALWAYS( iRecognitionMode == aMode, Panic(EPostConditionViolation) );
|
sl@0
|
1288 |
}
|
sl@0
|
1289 |
|
sl@0
|
1290 |
/**
|
sl@0
|
1291 |
*
|
sl@0
|
1292 |
* MSrTrainL
|
sl@0
|
1293 |
* @param aModelBankID
|
sl@0
|
1294 |
* @param aModelID
|
sl@0
|
1295 |
*
|
sl@0
|
1296 |
*/
|
sl@0
|
1297 |
void CCustomMmfASRController::MSrTrainL( TModelBankID aModelBankID, TModelID& aModelID )
|
sl@0
|
1298 |
{
|
sl@0
|
1299 |
// fixed duration to return for training
|
sl@0
|
1300 |
const TInt KUtteranceDuration = 2000;
|
sl@0
|
1301 |
//[ must be in training mode
|
sl@0
|
1302 |
// must have a lexicon that is not empty
|
sl@0
|
1303 |
// must have a grammar
|
sl@0
|
1304 |
// must have a model bank loaded ]
|
sl@0
|
1305 |
//[ presume train adds a new model id to the bank ]
|
sl@0
|
1306 |
//[ finally send event to client ]
|
sl@0
|
1307 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1308 |
TMMFEvent event( KUidAsrEventTrainReady, KErrNone );
|
sl@0
|
1309 |
SendEventToClient( event );
|
sl@0
|
1310 |
|
sl@0
|
1311 |
// [ precondition model bank is loaded ]
|
sl@0
|
1312 |
if( iLoadedModelBankID != aModelBankID )
|
sl@0
|
1313 |
{
|
sl@0
|
1314 |
TMMFEvent event( KUidAsrEventTrain, KErrNotReady );
|
sl@0
|
1315 |
SendEventToClient( event );
|
sl@0
|
1316 |
return;
|
sl@0
|
1317 |
}
|
sl@0
|
1318 |
|
sl@0
|
1319 |
TInt err = KErrNone;
|
sl@0
|
1320 |
|
sl@0
|
1321 |
CSDDatabase::TModelData modelData=CSDDatabase::TModelData();
|
sl@0
|
1322 |
modelData.iUtteranceDurationMicroSeconds = KUtteranceDuration;
|
sl@0
|
1323 |
TRAP(err, aModelID = iDatabase->CreateModelL( aModelBankID, modelData));
|
sl@0
|
1324 |
|
sl@0
|
1325 |
TMMFEvent trainCompleteEvent( KUidAsrEventTrain, err );
|
sl@0
|
1326 |
SendEventToClient( trainCompleteEvent );
|
sl@0
|
1327 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1328 |
}
|
sl@0
|
1329 |
|
sl@0
|
1330 |
/**
|
sl@0
|
1331 |
*
|
sl@0
|
1332 |
* MSrUnloadRuleL
|
sl@0
|
1333 |
* @param aGrammarID
|
sl@0
|
1334 |
* @param aRuleID
|
sl@0
|
1335 |
* @precondition state == ESTraining
|
sl@0
|
1336 |
* @postcondition grammar does not contain rule
|
sl@0
|
1337 |
*
|
sl@0
|
1338 |
*/
|
sl@0
|
1339 |
void CCustomMmfASRController::MSrUnloadRuleL( TGrammarID aGrammarID, TRuleID aRuleID )
|
sl@0
|
1340 |
{
|
sl@0
|
1341 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1342 |
|
sl@0
|
1343 |
//[ precondition grammar loaded is grammar with id ]
|
sl@0
|
1344 |
__ASSERT_ALWAYS( iLoadedGrammarID == aGrammarID, Panic(EPreConditionViolation) );
|
sl@0
|
1345 |
|
sl@0
|
1346 |
TBool ruleExists = EFalse;
|
sl@0
|
1347 |
|
sl@0
|
1348 |
TRAPD(err, ruleExists = iDatabase->RuleExistsL(aGrammarID, aRuleID));
|
sl@0
|
1349 |
|
sl@0
|
1350 |
if (err == KErrNone)
|
sl@0
|
1351 |
{
|
sl@0
|
1352 |
if (!ruleExists)
|
sl@0
|
1353 |
err = KErrNotFound;
|
sl@0
|
1354 |
}
|
sl@0
|
1355 |
|
sl@0
|
1356 |
//[ send message to client of success ]
|
sl@0
|
1357 |
TMMFEvent event( KUidAsrEventUnloadRule, err );
|
sl@0
|
1358 |
SendEventToClient( event );
|
sl@0
|
1359 |
|
sl@0
|
1360 |
__ASSERT_ALWAYS(InVariant(),Panic(EBadInvariant));;
|
sl@0
|
1361 |
}
|
sl@0
|
1362 |
|
sl@0
|
1363 |
/**
|
sl@0
|
1364 |
* SendEventToClient
|
sl@0
|
1365 |
*
|
sl@0
|
1366 |
* @param aEvent
|
sl@0
|
1367 |
*/
|
sl@0
|
1368 |
TInt CCustomMmfASRController::SendEventToClient(const TMMFEvent& aEvent)
|
sl@0
|
1369 |
{
|
sl@0
|
1370 |
//now send event to client...
|
sl@0
|
1371 |
return DoSendEventToClient(aEvent);
|
sl@0
|
1372 |
}
|
sl@0
|
1373 |
|
sl@0
|
1374 |
/**
|
sl@0
|
1375 |
*
|
sl@0
|
1376 |
* GetNumberOfMetaDataEntriesL
|
sl@0
|
1377 |
*
|
sl@0
|
1378 |
* @param "TInt"
|
sl@0
|
1379 |
*
|
sl@0
|
1380 |
*/
|
sl@0
|
1381 |
void CCustomMmfASRController::GetNumberOfMetaDataEntriesL(TInt& /*aNumberOfEntries*/ )
|
sl@0
|
1382 |
{
|
sl@0
|
1383 |
//[This function is deprecated and should not have been called]
|
sl@0
|
1384 |
Panic(EDeprecatedFunction);
|
sl@0
|
1385 |
}
|
sl@0
|
1386 |
|
sl@0
|
1387 |
/**
|
sl@0
|
1388 |
* GetMetaDataEntryL
|
sl@0
|
1389 |
* @param aIndex
|
sl@0
|
1390 |
* @returns "CMMFMetaDataEntry*"
|
sl@0
|
1391 |
*/
|
sl@0
|
1392 |
CMMFMetaDataEntry* CCustomMmfASRController::GetMetaDataEntryL(TInt /*aIndex*/ )
|
sl@0
|
1393 |
{
|
sl@0
|
1394 |
//[This function is deprecated and should not have been called]
|
sl@0
|
1395 |
Panic(EDeprecatedFunction);
|
sl@0
|
1396 |
return NULL;
|
sl@0
|
1397 |
}
|
sl@0
|
1398 |
|
sl@0
|
1399 |
/**
|
sl@0
|
1400 |
* RemoveDataSourceL
|
sl@0
|
1401 |
* @param aDataSource
|
sl@0
|
1402 |
*
|
sl@0
|
1403 |
*/
|
sl@0
|
1404 |
void CCustomMmfASRController::RemoveDataSourceL(MDataSource& /*aDataSource*/ )
|
sl@0
|
1405 |
{
|
sl@0
|
1406 |
//[This function is deprecated and should not have been called]
|
sl@0
|
1407 |
Panic(EDeprecatedFunction);
|
sl@0
|
1408 |
}
|
sl@0
|
1409 |
|
sl@0
|
1410 |
/**
|
sl@0
|
1411 |
* RemoveDataSinkL
|
sl@0
|
1412 |
*
|
sl@0
|
1413 |
* @param aDataSink
|
sl@0
|
1414 |
*
|
sl@0
|
1415 |
*/
|
sl@0
|
1416 |
void CCustomMmfASRController::RemoveDataSinkL(MDataSink& /*aDataSink*/ )
|
sl@0
|
1417 |
{
|
sl@0
|
1418 |
//[This function is deprecated and should not have been called]
|
sl@0
|
1419 |
Panic(EDeprecatedFunction);
|
sl@0
|
1420 |
}
|
sl@0
|
1421 |
|
sl@0
|
1422 |
/**
|
sl@0
|
1423 |
* SetPrioritySettings
|
sl@0
|
1424 |
*
|
sl@0
|
1425 |
* @param aPrioritySettings
|
sl@0
|
1426 |
*/
|
sl@0
|
1427 |
void CCustomMmfASRController::SetPrioritySettings(const TMMFPrioritySettings& /*aPrioritySettings*/)
|
sl@0
|
1428 |
{
|
sl@0
|
1429 |
}
|
sl@0
|
1430 |
|
sl@0
|
1431 |
/**
|
sl@0
|
1432 |
*
|
sl@0
|
1433 |
* DurationL
|
sl@0
|
1434 |
*
|
sl@0
|
1435 |
* @returns TTimeIntervalMicroSeconds
|
sl@0
|
1436 |
*
|
sl@0
|
1437 |
*/
|
sl@0
|
1438 |
TTimeIntervalMicroSeconds CCustomMmfASRController::DurationL() const
|
sl@0
|
1439 |
{
|
sl@0
|
1440 |
TTimeIntervalMicroSeconds xx(0);
|
sl@0
|
1441 |
return xx;
|
sl@0
|
1442 |
}
|
sl@0
|
1443 |
|
sl@0
|
1444 |
/**
|
sl@0
|
1445 |
*
|
sl@0
|
1446 |
* InVariant
|
sl@0
|
1447 |
* @returns TBool
|
sl@0
|
1448 |
*
|
sl@0
|
1449 |
*/
|
sl@0
|
1450 |
TBool CCustomMmfASRController::InVariant() const
|
sl@0
|
1451 |
{
|
sl@0
|
1452 |
TBool status = EFalse;
|
sl@0
|
1453 |
//[ for now the invariant is simply that we have a valid state ]
|
sl@0
|
1454 |
if( (iState == ESTraining ) || ( iState == ESTraining ) || ( iState == ESRecognition ) )
|
sl@0
|
1455 |
{
|
sl@0
|
1456 |
status = ETrue;
|
sl@0
|
1457 |
}
|
sl@0
|
1458 |
|
sl@0
|
1459 |
return status;
|
sl@0
|
1460 |
}
|
sl@0
|
1461 |
|
sl@0
|
1462 |
/**
|
sl@0
|
1463 |
*
|
sl@0
|
1464 |
* State
|
sl@0
|
1465 |
* @returns TControllerState
|
sl@0
|
1466 |
*
|
sl@0
|
1467 |
*/
|
sl@0
|
1468 |
CCustomMmfASRController::TControllerState CCustomMmfASRController::State() const
|
sl@0
|
1469 |
{
|
sl@0
|
1470 |
return iState;
|
sl@0
|
1471 |
}
|