19
|
1 |
/*
|
|
2 |
* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: This is the implementation of the client interface for the
|
|
15 |
* speaker independent custom commands.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include "srsfbldvariant.hrh"
|
|
22 |
#include "nsssispeechrecognitioncustomcommands.h"
|
|
23 |
#include <nsssispeechrecognitiondatacommon.h>
|
|
24 |
#include <badesca.h>
|
|
25 |
#include "nsssispeechrecognitioncustomcommandcommon.h"
|
|
26 |
#include "nsssicustomcommanddata.h"
|
|
27 |
#include "rubydebug.h"
|
|
28 |
|
|
29 |
|
|
30 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
31 |
|
|
32 |
// -----------------------------------------------------------------------------
|
|
33 |
// RSISpeechRecognitionCustomCommands::RSISpeechRecognitionCustomCommands
|
|
34 |
// C++ constructor.
|
|
35 |
// -----------------------------------------------------------------------------
|
|
36 |
|
|
37 |
EXPORT_C RSISpeechRecognitionCustomCommands::RSISpeechRecognitionCustomCommands(
|
|
38 |
RMMFController& aController) :
|
|
39 |
RMMFCustomCommandsBase(aController,
|
|
40 |
KUidInterfaceSpeakerIndependent)
|
|
41 |
{
|
|
42 |
|
|
43 |
}
|
|
44 |
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
// RSISpeechRecognitionCustomCommands::AddRule
|
|
47 |
// Sends a command to the controller to add a rule.
|
|
48 |
// -----------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::AddRule(
|
|
51 |
TSIGrammarID aGrammarID,
|
|
52 |
TSILexiconID aLexiconID,
|
|
53 |
TSIPronunciationID aPronunciationID,
|
|
54 |
TSIRuleID& aRuleID)
|
|
55 |
{
|
|
56 |
|
|
57 |
TSrsAddRule srsAddRule(aGrammarID, aLexiconID, aPronunciationID, &aRuleID);
|
|
58 |
TSrsAddRulePckg pckg(srsAddRule);
|
|
59 |
return iController.CustomCommandSync(iDestinationPckg, ESrAddRule,
|
|
60 |
pckg, KNullDesC8); // Async
|
|
61 |
|
|
62 |
}
|
|
63 |
|
|
64 |
// -----------------------------------------------------------------------------
|
|
65 |
// RSISpeechRecognitionCustomCommands::Cancel
|
|
66 |
// Sends a command to the controller to cancel the currect asynchronous
|
|
67 |
// operation.
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
EXPORT_C void RSISpeechRecognitionCustomCommands::Cancel()
|
|
71 |
{
|
|
72 |
|
|
73 |
iController.CustomCommandSync(iDestinationPckg, ESrCancel,
|
|
74 |
KNullDesC8, KNullDesC8);
|
|
75 |
|
|
76 |
}
|
|
77 |
|
|
78 |
// -----------------------------------------------------------------------------
|
|
79 |
// RSISpeechRecognitionCustomCommands::CommitChanges
|
|
80 |
// Sends a command to the controller to commit the current changes.
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::CommitChanges()
|
|
84 |
{
|
|
85 |
|
|
86 |
return iController.CustomCommandSync(iDestinationPckg, ESrCommitChanges,
|
|
87 |
KNullDesC8, KNullDesC8); // Async
|
|
88 |
|
|
89 |
}
|
|
90 |
|
|
91 |
// -----------------------------------------------------------------------------
|
|
92 |
// RSISpeechRecognitionCustomCommands::CreateGrammar
|
|
93 |
// Sends a command to the controller to create a grammar.
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::CreateGrammar(
|
|
97 |
TSIGrammarID& aGrammarID)
|
|
98 |
{
|
|
99 |
|
|
100 |
TSrsGrammarIDPtrPckg srsGrammarIDPtrPckg = &aGrammarID;
|
|
101 |
return iController.CustomCommandSync(iDestinationPckg, ESrCreateGrammar,
|
|
102 |
srsGrammarIDPtrPckg, KNullDesC8);
|
|
103 |
|
|
104 |
}
|
|
105 |
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
// RSISpeechRecognitionCustomCommands::CreateLexicon
|
|
108 |
// Sends a command to the controller to create a lexicon.
|
|
109 |
// -----------------------------------------------------------------------------
|
|
110 |
//
|
|
111 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::CreateLexicon(
|
|
112 |
TSILexiconID& aLexiconID)
|
|
113 |
{
|
|
114 |
|
|
115 |
TSrsLexiconIDPtrPckg srsLexiconIDPtrPckg = &aLexiconID;
|
|
116 |
return iController.CustomCommandSync(iDestinationPckg, ESrCreateLexicon,
|
|
117 |
srsLexiconIDPtrPckg, KNullDesC8);
|
|
118 |
|
|
119 |
}
|
|
120 |
|
|
121 |
// -----------------------------------------------------------------------------
|
|
122 |
// RSISpeechRecognitionCustomCommands::CreateModelBank
|
|
123 |
// Sends a command to the controller to create a model bank.
|
|
124 |
// -----------------------------------------------------------------------------
|
|
125 |
//
|
|
126 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::CreateModelBank(
|
|
127 |
TSIModelBankID& aModelBankID)
|
|
128 |
{
|
|
129 |
|
|
130 |
TSrsModelBankIDPtrPckg modelBankIDPtrPckg = &aModelBankID;
|
|
131 |
return iController.CustomCommandSync(iDestinationPckg, ESrCreateModelBank,
|
|
132 |
modelBankIDPtrPckg, KNullDesC8);
|
|
133 |
|
|
134 |
}
|
|
135 |
|
|
136 |
// -----------------------------------------------------------------------------
|
|
137 |
// RSISpeechRecognitionCustomCommands::EndRecSession
|
|
138 |
// Sends a command to the controller to end the current recognition session and
|
|
139 |
// free the allocated resources.
|
|
140 |
// -----------------------------------------------------------------------------
|
|
141 |
//
|
|
142 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::EndRecSession()
|
|
143 |
{
|
|
144 |
|
|
145 |
TInt err = iController.CustomCommandSync(iDestinationPckg, ESrEndRecSession,
|
|
146 |
KNullDesC8, KNullDesC8);
|
|
147 |
return err;
|
|
148 |
|
|
149 |
}
|
|
150 |
|
|
151 |
// -----------------------------------------------------------------------------
|
|
152 |
// RSISpeechRecognitionCustomCommands::GetAllClientGrammarIDs
|
|
153 |
// Calls the controller plugin to get all client grammar IDs.
|
|
154 |
// -----------------------------------------------------------------------------
|
|
155 |
//
|
|
156 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllClientGrammarIDs()
|
|
157 |
{
|
|
158 |
|
|
159 |
return iController.CustomCommandSync(iDestinationPckg,
|
|
160 |
ESrGetAllClientGrammarIDs, KNullDesC8, KNullDesC8); // Async
|
|
161 |
|
|
162 |
}
|
|
163 |
|
|
164 |
// -----------------------------------------------------------------------------
|
|
165 |
// RSISpeechRecognitionCustomCommands::GetAllClientLexiconIDs
|
|
166 |
// Calls the controller plugin to get all client lexicon IDs.
|
|
167 |
// -----------------------------------------------------------------------------
|
|
168 |
//
|
|
169 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllClientLexiconIDs()
|
|
170 |
{
|
|
171 |
|
|
172 |
return iController.CustomCommandSync(iDestinationPckg,
|
|
173 |
ESrGetAllClientLexiconIDs, KNullDesC8, KNullDesC8); // Async
|
|
174 |
|
|
175 |
}
|
|
176 |
|
|
177 |
// -----------------------------------------------------------------------------
|
|
178 |
// RSISpeechRecognitionCustomCommands::GetAllClientModelBankIDs
|
|
179 |
// Calls the controller plugin to get all client model bank IDs.
|
|
180 |
// -----------------------------------------------------------------------------
|
|
181 |
//
|
|
182 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllClientModelBankIDs()
|
|
183 |
{
|
|
184 |
|
|
185 |
return iController.CustomCommandSync(iDestinationPckg, ESrGetAllClientModelBankIDs,
|
|
186 |
KNullDesC8, KNullDesC8); // Async
|
|
187 |
|
|
188 |
}
|
|
189 |
|
|
190 |
// -----------------------------------------------------------------------------
|
|
191 |
// RSISpeechRecognitionCustomCommands::GetAllGrammarIDs
|
|
192 |
// Calls the controller plugin to get all grammar IDs for all clients.
|
|
193 |
// -----------------------------------------------------------------------------
|
|
194 |
//
|
|
195 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllGrammarIDs()
|
|
196 |
{
|
|
197 |
|
|
198 |
return iController.CustomCommandSync(iDestinationPckg, ESrGetAllGrammarIDs,
|
|
199 |
KNullDesC8, KNullDesC8); // Async
|
|
200 |
|
|
201 |
}
|
|
202 |
|
|
203 |
// -----------------------------------------------------------------------------
|
|
204 |
// RSISpeechRecognitionCustomCommands::GetAllLexiconIDs
|
|
205 |
// Calls the controller plugin to get all lexicon IDs for all clients.
|
|
206 |
// -----------------------------------------------------------------------------
|
|
207 |
//
|
|
208 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllLexiconIDs()
|
|
209 |
{
|
|
210 |
|
|
211 |
return iController.CustomCommandSync(iDestinationPckg, ESrGetAllLexiconIDs,
|
|
212 |
KNullDesC8, KNullDesC8); // Async
|
|
213 |
|
|
214 |
}
|
|
215 |
|
|
216 |
// -----------------------------------------------------------------------------
|
|
217 |
// RSISpeechRecognitionCustomCommands::GetAllModelBankIDs
|
|
218 |
// Calls the controller plugin to get all model bank IDs.
|
|
219 |
// -----------------------------------------------------------------------------
|
|
220 |
//
|
|
221 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllModelBankIDs()
|
|
222 |
{
|
|
223 |
|
|
224 |
return iController.CustomCommandSync(iDestinationPckg, ESrGetAllModelBankIDs,
|
|
225 |
KNullDesC8, KNullDesC8); // Async
|
|
226 |
|
|
227 |
}
|
|
228 |
|
|
229 |
// -----------------------------------------------------------------------------
|
|
230 |
// RSISpeechRecognitionCustomCommands::GetAllModelIDs
|
|
231 |
// Sends a command to the controller to get all model IDs from a model bank.
|
|
232 |
// -----------------------------------------------------------------------------
|
|
233 |
//
|
|
234 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllModelIDs(
|
|
235 |
TSIModelBankID aModelBankID)
|
|
236 |
{
|
|
237 |
|
|
238 |
TSrsModelBankIDPckg modelBankIDPckg = aModelBankID;
|
|
239 |
|
|
240 |
return iController.CustomCommandSync(iDestinationPckg, ESrGetAllModelIDs,
|
|
241 |
modelBankIDPckg, KNullDesC8); // Async
|
|
242 |
|
|
243 |
}
|
|
244 |
|
|
245 |
// -----------------------------------------------------------------------------
|
|
246 |
// RSISpeechRecognitionCustomCommands::GetAllPronunciationIDs
|
|
247 |
// Sends a command to the controller to get all pronunciation IDs from a lexicon.
|
|
248 |
// -----------------------------------------------------------------------------
|
|
249 |
//
|
|
250 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllPronunciationIDs(
|
|
251 |
TSILexiconID aLexiconID)
|
|
252 |
{
|
|
253 |
|
|
254 |
TSrsLexiconIDPckg lexiconIDPckg = aLexiconID;
|
|
255 |
return iController.CustomCommandSync(iDestinationPckg,
|
|
256 |
ESrGetAllPronunciationIDs,
|
|
257 |
lexiconIDPckg, KNullDesC8); // Async
|
|
258 |
|
|
259 |
}
|
|
260 |
|
|
261 |
// -----------------------------------------------------------------------------
|
|
262 |
// RSISpeechRecognitionCustomCommands::GetAllRuleIDs
|
|
263 |
// Sends a command to the controller to get all rule IDs from a grammar.
|
|
264 |
// -----------------------------------------------------------------------------
|
|
265 |
//
|
|
266 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllRuleIDs(
|
|
267 |
TSIGrammarID aGrammarID)
|
|
268 |
{
|
|
269 |
|
|
270 |
TSrsGrammarIDPckg grammarIDPckg = aGrammarID;
|
|
271 |
|
|
272 |
return iController.CustomCommandSync(iDestinationPckg, ESrGetAllRuleIDs,
|
|
273 |
grammarIDPckg, KNullDesC8); // Async
|
|
274 |
|
|
275 |
}
|
|
276 |
|
|
277 |
// -----------------------------------------------------------------------------
|
|
278 |
// RSISpeechRecognitionCustomCommands::GetEngineProperties
|
|
279 |
// Sends a command to the controller to get the engine properties.
|
|
280 |
// -----------------------------------------------------------------------------
|
|
281 |
//
|
|
282 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetEngineProperties(
|
|
283 |
const RArray<TInt>& aPropertyId,
|
|
284 |
RArray<TInt>& aPropertyValue)
|
|
285 |
{
|
|
286 |
|
|
287 |
TRAPD(err, DoGetEnginePropertiesL(aPropertyId, aPropertyValue));
|
|
288 |
return err;
|
|
289 |
|
|
290 |
}
|
|
291 |
|
|
292 |
// -----------------------------------------------------------------------------
|
|
293 |
// RSISpeechRecognitionCustomCommands::GetModelCount
|
|
294 |
// Sends a command to the controller to get the number of models in a model bank.
|
|
295 |
// -----------------------------------------------------------------------------
|
|
296 |
//
|
|
297 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetModelCount(
|
|
298 |
TSIModelBankID aModelBankID, TInt& aModelCount)
|
|
299 |
{
|
|
300 |
|
|
301 |
TSrsModelBankIDPckg modelBankPckg = aModelBankID;
|
|
302 |
TSrsIntPtrPckg modelCountPtrPckg = &aModelCount;
|
|
303 |
|
|
304 |
return iController.CustomCommandSync(iDestinationPckg, ESrGetModelCount,
|
|
305 |
modelBankPckg, modelCountPtrPckg);
|
|
306 |
|
|
307 |
}
|
|
308 |
|
|
309 |
|
|
310 |
// -----------------------------------------------------------------------------
|
|
311 |
// RSISpeechRecognitionCustomCommands::GetRuleValidity
|
|
312 |
// Sends a command to the controller to determine if a rule is valid.
|
|
313 |
// -----------------------------------------------------------------------------
|
|
314 |
//
|
|
315 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetRuleValidity(
|
|
316 |
TSIGrammarID aGrammarID,
|
|
317 |
TSIRuleID aRuleID, TBool& aValid)
|
|
318 |
{
|
|
319 |
|
|
320 |
TSrsRuleValidity srsRuleValidity(aGrammarID, aRuleID, &aValid);
|
|
321 |
TSrsRuleValidityPckg srsRuleValidityPckg(srsRuleValidity);
|
|
322 |
|
|
323 |
return iController.CustomCommandSync(iDestinationPckg, ESrGetRuleValidity,
|
|
324 |
srsRuleValidityPckg, KNullDesC8);
|
|
325 |
|
|
326 |
}
|
|
327 |
|
|
328 |
// -----------------------------------------------------------------------------
|
|
329 |
// RSISpeechRecognitionCustomCommands::LoadGrammar
|
|
330 |
// Sends a command to the controller to load the specified grammar.
|
|
331 |
// -----------------------------------------------------------------------------
|
|
332 |
//
|
|
333 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::LoadGrammar(
|
|
334 |
TSIGrammarID aGrammarID)
|
|
335 |
{
|
|
336 |
|
|
337 |
TSrsGrammarIDPckg pckg = aGrammarID;
|
|
338 |
return iController.CustomCommandSync(iDestinationPckg, ESrLoadGrammar,
|
|
339 |
pckg, KNullDesC8); // Async
|
|
340 |
|
|
341 |
}
|
|
342 |
|
|
343 |
// -----------------------------------------------------------------------------
|
|
344 |
// RSISpeechRecognitionCustomCommands::ActivateGrammar
|
|
345 |
// Sends a command to the controller to activate a grammar
|
|
346 |
// -----------------------------------------------------------------------------
|
|
347 |
//
|
|
348 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::ActivateGrammar(
|
|
349 |
TSIGrammarID aGrammarID)
|
|
350 |
{
|
|
351 |
TSrsGrammarIDPckg pckg = aGrammarID;
|
|
352 |
return iController.CustomCommandSync( iDestinationPckg, ESrActivateGrammar,
|
|
353 |
pckg, KNullDesC8 ); // Async
|
|
354 |
|
|
355 |
}
|
|
356 |
|
|
357 |
// -----------------------------------------------------------------------------
|
|
358 |
// RSISpeechRecognitionCustomCommands::DeactivateGrammar
|
|
359 |
// Sends a command to the controller to deactivate a gramamr
|
|
360 |
// -----------------------------------------------------------------------------
|
|
361 |
//
|
|
362 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::DeactivateGrammar(
|
|
363 |
TSIGrammarID aGrammarID)
|
|
364 |
{
|
|
365 |
TSrsGrammarIDPckg pckg = aGrammarID;
|
|
366 |
return iController.CustomCommandSync( iDestinationPckg, ESrDeactivateGrammar,
|
|
367 |
pckg, KNullDesC8); // Async
|
|
368 |
|
|
369 |
}
|
|
370 |
|
|
371 |
// -----------------------------------------------------------------------------
|
|
372 |
// RSISpeechRecognitionCustomCommands::LoadLexicon
|
|
373 |
// Sends a command to the controller to load the specified lexican.
|
|
374 |
// -----------------------------------------------------------------------------
|
|
375 |
//
|
|
376 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::LoadLexicon(
|
|
377 |
TSILexiconID aLexiconID)
|
|
378 |
{
|
|
379 |
|
|
380 |
TSrsLexiconIDPckg pckg = aLexiconID;
|
|
381 |
return iController.CustomCommandSync(iDestinationPckg, ESrLoadLexicon,
|
|
382 |
pckg, KNullDesC8); // Async
|
|
383 |
|
|
384 |
}
|
|
385 |
|
|
386 |
// -----------------------------------------------------------------------------
|
|
387 |
// RSISpeechRecognitionCustomCommands::LoadModels
|
|
388 |
// Sends a command to the controller to load all models from a model bank.
|
|
389 |
// -----------------------------------------------------------------------------
|
|
390 |
//
|
|
391 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::LoadModels(
|
|
392 |
TSIModelBankID aModelBankID)
|
|
393 |
{
|
|
394 |
|
|
395 |
TSrsModelIDPckg pckg = aModelBankID;
|
|
396 |
return iController.CustomCommandSync(iDestinationPckg, ESrLoadModels,
|
|
397 |
pckg, KNullDesC8); // Async
|
|
398 |
|
|
399 |
}
|
|
400 |
|
|
401 |
// -----------------------------------------------------------------------------
|
|
402 |
// RSISpeechRecognitionCustomCommands::Record
|
|
403 |
// Sends a command to the controller to start recording an utterance for either
|
|
404 |
// training or recognition
|
|
405 |
// -----------------------------------------------------------------------------
|
|
406 |
//
|
|
407 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::Record(
|
|
408 |
TTimeIntervalMicroSeconds32 aRecordTime)
|
|
409 |
{
|
|
410 |
|
|
411 |
TSrsTimeIntervalMicroSeconds32Pckg pckg = aRecordTime;
|
|
412 |
return iController.CustomCommandSync(iDestinationPckg, ESrRecord,
|
|
413 |
pckg, KNullDesC8); // Async
|
|
414 |
|
|
415 |
}
|
|
416 |
|
|
417 |
// -----------------------------------------------------------------------------
|
|
418 |
// RSISpeechRecognitionCustomCommands::RemoveGrammar
|
|
419 |
// Sends a command to the controller to remove a grammar.
|
|
420 |
// -----------------------------------------------------------------------------
|
|
421 |
//
|
|
422 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::RemoveGrammar(
|
|
423 |
TSIGrammarID aGrammarID)
|
|
424 |
{
|
|
425 |
|
|
426 |
TSrsGrammarIDPckg pckg = aGrammarID;
|
|
427 |
return iController.CustomCommandSync(iDestinationPckg, ESrRemoveGrammar,
|
|
428 |
pckg, KNullDesC8);
|
|
429 |
|
|
430 |
}
|
|
431 |
|
|
432 |
// -----------------------------------------------------------------------------
|
|
433 |
// RSISpeechRecognitionCustomCommands::RemoveLexicon
|
|
434 |
// Sends a command to the controller to remove a lexicon.
|
|
435 |
// -----------------------------------------------------------------------------
|
|
436 |
//
|
|
437 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::RemoveLexicon(
|
|
438 |
TSILexiconID aLexiconID)
|
|
439 |
{
|
|
440 |
|
|
441 |
TSrsLexiconIDPckg pckg = aLexiconID;
|
|
442 |
return iController.CustomCommandSync(iDestinationPckg, ESrRemoveLexicon,
|
|
443 |
pckg, KNullDesC8);
|
|
444 |
|
|
445 |
}
|
|
446 |
|
|
447 |
// -----------------------------------------------------------------------------
|
|
448 |
// RSISpeechRecognitionCustomCommands::RemoveModelBank
|
|
449 |
// Sends a command to the controller to remove a model bank and all associated
|
|
450 |
// models.
|
|
451 |
// -----------------------------------------------------------------------------
|
|
452 |
//
|
|
453 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::RemoveModelBank(
|
|
454 |
TSIModelBankID aModelBankID)
|
|
455 |
{
|
|
456 |
|
|
457 |
TSrsModelBankIDPckg modelBankIDPckg = aModelBankID;
|
|
458 |
return iController.CustomCommandSync(iDestinationPckg, ESrRemoveModelBank,
|
|
459 |
modelBankIDPckg, KNullDesC8);
|
|
460 |
|
|
461 |
}
|
|
462 |
|
|
463 |
// -----------------------------------------------------------------------------
|
|
464 |
// RSISpeechRecognitionCustomCommands::RemoveModel
|
|
465 |
// Sends a command to the controller to remove a model from a model bank.
|
|
466 |
// -----------------------------------------------------------------------------
|
|
467 |
//
|
|
468 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::RemoveModel(
|
|
469 |
TSIModelBankID aModelBankID,
|
|
470 |
TSIModelID aModelID)
|
|
471 |
{
|
|
472 |
|
|
473 |
TSrsModelBankIDPckg modelBankIDPckg = aModelBankID;
|
|
474 |
TSrsModelIDPckg modelIDPckg = aModelID;
|
|
475 |
|
|
476 |
return iController.CustomCommandSync(iDestinationPckg, ESrRemoveModel,
|
|
477 |
modelBankIDPckg, modelIDPckg); // Async
|
|
478 |
|
|
479 |
}
|
|
480 |
|
|
481 |
// -----------------------------------------------------------------------------
|
|
482 |
// RSISpeechRecognitionCustomCommands::RemovePronunciation
|
|
483 |
// Sends a command to the controller to remove a pronunciation.
|
|
484 |
// -----------------------------------------------------------------------------
|
|
485 |
//
|
|
486 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::RemovePronunciation(
|
|
487 |
TSILexiconID aLexiconID,
|
|
488 |
TSIPronunciationID aPronunciationID)
|
|
489 |
{
|
|
490 |
|
|
491 |
TSrsLexiconIDPckg lexiconIDPckg = aLexiconID;
|
|
492 |
TSrsPronunciationIDPckg pronunciationIDPckg = aPronunciationID;
|
|
493 |
|
|
494 |
return iController.CustomCommandSync(iDestinationPckg, ESrRemovePronunciation,
|
|
495 |
lexiconIDPckg, pronunciationIDPckg); // Async
|
|
496 |
|
|
497 |
}
|
|
498 |
|
|
499 |
// -----------------------------------------------------------------------------
|
|
500 |
// RSISpeechRecognitionCustomCommands::RemoveRule
|
|
501 |
// Sends a command to the controller to remove a rule.
|
|
502 |
// -----------------------------------------------------------------------------
|
|
503 |
//
|
|
504 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::RemoveRule(
|
|
505 |
TSIGrammarID aGrammarID,
|
|
506 |
TSIRuleID aRuleID)
|
|
507 |
{
|
|
508 |
|
|
509 |
TSrsGrammarIDPckg grammarIDPckg = aGrammarID;
|
|
510 |
TSrsRuleIDPckg ruleIDPckg = aRuleID;
|
|
511 |
|
|
512 |
return iController.CustomCommandSync(iDestinationPckg, ESrRemoveRule,
|
|
513 |
grammarIDPckg, ruleIDPckg); // Async
|
|
514 |
|
|
515 |
}
|
|
516 |
|
|
517 |
// -----------------------------------------------------------------------------
|
|
518 |
// RSISpeechRecognitionCustomCommands::RemoveRules
|
|
519 |
// Sends a command to the controller to remove a rule.
|
|
520 |
// -----------------------------------------------------------------------------
|
|
521 |
//
|
|
522 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::RemoveRules(
|
|
523 |
TSIGrammarID aGrammarID,
|
|
524 |
RArray<TSIRuleID>& aRuleIDs)
|
|
525 |
{
|
|
526 |
RUBY_DEBUG1( "RSISpeechRecognitionCustomCommands::RemoveRules GrammarID [%d]", aGrammarID );
|
|
527 |
|
|
528 |
TSrsGrammarIDPckg grammarIDPckg = aGrammarID;
|
|
529 |
|
|
530 |
CBufFlat* flatBuf = 0;
|
|
531 |
|
|
532 |
/** @todo Implement externalize, that takes arrays of Uint32? */
|
|
533 |
TRAPD( err, flatBuf
|
|
534 |
= ExternalizeIntArrayL( reinterpret_cast<RArray<TInt>&> ( aRuleIDs ) ) );
|
|
535 |
|
|
536 |
if ( err != KErrNone )
|
|
537 |
{
|
|
538 |
delete flatBuf;
|
|
539 |
return err;
|
|
540 |
}
|
|
541 |
// SRS will signal, when the rule IDs are ready.
|
|
542 |
TInt ret = iController.CustomCommandSync(iDestinationPckg, ESrRemoveRules,
|
|
543 |
grammarIDPckg, flatBuf->Ptr(0) ); // Async
|
|
544 |
delete flatBuf;
|
|
545 |
|
|
546 |
return( ret );
|
|
547 |
}
|
|
548 |
|
|
549 |
// -----------------------------------------------------------------------------
|
|
550 |
// RSISpeechRecognitionCustomCommands::SetClientUid
|
|
551 |
// Sends a command to the controller to set the client UID.
|
|
552 |
// -----------------------------------------------------------------------------
|
|
553 |
//
|
|
554 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::SetClientUid( TUid aClientUid )
|
|
555 |
{
|
|
556 |
|
|
557 |
TSrsUidPckg uidPckg = aClientUid;
|
|
558 |
return iController.CustomCommandSync(iDestinationPckg,
|
|
559 |
ESrSetClientUid, uidPckg, KNullDesC8);
|
|
560 |
|
|
561 |
}
|
|
562 |
|
|
563 |
|
|
564 |
// -----------------------------------------------------------------------------
|
|
565 |
// RSISpeechRecognitionCustomCommands::StartRecSession
|
|
566 |
// Sends a command to the controller to begin a recognition session.
|
|
567 |
// -----------------------------------------------------------------------------
|
|
568 |
//
|
|
569 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::StartRecSession(
|
|
570 |
TNSSRecognitionMode aMode)
|
|
571 |
{
|
|
572 |
|
|
573 |
TSrsRecognitionModePckg recognitionModePckg = aMode;
|
|
574 |
TInt err = iController.CustomCommandSync(iDestinationPckg,
|
|
575 |
ESrStartRecSession, recognitionModePckg, KNullDesC8);
|
|
576 |
|
|
577 |
return err;
|
|
578 |
|
|
579 |
}
|
|
580 |
|
|
581 |
// -----------------------------------------------------------------------------
|
|
582 |
// RSISpeechRecognitionCustomCommands::UnloadRule
|
|
583 |
// Sends a command to the controller to add a rule.
|
|
584 |
// -----------------------------------------------------------------------------
|
|
585 |
//
|
|
586 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::UnloadRule(
|
|
587 |
TSIGrammarID aGrammarID,
|
|
588 |
TSIRuleID aRuleID)
|
|
589 |
{
|
|
590 |
|
|
591 |
TSrsGrammarIDPckg grammarIDPckg = aGrammarID;
|
|
592 |
TSrsRuleIDPckg ruleIDPtrPckg = aRuleID;
|
|
593 |
|
|
594 |
return iController.CustomCommandSync(iDestinationPckg, ESrUnloadRule,
|
|
595 |
grammarIDPckg, ruleIDPtrPckg);
|
|
596 |
|
|
597 |
}
|
|
598 |
|
|
599 |
// -----------------------------------------------------------------------------
|
|
600 |
// RSISpeechRecognitionCustomCommands::LoadEngineParameters
|
|
601 |
// Sends a command to the controller to load the parameters into
|
|
602 |
// the engine.
|
|
603 |
// -----------------------------------------------------------------------------
|
|
604 |
//
|
|
605 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::LoadEngineParameters(
|
|
606 |
const RArray<TInt>& aParameterId,
|
|
607 |
const RArray<TInt>& aParameterValue)
|
|
608 |
{
|
|
609 |
|
|
610 |
TRAPD(error, DoLoadEngineParametersL(aParameterId, aParameterValue));
|
|
611 |
return error;
|
|
612 |
|
|
613 |
}
|
|
614 |
|
|
615 |
|
|
616 |
// -----------------------------------------------------------------------------
|
|
617 |
// RSISpeechRecognitionCustomCommands::GetPronunciationIDArrayL
|
|
618 |
// Sends a command to get the pronunciation ID array.
|
|
619 |
// -----------------------------------------------------------------------------
|
|
620 |
//
|
|
621 |
EXPORT_C void RSISpeechRecognitionCustomCommands::GetPronunciationIDArrayL(
|
|
622 |
RArray<TSIPronunciationID>& aPronunciationIDs)
|
|
623 |
{
|
|
624 |
CleanupClosePushL( aPronunciationIDs );
|
|
625 |
|
|
626 |
TPckgBuf<TInt> pckgSize;
|
|
627 |
|
|
628 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
629 |
ESrGetPronunciationIDArraySize,
|
|
630 |
KNullDesC8,
|
|
631 |
KNullDesC8,
|
|
632 |
pckgSize));
|
|
633 |
|
|
634 |
|
|
635 |
HBufC8* buf = HBufC8::NewLC(pckgSize()*sizeof(TUint32));
|
|
636 |
TPtr8 ptr = buf->Des();
|
|
637 |
|
|
638 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
639 |
ESrGetPronunciationIDArrayContents,
|
|
640 |
KNullDesC8,
|
|
641 |
KNullDesC8,
|
|
642 |
ptr));
|
|
643 |
|
|
644 |
RDesReadStream stream(ptr);
|
|
645 |
CleanupClosePushL(stream);
|
|
646 |
|
|
647 |
for (TInt i=0; i<pckgSize(); i++)
|
|
648 |
{
|
|
649 |
User::LeaveIfError(aPronunciationIDs.Append(stream.ReadUint32L()));
|
|
650 |
}
|
|
651 |
|
|
652 |
CleanupStack::PopAndDestroy(2);//stream, buf
|
|
653 |
CleanupStack::Pop();
|
|
654 |
}
|
|
655 |
|
|
656 |
// -----------------------------------------------------------------------------
|
|
657 |
// RSISpeechRecognitionCustomCommands::GetRuleIDArrayL
|
|
658 |
// Sends a command to get the rule ID array.
|
|
659 |
// -----------------------------------------------------------------------------
|
|
660 |
//
|
|
661 |
EXPORT_C void RSISpeechRecognitionCustomCommands::GetRuleIDArrayL(
|
|
662 |
RArray<TSIRuleID>& aRuleIDs)
|
|
663 |
{
|
|
664 |
CleanupClosePushL( aRuleIDs );
|
|
665 |
|
|
666 |
TPckgBuf<TInt> pckgSize;
|
|
667 |
|
|
668 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
669 |
ESrGetRuleIDArraySize,
|
|
670 |
KNullDesC8,
|
|
671 |
KNullDesC8,
|
|
672 |
pckgSize));
|
|
673 |
|
|
674 |
HBufC8* buf = HBufC8::NewLC(pckgSize()*sizeof(TUint32));
|
|
675 |
TPtr8 ptr = buf->Des();
|
|
676 |
|
|
677 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
678 |
ESrGetRuleIDArrayContents,
|
|
679 |
KNullDesC8,
|
|
680 |
KNullDesC8,
|
|
681 |
ptr));
|
|
682 |
|
|
683 |
RDesReadStream stream(ptr);
|
|
684 |
CleanupClosePushL(stream);
|
|
685 |
|
|
686 |
for (TInt i=0; i<pckgSize(); i++)
|
|
687 |
{
|
|
688 |
User::LeaveIfError(aRuleIDs.Append(stream.ReadUint32L()));
|
|
689 |
}
|
|
690 |
|
|
691 |
CleanupStack::PopAndDestroy(2);//stream, buf
|
|
692 |
CleanupStack::Pop();
|
|
693 |
}
|
|
694 |
|
|
695 |
// -----------------------------------------------------------------------------
|
|
696 |
// RSISpeechRecognitionCustomCommands::GetModelIDArrayL
|
|
697 |
// Sends a command to get the model ID array.
|
|
698 |
// -----------------------------------------------------------------------------
|
|
699 |
//
|
|
700 |
EXPORT_C void RSISpeechRecognitionCustomCommands::GetModelIDArrayL(
|
|
701 |
RArray<TSIModelID>& aModelIDs)
|
|
702 |
{
|
|
703 |
CleanupClosePushL( aModelIDs );
|
|
704 |
|
|
705 |
TPckgBuf<TInt> pckgSize;
|
|
706 |
|
|
707 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
708 |
ESrGetModelIDArraySize,
|
|
709 |
KNullDesC8,
|
|
710 |
KNullDesC8,
|
|
711 |
pckgSize));
|
|
712 |
|
|
713 |
HBufC8* buf = HBufC8::NewLC(pckgSize()*sizeof(TUint32));
|
|
714 |
TPtr8 ptr = buf->Des();
|
|
715 |
|
|
716 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
717 |
ESrGetModelIDArrayContents,
|
|
718 |
KNullDesC8,
|
|
719 |
KNullDesC8,
|
|
720 |
ptr));
|
|
721 |
|
|
722 |
RDesReadStream stream(ptr);
|
|
723 |
CleanupClosePushL(stream);
|
|
724 |
|
|
725 |
for (TInt i=0; i<pckgSize(); i++)
|
|
726 |
{
|
|
727 |
User::LeaveIfError( aModelIDs.Append( (TSIModelID)stream.ReadUint32L() ) );
|
|
728 |
}
|
|
729 |
|
|
730 |
CleanupStack::PopAndDestroy( 2 );//stream, buf
|
|
731 |
CleanupStack::Pop();
|
|
732 |
}
|
|
733 |
|
|
734 |
// -----------------------------------------------------------------------------
|
|
735 |
// RSISpeechRecognitionCustomCommands::GetGrammarIDArrayL
|
|
736 |
// Sends a command to get the grammar ID array.
|
|
737 |
// -----------------------------------------------------------------------------
|
|
738 |
//
|
|
739 |
EXPORT_C void RSISpeechRecognitionCustomCommands::GetGrammarIDArrayL(
|
|
740 |
RArray<TSIGrammarID>& aGrammarIDs)
|
|
741 |
{
|
|
742 |
CleanupClosePushL( aGrammarIDs );
|
|
743 |
|
|
744 |
TPckgBuf<TInt> pckgSize;
|
|
745 |
|
|
746 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
747 |
ESrGetGrammarIDArraySize,
|
|
748 |
KNullDesC8,
|
|
749 |
KNullDesC8,
|
|
750 |
pckgSize));
|
|
751 |
|
|
752 |
HBufC8* buf = HBufC8::NewLC(pckgSize()*sizeof(TUint32));
|
|
753 |
TPtr8 ptr = buf->Des();
|
|
754 |
|
|
755 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
756 |
ESrGetGrammarIDArrayContents,
|
|
757 |
KNullDesC8,
|
|
758 |
KNullDesC8,
|
|
759 |
ptr));
|
|
760 |
|
|
761 |
RDesReadStream stream(ptr);
|
|
762 |
CleanupClosePushL(stream);
|
|
763 |
|
|
764 |
for ( TInt i = 0; i < pckgSize(); i++ )
|
|
765 |
{
|
|
766 |
User::LeaveIfError( aGrammarIDs.Append( (TSIGrammarID)stream.ReadUint32L() ) );
|
|
767 |
}
|
|
768 |
|
|
769 |
CleanupStack::PopAndDestroy( 2 );//stream, buf
|
|
770 |
CleanupStack::Pop();//aGrammarIDs
|
|
771 |
}
|
|
772 |
|
|
773 |
// -----------------------------------------------------------------------------
|
|
774 |
// RSISpeechRecognitionCustomCommands::GetLexiconIDArrayL
|
|
775 |
// Sends a command to get the lexicon ID array.
|
|
776 |
// -----------------------------------------------------------------------------
|
|
777 |
//
|
|
778 |
EXPORT_C void RSISpeechRecognitionCustomCommands::GetLexiconIDArrayL(
|
|
779 |
RArray<TSILexiconID>& aLexiconIDs)
|
|
780 |
{
|
|
781 |
CleanupClosePushL( aLexiconIDs );
|
|
782 |
|
|
783 |
TPckgBuf<TInt> pckgSize;
|
|
784 |
|
|
785 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
786 |
ESrGetLexiconIDArraySize,
|
|
787 |
KNullDesC8,
|
|
788 |
KNullDesC8,
|
|
789 |
pckgSize));
|
|
790 |
|
|
791 |
TInt size = pckgSize();
|
|
792 |
HBufC8* buf = HBufC8::NewLC(size*sizeof(TUint32));
|
|
793 |
TPtr8 ptr = buf->Des();
|
|
794 |
|
|
795 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
796 |
ESrGetLexiconIDArrayContents,
|
|
797 |
KNullDesC8,
|
|
798 |
KNullDesC8,
|
|
799 |
ptr));
|
|
800 |
|
|
801 |
RDesReadStream stream(ptr);
|
|
802 |
CleanupClosePushL(stream);
|
|
803 |
|
|
804 |
for ( TInt i = 0; i < pckgSize(); i++ )
|
|
805 |
{
|
|
806 |
User::LeaveIfError( aLexiconIDs.Append( (TSILexiconID)stream.ReadUint32L() ) );
|
|
807 |
}
|
|
808 |
|
|
809 |
CleanupStack::PopAndDestroy(2);//stream, buf
|
|
810 |
CleanupStack::Pop();
|
|
811 |
}
|
|
812 |
|
|
813 |
// -----------------------------------------------------------------------------
|
|
814 |
// RSISpeechRecognitionCustomCommands::GetLexiconIDArrayL
|
|
815 |
// Sends a command to get the lexicon ID array.
|
|
816 |
// -----------------------------------------------------------------------------
|
|
817 |
//
|
|
818 |
EXPORT_C void RSISpeechRecognitionCustomCommands::GetModelBankIDArrayL(
|
|
819 |
RArray<TSIModelBankID>& aModelBankIDs)
|
|
820 |
{
|
|
821 |
CleanupClosePushL( aModelBankIDs );
|
|
822 |
|
|
823 |
TPckgBuf<TInt> pckgSize;
|
|
824 |
|
|
825 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
826 |
ESrGetModelBankIDArraySize,
|
|
827 |
KNullDesC8,
|
|
828 |
KNullDesC8,
|
|
829 |
pckgSize));
|
|
830 |
|
|
831 |
HBufC8* buf = HBufC8::NewLC(pckgSize()*sizeof(TUint32));
|
|
832 |
TPtr8 ptr = buf->Des();
|
|
833 |
|
|
834 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
835 |
ESrGetModelBankIDArrayContents,
|
|
836 |
KNullDesC8,
|
|
837 |
KNullDesC8,
|
|
838 |
ptr));
|
|
839 |
|
|
840 |
RDesReadStream stream(ptr);
|
|
841 |
CleanupClosePushL(stream);
|
|
842 |
|
|
843 |
for ( TInt i = 0; i < pckgSize(); i++ )
|
|
844 |
{
|
|
845 |
User::LeaveIfError( aModelBankIDs.Append( (TSIModelBankID)stream.ReadUint32L() ) );
|
|
846 |
}
|
|
847 |
|
|
848 |
CleanupStack::PopAndDestroy(2);//stream, buf
|
|
849 |
CleanupStack::Pop();
|
|
850 |
}
|
|
851 |
|
|
852 |
// -----------------------------------------------------------------------------
|
|
853 |
// RSISpeechRecognitionCustomCommands::GetSIResultSetL
|
|
854 |
// Sends a command to get the speaker independent recognition result set.
|
|
855 |
// -----------------------------------------------------------------------------
|
|
856 |
//
|
|
857 |
EXPORT_C void RSISpeechRecognitionCustomCommands::GetSIResultSetL(
|
|
858 |
CSIClientResultSet& aResultSet)
|
|
859 |
{
|
|
860 |
|
|
861 |
TPckgBuf<TInt> pckgSize;
|
|
862 |
|
|
863 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
864 |
ESrGetClientResultSetSizeSI,
|
|
865 |
KNullDesC8,
|
|
866 |
KNullDesC8,
|
|
867 |
pckgSize));
|
|
868 |
|
|
869 |
HBufC8* buf = HBufC8::NewLC( pckgSize() );
|
|
870 |
TPtr8 ptr = buf->Des();
|
|
871 |
|
|
872 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
873 |
ESrGetClientResultSet,
|
|
874 |
KNullDesC8,
|
|
875 |
KNullDesC8,
|
|
876 |
ptr));
|
|
877 |
|
|
878 |
RDesReadStream stream(ptr);
|
|
879 |
CleanupClosePushL(stream);
|
|
880 |
|
|
881 |
aResultSet.InternalizeL(stream);
|
|
882 |
CleanupStack::PopAndDestroy(2);//stream, buf
|
|
883 |
|
|
884 |
}
|
|
885 |
|
|
886 |
// -----------------------------------------------------------------------------
|
|
887 |
// RSISpeechRecognitionCustomCommands::DoRecognizeL
|
|
888 |
// Sends a command to get the recognition result set.
|
|
889 |
// -----------------------------------------------------------------------------
|
|
890 |
//
|
|
891 |
void RSISpeechRecognitionCustomCommands::DoRecognizeL(CSDClientResultSet& /*aResultSet*/)
|
|
892 |
{
|
|
893 |
RUBY_DEBUG0( "RSISpeechRecognitionCustomCommands::DoRecognizeL is NOT supported" );
|
|
894 |
User::Leave( KErrNotSupported );
|
|
895 |
}
|
|
896 |
|
|
897 |
// -----------------------------------------------------------------------------
|
|
898 |
// RSISpeechRecognitionCustomCommands::DoRecognizeSIL
|
|
899 |
// Sends a command to get the recognition result set.
|
|
900 |
// -----------------------------------------------------------------------------
|
|
901 |
//
|
|
902 |
void RSISpeechRecognitionCustomCommands::DoRecognizeSIL(CSIClientResultSet& aResultSet)
|
|
903 |
{
|
|
904 |
CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
|
|
905 |
CleanupStack::PushL(dataCopyBuffer);
|
|
906 |
|
|
907 |
RBufWriteStream stream;
|
|
908 |
stream.Open(*dataCopyBuffer);
|
|
909 |
CleanupClosePushL(stream);
|
|
910 |
|
|
911 |
aResultSet.ExternalizeL(stream);
|
|
912 |
|
|
913 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
914 |
ESrRecognizeSI,
|
|
915 |
dataCopyBuffer->Ptr(0),
|
|
916 |
KNullDesC8));
|
|
917 |
|
|
918 |
CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer
|
|
919 |
}
|
|
920 |
|
|
921 |
// -----------------------------------------------------------------------------
|
|
922 |
// RSISpeechRecognitionCustomCommands::DoGetEnginePropertiesL
|
|
923 |
// Sends a command to get the engine properties.
|
|
924 |
// -----------------------------------------------------------------------------
|
|
925 |
//
|
|
926 |
void RSISpeechRecognitionCustomCommands::DoGetEnginePropertiesL(
|
|
927 |
const RArray<TInt>& aPropertyId,
|
|
928 |
RArray<TInt>& aPropertyValue)
|
|
929 |
{
|
|
930 |
|
|
931 |
CBufFlat* param1 = ExternalizeIntArrayL(aPropertyId);
|
|
932 |
CleanupStack::PushL(param1);
|
|
933 |
|
|
934 |
TInt aNumberResults = aPropertyId.Count(); // same number of values as properties
|
|
935 |
|
|
936 |
HBufC8* buf = HBufC8::NewLC(aNumberResults *sizeof(TInt));
|
|
937 |
TPtr8 ptr = buf->Des();
|
|
938 |
|
|
939 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
940 |
ESrGetEngineProperties,
|
|
941 |
param1->Ptr(0),
|
|
942 |
KNullDesC8,
|
|
943 |
ptr));
|
|
944 |
|
|
945 |
|
|
946 |
InternalizeIntArrayL(ptr,aNumberResults,aPropertyValue);
|
|
947 |
CleanupStack::PopAndDestroy(2);//buf,param1
|
|
948 |
|
|
949 |
}
|
|
950 |
|
|
951 |
// -----------------------------------------------------------------------------
|
|
952 |
// RSISpeechRecognitionCustomCommands::DoLoadEngineParametersL
|
|
953 |
// Sends a command to load the engine parameters.
|
|
954 |
// -----------------------------------------------------------------------------
|
|
955 |
//
|
|
956 |
void RSISpeechRecognitionCustomCommands::DoLoadEngineParametersL(
|
|
957 |
const RArray<TInt>& aParameterId,
|
|
958 |
const RArray<TInt>& aParameterValue)
|
|
959 |
{
|
|
960 |
|
|
961 |
CBufFlat* param1 = ExternalizeIntArrayL(aParameterId);
|
|
962 |
CleanupStack::PushL(param1);
|
|
963 |
CBufFlat* param2 = ExternalizeIntArrayL(aParameterValue);
|
|
964 |
CleanupStack::PushL(param2);
|
|
965 |
User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
|
|
966 |
ESrLoadEngineParameters,
|
|
967 |
param1->Ptr(0),
|
|
968 |
param2->Ptr(0)));
|
|
969 |
|
|
970 |
CleanupStack::PopAndDestroy(2); //param2, param1
|
|
971 |
|
|
972 |
}
|
|
973 |
|
|
974 |
// -----------------------------------------------------------------------------
|
|
975 |
// RSISpeechRecognitionCustomCommands::ExternalizeIntArrayL
|
|
976 |
// Externalizes an interger array.
|
|
977 |
// -----------------------------------------------------------------------------
|
|
978 |
//
|
|
979 |
CBufFlat* RSISpeechRecognitionCustomCommands::ExternalizeIntArrayL(
|
|
980 |
const RArray<TInt>& aArray)
|
|
981 |
{
|
|
982 |
|
|
983 |
CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
|
|
984 |
CleanupStack::PushL(dataCopyBuffer);
|
|
985 |
RBufWriteStream stream;
|
|
986 |
stream.Open(*dataCopyBuffer);
|
|
987 |
CleanupClosePushL(stream);
|
|
988 |
|
|
989 |
stream.WriteInt32L(aArray.Count());
|
|
990 |
|
|
991 |
for (TInt i=0;i<aArray.Count();i++)
|
|
992 |
stream.WriteUint32L(aArray[i]);
|
|
993 |
|
|
994 |
CleanupStack::PopAndDestroy(1); //stream
|
|
995 |
CleanupStack::Pop(); //dataCopyBuffer;
|
|
996 |
return dataCopyBuffer;
|
|
997 |
|
|
998 |
}
|
|
999 |
|
|
1000 |
// -----------------------------------------------------------------------------
|
|
1001 |
// RSISpeechRecognitionCustomCommands::InternalizeIntArrayL
|
|
1002 |
// Internalizes an interger array.
|
|
1003 |
// -----------------------------------------------------------------------------
|
|
1004 |
//
|
|
1005 |
void RSISpeechRecognitionCustomCommands::InternalizeIntArrayL(
|
|
1006 |
TDes8& aDes,
|
|
1007 |
TInt aNumberElements,
|
|
1008 |
RArray<TInt>& aArray)
|
|
1009 |
{
|
|
1010 |
CleanupClosePushL( aArray );
|
|
1011 |
|
|
1012 |
RDesReadStream stream(aDes);
|
|
1013 |
CleanupClosePushL(stream);
|
|
1014 |
|
|
1015 |
for (TInt i=0; i<aNumberElements; i++)
|
|
1016 |
{
|
|
1017 |
User::LeaveIfError(aArray.Append(stream.ReadInt32L()));
|
|
1018 |
}
|
|
1019 |
|
|
1020 |
CleanupStack::PopAndDestroy();//stream
|
|
1021 |
CleanupStack::Pop();
|
|
1022 |
}
|
|
1023 |
|
|
1024 |
/************************** New SI functions start here ***********************/
|
|
1025 |
|
|
1026 |
// -----------------------------------------------------------------------------
|
|
1027 |
// Adapts speaker independent models according using a correct recognition result.
|
|
1028 |
// -----------------------------------------------------------------------------
|
|
1029 |
//
|
|
1030 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::Adapt(const CSIClientResultSet& aResultSet, TInt aCorrect)
|
|
1031 |
{
|
|
1032 |
CBufFlat* dataBuf = 0;
|
|
1033 |
RBufWriteStream dataStream;
|
|
1034 |
TInt ret = KErrNone;
|
|
1035 |
TBool forever = ETrue;
|
|
1036 |
|
|
1037 |
TPckgBuf<TInt> correctPckg( aCorrect );
|
|
1038 |
|
|
1039 |
while(forever)
|
|
1040 |
{
|
|
1041 |
// Poor man's exception handling: while and break
|
|
1042 |
#define BREAK( error ) if ( error != KErrNone ) { break; }
|
|
1043 |
|
|
1044 |
// Allocate buffer for storing CSIClientResultSet
|
|
1045 |
TRAP ( ret, dataBuf = CBufFlat::NewL( KExpandSize ) );
|
|
1046 |
BREAK( ret );
|
|
1047 |
|
|
1048 |
// Open a stream to the buffer
|
|
1049 |
dataStream.Open( *dataBuf );
|
|
1050 |
|
|
1051 |
// Pack the data
|
|
1052 |
TRAP ( ret, aResultSet.ExternalizeL( dataStream ) );
|
|
1053 |
BREAK( ret );
|
|
1054 |
|
|
1055 |
// Send through MMF
|
|
1056 |
ret = iController.CustomCommandSync(
|
|
1057 |
iDestinationPckg,
|
|
1058 |
ESrAdapt,
|
|
1059 |
dataBuf->Ptr( 0 ),
|
|
1060 |
correctPckg );
|
|
1061 |
|
|
1062 |
break;
|
|
1063 |
}
|
|
1064 |
|
|
1065 |
dataStream.Close();
|
|
1066 |
delete dataBuf;
|
|
1067 |
|
|
1068 |
return ret;
|
|
1069 |
}
|
|
1070 |
|
|
1071 |
// -----------------------------------------------------------------------------
|
|
1072 |
// Adds a pronunciation to the given lexicon.
|
|
1073 |
// -----------------------------------------------------------------------------
|
|
1074 |
//
|
|
1075 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::AddPronunciation(
|
|
1076 |
TSILexiconID aLexiconID,
|
|
1077 |
const TDesC& aTrainText,
|
|
1078 |
TLanguage aLanguage,
|
|
1079 |
TSIPronunciationID& aPronunciationID)
|
|
1080 |
{
|
|
1081 |
TSrsAddPronunciationSI srsAddPronunciation( aLexiconID, aTrainText.Length(),
|
|
1082 |
aLanguage, aPronunciationID );
|
|
1083 |
TSrsAddPronunciationSIPckg pckg( srsAddPronunciation );
|
|
1084 |
|
|
1085 |
TInt trainTextSize( aTrainText.Size() );
|
|
1086 |
TUint8* trainTextPtr = (TUint8*)aTrainText.Ptr();
|
|
1087 |
TPtrC8 trainTextDes( trainTextPtr, trainTextSize );
|
|
1088 |
|
|
1089 |
return iController.CustomCommandSync(iDestinationPckg, ESrAddPronunciationSI,
|
|
1090 |
pckg, trainTextDes );
|
|
1091 |
}
|
|
1092 |
|
|
1093 |
// -----------------------------------------------------------------------------
|
|
1094 |
// Adds a rule variant to a rule in a grammar.
|
|
1095 |
// -----------------------------------------------------------------------------
|
|
1096 |
//
|
|
1097 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::AddRuleVariant(
|
|
1098 |
TSIGrammarID aGrammarID,
|
|
1099 |
TSILexiconID aLexiconID,
|
|
1100 |
const RArray<TSIPronunciationID>& aPronunciationIDs,
|
|
1101 |
TSIRuleID aRuleID,
|
|
1102 |
TSIRuleVariantID& aRuleVariantID )
|
|
1103 |
{
|
|
1104 |
TSrsAddRuleVariant srsAddRuleVariant( aGrammarID,
|
|
1105 |
aLexiconID,
|
|
1106 |
aPronunciationIDs.Count(),
|
|
1107 |
aRuleID,
|
|
1108 |
&aRuleVariantID );
|
|
1109 |
TSrsAddRuleVariantPckg pckg( srsAddRuleVariant );
|
|
1110 |
|
|
1111 |
TUint8* pronunIdPtr = (TUint8*)&(aPronunciationIDs[0]);
|
|
1112 |
TPtrC8 pronunIdDes( pronunIdPtr,
|
|
1113 |
sizeof( TSIPronunciationID ) * aPronunciationIDs.Count()
|
|
1114 |
);
|
|
1115 |
|
|
1116 |
return iController.CustomCommandSync(iDestinationPckg, ESrAddRuleVariant,
|
|
1117 |
pckg, pronunIdDes );
|
|
1118 |
}
|
|
1119 |
|
|
1120 |
// -----------------------------------------------------------------------------
|
|
1121 |
// Trains a voice tag. Adds the text to the lexicon, and creates the required
|
|
1122 |
// rules and rule variants.
|
|
1123 |
// -----------------------------------------------------------------------------
|
|
1124 |
//
|
|
1125 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::AddVoiceTag(
|
|
1126 |
const MDesCArray& aTrainArray,
|
|
1127 |
const RArray<TLanguage>& aLanguageArray,
|
|
1128 |
TSILexiconID aLexiconID,
|
|
1129 |
TSIGrammarID aGrammarID,
|
|
1130 |
TSIRuleID& aRuleID)
|
|
1131 |
{
|
|
1132 |
TSrsAddVoiceTag srsAddVoiceTagData( aLexiconID, aGrammarID, &aRuleID, aLanguageArray );
|
|
1133 |
TSrsAddVoiceTagPckg pckg( srsAddVoiceTagData );
|
|
1134 |
|
|
1135 |
CBufFlat* flatBuf = 0;
|
|
1136 |
TRAPD( err, flatBuf
|
|
1137 |
= SICustomCommandData::ExternalizeDesCArrayL( aTrainArray ) );
|
|
1138 |
|
|
1139 |
if ( err != KErrNone )
|
|
1140 |
return( err );
|
|
1141 |
|
|
1142 |
// SRS will signal, when the rule IDs are ready.
|
|
1143 |
TInt ret = iController.CustomCommandSync( iDestinationPckg, ESrAddVoiceTag,
|
|
1144 |
pckg, flatBuf->Ptr( 0 ) ); // Async
|
|
1145 |
|
|
1146 |
delete flatBuf;
|
|
1147 |
|
|
1148 |
return( ret );
|
|
1149 |
}
|
|
1150 |
|
|
1151 |
// -----------------------------------------------------------------------------
|
|
1152 |
// Trains voice tags. If the training fails for some of the names (but not all),
|
|
1153 |
// it is signaled by setting the Rule ID to KInvalidRuleID.
|
|
1154 |
// -----------------------------------------------------------------------------
|
|
1155 |
//
|
|
1156 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::AddVoiceTags(
|
|
1157 |
const RPointerArray<MDesCArray>& aTrainArray,
|
|
1158 |
const RArray<TLanguage>& aLanguageArray,
|
|
1159 |
TSILexiconID aLexiconID,
|
|
1160 |
TSIGrammarID aGrammarID,
|
|
1161 |
RArray<TSIRuleID>& /*aRuleID*/)
|
|
1162 |
{
|
|
1163 |
TSrsAddVoiceTag srsAddVoiceTagData( aLexiconID, aGrammarID, NULL, aLanguageArray );
|
|
1164 |
TSrsAddVoiceTagPckg pckg( srsAddVoiceTagData );
|
|
1165 |
|
|
1166 |
CBufFlat* flatBuf = 0;
|
|
1167 |
TRAPD( err, flatBuf
|
|
1168 |
= SICustomCommandData::ExternalizeDesCArrayArrayL( aTrainArray ) );
|
|
1169 |
|
|
1170 |
if ( err != KErrNone )
|
|
1171 |
{
|
|
1172 |
delete flatBuf;
|
|
1173 |
return err;
|
|
1174 |
}
|
|
1175 |
|
|
1176 |
// SRS will signal, when the rule IDs are ready.
|
|
1177 |
TInt ret = iController.CustomCommandSync( iDestinationPckg, ESrAddVoiceTags,
|
|
1178 |
pckg, flatBuf->Ptr( 0 ) ); // Async
|
|
1179 |
delete flatBuf;
|
|
1180 |
|
|
1181 |
return( ret );
|
|
1182 |
}
|
|
1183 |
|
|
1184 |
#ifdef __SINDE_TRAINING
|
|
1185 |
// -----------------------------------------------------------------------------
|
|
1186 |
// Trains a voice tag. Adds the text to the lexicon, and creates the required
|
|
1187 |
// rules and rule variants.
|
|
1188 |
// -----------------------------------------------------------------------------
|
|
1189 |
//
|
|
1190 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::AddVoiceTag( const MDesCArray& aTrainArray,
|
|
1191 |
const RArray<RLanguageArray>& aLanguageArray,
|
|
1192 |
TSILexiconID aLexiconID,
|
|
1193 |
TSIGrammarID aGrammarID,
|
|
1194 |
TSIRuleID& aRuleID )
|
|
1195 |
{
|
|
1196 |
TSrsAddSindeVoiceTag srsAddVoiceTagData( aLexiconID, aGrammarID, &aRuleID, aLanguageArray );
|
|
1197 |
TSrsAddSindeVoiceTagPckg pckg( srsAddVoiceTagData );
|
|
1198 |
|
|
1199 |
CBufFlat* flatBuf( NULL );
|
|
1200 |
TRAPD( err, flatBuf = SICustomCommandData::ExternalizeDesCArrayL( aTrainArray ) );
|
|
1201 |
|
|
1202 |
if ( err != KErrNone )
|
|
1203 |
{
|
|
1204 |
return err;
|
|
1205 |
}
|
|
1206 |
|
|
1207 |
// SRS plugin will signal, when the rule IDs are ready.
|
|
1208 |
TInt ret = iController.CustomCommandSync( iDestinationPckg, ESrAddSindeVoiceTag,
|
|
1209 |
pckg, flatBuf->Ptr( 0 ) ); // Async
|
|
1210 |
|
|
1211 |
delete flatBuf;
|
|
1212 |
|
|
1213 |
return ret;
|
|
1214 |
}
|
|
1215 |
|
|
1216 |
// -----------------------------------------------------------------------------
|
|
1217 |
// Trains voice tags. If the training fails for some of the names (but not all),
|
|
1218 |
// it is signaled by setting the Rule ID to KInvalidRuleID.
|
|
1219 |
// -----------------------------------------------------------------------------
|
|
1220 |
//
|
|
1221 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::AddVoiceTags( const RPointerArray<MDesCArray>& aTrainArray,
|
|
1222 |
const RArray<RLanguageArray>& aLanguageArray,
|
|
1223 |
TSILexiconID aLexiconID,
|
|
1224 |
TSIGrammarID aGrammarID,
|
|
1225 |
RArray<TSIRuleID>& /*aRuleID*/)
|
|
1226 |
{
|
|
1227 |
TSrsAddSindeVoiceTag srsAddVoiceTagData( aLexiconID, aGrammarID, NULL, aLanguageArray );
|
|
1228 |
TSrsAddSindeVoiceTagPckg pckg( srsAddVoiceTagData );
|
|
1229 |
|
|
1230 |
CBufFlat* flatBuf( NULL );
|
|
1231 |
TRAPD( err, flatBuf = SICustomCommandData::ExternalizeDesCArrayArrayL( aTrainArray ) );
|
|
1232 |
|
|
1233 |
if ( err != KErrNone )
|
|
1234 |
{
|
|
1235 |
delete flatBuf;
|
|
1236 |
return err;
|
|
1237 |
}
|
|
1238 |
|
|
1239 |
// SRS plugin will signal, when the rule IDs are ready.
|
|
1240 |
TInt ret = iController.CustomCommandSync( iDestinationPckg, ESrAddSindeVoiceTags,
|
|
1241 |
pckg, flatBuf->Ptr( 0 ) ); // Async
|
|
1242 |
delete flatBuf;
|
|
1243 |
|
|
1244 |
return ret;
|
|
1245 |
}
|
|
1246 |
|
|
1247 |
// -----------------------------------------------------------------------------
|
|
1248 |
// Pre-starts sampling before Record() call
|
|
1249 |
// -----------------------------------------------------------------------------
|
|
1250 |
//
|
|
1251 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::PreStartSampling()
|
|
1252 |
{
|
|
1253 |
return iController.CustomCommandSync( iDestinationPckg, ESrPreStartSampling,
|
|
1254 |
KNullDesC8, KNullDesC8 ); // Async
|
|
1255 |
}
|
|
1256 |
|
|
1257 |
#endif // SINDE_TRAINING
|
|
1258 |
|
|
1259 |
// -----------------------------------------------------------------------------
|
|
1260 |
// Creates a new rule.
|
|
1261 |
// -----------------------------------------------------------------------------
|
|
1262 |
//
|
|
1263 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::CreateRule(TSIGrammarID aGrammarID, TSIRuleID& aRuleID)
|
|
1264 |
{
|
|
1265 |
TSrsAddRule srsCreateRule( aGrammarID, KInvalidLexiconID, KInvalidPronunciationID, &aRuleID );
|
|
1266 |
TSrsAddRulePckg pckg( srsCreateRule );
|
|
1267 |
|
|
1268 |
return iController.CustomCommandSync(iDestinationPckg, ESrCreateRule,
|
|
1269 |
pckg, KNullDesC8 ); // Async
|
|
1270 |
}
|
|
1271 |
|
|
1272 |
// -----------------------------------------------------------------------------
|
|
1273 |
// Starts recognition
|
|
1274 |
// -----------------------------------------------------------------------------
|
|
1275 |
//
|
|
1276 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::Recognize( CSIClientResultSet& aResultSet )
|
|
1277 |
{
|
|
1278 |
TRAPD( err, DoRecognizeSIL( aResultSet ) );
|
|
1279 |
return err;
|
|
1280 |
}
|
|
1281 |
|
|
1282 |
// -----------------------------------------------------------------------------
|
|
1283 |
// Stops recognition. Unlike Cancel(), this function gives
|
|
1284 |
// the recognition result, if it can be guessed.
|
|
1285 |
// -----------------------------------------------------------------------------
|
|
1286 |
//
|
|
1287 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::EndRecord()
|
|
1288 |
{
|
|
1289 |
return iController.CustomCommandSync( iDestinationPckg, ESrEndRecord,
|
|
1290 |
KNullDesC8, KNullDesC8 ); // Async
|
|
1291 |
}
|
|
1292 |
|
|
1293 |
// -----------------------------------------------------------------------------
|
|
1294 |
// Deactivates a grammar.
|
|
1295 |
// -----------------------------------------------------------------------------
|
|
1296 |
//
|
|
1297 |
EXPORT_C TInt RSISpeechRecognitionCustomCommands::UnloadGrammar( TSIGrammarID aGrammarID )
|
|
1298 |
{
|
|
1299 |
TSrsGrammarIDPckg pckg( aGrammarID );
|
|
1300 |
|
|
1301 |
return iController.CustomCommandSync(iDestinationPckg, ESrUnloadGrammar,
|
|
1302 |
pckg, KNullDesC8 ); // Async
|
|
1303 |
}
|
|
1304 |
|
|
1305 |
|
|
1306 |
/************************** New SI functions stop here ************************/
|
|
1307 |
|
|
1308 |
// End of file
|