|
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __SPEECHRECOGNITIONCUSTOMCOMMANDPARSER_H__ |
|
17 #define __SPEECHRECOGNITIONCUSTOMCOMMANDPARSER_H__ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <mmf/common/mmfcontroller.h> |
|
21 #include <mmf/common/speechrecognitioncustomcommandimplementor.h> |
|
22 #include <mmf/common/speechrecognitiondataclient.h> |
|
23 |
|
24 // CLASS DECLARATION |
|
25 |
|
26 /** |
|
27 @publishedAll |
|
28 @released |
|
29 |
|
30 This is the main class of Speech Recognition Custom Commands Parser. |
|
31 |
|
32 @since 8.0 |
|
33 */ |
|
34 class CSpeechRecognitionCustomCommandParser : public CMMFCustomCommandParserBase |
|
35 { |
|
36 public: |
|
37 |
|
38 /** |
|
39 Factory function for creating this class. |
|
40 |
|
41 @param aImplementor |
|
42 A reference to a custom commands implementor. |
|
43 |
|
44 @return A pointer to a CSpeechRecognitionCustomCommandParser object. |
|
45 |
|
46 @since 8.0 |
|
47 */ |
|
48 IMPORT_C static CSpeechRecognitionCustomCommandParser* NewL( |
|
49 MSpeechRecognitionCustomCommandImplementor& |
|
50 aImplementor); |
|
51 |
|
52 /** |
|
53 Destructor. |
|
54 |
|
55 @since 8.0 |
|
56 */ |
|
57 IMPORT_C ~CSpeechRecognitionCustomCommandParser(); |
|
58 |
|
59 /** |
|
60 @internalTechnology |
|
61 |
|
62 Handles the request from the client. |
|
63 |
|
64 @param aMessage |
|
65 The message containing the information of the request. |
|
66 |
|
67 @since 8.0 |
|
68 */ |
|
69 void HandleRequest(TMMFMessage& aMessage); |
|
70 |
|
71 private: |
|
72 /** |
|
73 C++ constructor for a CSpeechRecognitionCustomCommandParser class. |
|
74 |
|
75 @param aImplementor |
|
76 A reference to a custom commands implementor. |
|
77 |
|
78 @since 8.0 |
|
79 */ |
|
80 CSpeechRecognitionCustomCommandParser( |
|
81 MSpeechRecognitionCustomCommandImplementor& aImplementor); |
|
82 |
|
83 /** |
|
84 Private method to handle the request from the client. |
|
85 |
|
86 @param aMessage |
|
87 The message containing the information of the request. |
|
88 |
|
89 @since 8.0 |
|
90 */ |
|
91 void DoHandleRequestL(TMMFMessage& aMessage); |
|
92 |
|
93 /** |
|
94 Adds a new pronunciation for the given model into the specified lexicon. |
|
95 |
|
96 @param aMessage |
|
97 The message containing the information of the request. |
|
98 |
|
99 @since 8.0 |
|
100 */ |
|
101 void DoAddPronunciationL(TMMFMessage& aMessage); |
|
102 |
|
103 /** |
|
104 Adds a new rule for the given pronunciation into the specified grammar. |
|
105 |
|
106 @param aMessage |
|
107 The message containing the information of the request. |
|
108 |
|
109 @since 8.0 |
|
110 */ |
|
111 void DoAddRuleL(TMMFMessage& aMessage); |
|
112 |
|
113 /** |
|
114 Cancels the current operation. |
|
115 |
|
116 @since 8.0 |
|
117 */ |
|
118 void DoCancel(); |
|
119 |
|
120 /** |
|
121 Commits uncommitted database operations to the database. |
|
122 |
|
123 @since 8.0 |
|
124 */ |
|
125 void DoCommitChangesL(); |
|
126 |
|
127 /** |
|
128 Creates a new grammar. |
|
129 |
|
130 @param aMessage |
|
131 A message containing the information of the request. |
|
132 |
|
133 @since 8.0 |
|
134 */ |
|
135 void DoCreateGrammarL(TMMFMessage& aMessage); |
|
136 |
|
137 /** |
|
138 Creates a new lexicon. |
|
139 |
|
140 @param aMessage |
|
141 The message containing the information of the request. |
|
142 |
|
143 @since 8.0 |
|
144 */ |
|
145 void DoCreateLexiconL(TMMFMessage& aMessage); |
|
146 |
|
147 /** |
|
148 Creates a new model bank. |
|
149 |
|
150 @param aMessage |
|
151 The message containing the information of the request. |
|
152 |
|
153 @since 8.0 |
|
154 */ |
|
155 void DoCreateModelBankL(TMMFMessage& aMessage); |
|
156 |
|
157 /** |
|
158 Ends the current recognition session. Resources allocated for recognition are freed. |
|
159 |
|
160 @since 8.0 |
|
161 */ |
|
162 void DoEndRecSessionL(); |
|
163 |
|
164 /** |
|
165 Returns all grammar IDs that belong to the current client, whose UID was set with |
|
166 SetClientUid(). |
|
167 |
|
168 @since 8.0 |
|
169 */ |
|
170 void DoGetAllClientGrammarIDsL(); |
|
171 |
|
172 /** |
|
173 Returns all lexicon IDs that belong to the current client, whose UID was set with |
|
174 SetClientUid(). |
|
175 |
|
176 @since 8.0 |
|
177 */ |
|
178 void DoGetAllClientLexiconIDsL(); |
|
179 |
|
180 /** |
|
181 Returns all model bank IDs that belong to the current client, whose UID was set with |
|
182 SetClientUid(). |
|
183 |
|
184 @since 8.0 |
|
185 */ |
|
186 void DoGetAllClientModelBankIDsL(); |
|
187 |
|
188 /** |
|
189 Returns all grammar IDs that exist (for all clients). |
|
190 |
|
191 @return An error code indicating if the function call was successful. KErrNone on success, otherwise |
|
192 another of the system-wide error codes. |
|
193 |
|
194 @since 8.0 |
|
195 */ |
|
196 void DoGetAllGrammarIDsL(); |
|
197 |
|
198 /** |
|
199 Returns all lexicon IDs that exist (for all clients). |
|
200 |
|
201 @since 8.0 |
|
202 */ |
|
203 void DoGetAllLexiconIDsL(); |
|
204 |
|
205 /** |
|
206 Returns all model bank IDs that exist (for all clients). |
|
207 |
|
208 @since 8.0 |
|
209 */ |
|
210 void DoGetAllModelBankIDsL(); |
|
211 |
|
212 /** |
|
213 Returns all model IDs that exist in the specified model bank. |
|
214 |
|
215 @param aMessage |
|
216 The message containing the information of the request. |
|
217 |
|
218 @since 8.0 |
|
219 */ |
|
220 void DoGetAllModelIDsL(TMMFMessage& aMessage); |
|
221 |
|
222 /** |
|
223 Returns all pronunciation IDs that exist in the specified lexicon. |
|
224 |
|
225 @param aMessage |
|
226 The message containing the information of the request. |
|
227 |
|
228 @since 8.0 |
|
229 */ |
|
230 void DoGetAllPronunciationIDsL(TMMFMessage& aMessage); |
|
231 |
|
232 /** |
|
233 Returns all rule IDs that exist in the specified grammar. |
|
234 |
|
235 @param aMessage |
|
236 The message containing the information of the request. |
|
237 |
|
238 @since 8.0 |
|
239 */ |
|
240 void DoGetAllRuleIDsL(TMMFMessage& aMessage); |
|
241 |
|
242 /** |
|
243 Returns the number of models available for training system wide, based on available disk space. |
|
244 |
|
245 @param aMessage |
|
246 The message containing the information of the request. |
|
247 |
|
248 @since 8.0 |
|
249 */ |
|
250 void DoGetAvailableStorageL(TMMFMessage& aMessage); |
|
251 |
|
252 /** |
|
253 Returns the engine properties. |
|
254 |
|
255 @param aMessage |
|
256 The message containing the information of the request. |
|
257 |
|
258 @since 8.0 |
|
259 */ |
|
260 void DoGetEnginePropertiesL(TMMFMessage& aMessage); |
|
261 |
|
262 /** |
|
263 Returns the number of models in the specified model bank. |
|
264 |
|
265 @param aMessage |
|
266 The message containing the information of the request. |
|
267 |
|
268 @since 8.0 |
|
269 */ |
|
270 void DoGetModelCountL(TMMFMessage& aMessage); |
|
271 |
|
272 /** |
|
273 Checks if the rule is valid or not. |
|
274 |
|
275 @param aMessage |
|
276 The message containing the information of the request. |
|
277 |
|
278 @since 8.0 |
|
279 */ |
|
280 void DoGetRuleValidityL(TMMFMessage& aMessage); |
|
281 |
|
282 /** |
|
283 Returns the duration of the utterance for the specified model. |
|
284 |
|
285 @param aMessage |
|
286 The message containing the information of the request. |
|
287 |
|
288 @since 8.0 |
|
289 */ |
|
290 void DoGetUtteranceDurationL(TMMFMessage& aMessage); |
|
291 |
|
292 /** |
|
293 Loads the specified grammar into the recognizer; done prior to recognition. |
|
294 |
|
295 @param aMessage |
|
296 The message containing the information of the request. |
|
297 |
|
298 @since 8.0 |
|
299 */ |
|
300 void DoLoadGrammarL(TMMFMessage& aMessage); |
|
301 |
|
302 /** |
|
303 Loads the specified lexicon into the recognizer; done prior to recognition. |
|
304 |
|
305 @param aMessage |
|
306 The message containing the information of the request. |
|
307 |
|
308 @since 8.0 |
|
309 */ |
|
310 void DoLoadLexiconL(TMMFMessage& aMessage); |
|
311 |
|
312 /** |
|
313 Loads the specified model bank into the recognizer; done prior to recognition. |
|
314 |
|
315 @param aMessage |
|
316 The message containing the information of the request. |
|
317 |
|
318 @since 8.0 |
|
319 */ |
|
320 void DoLoadModelsL(TMMFMessage& aMessage); |
|
321 |
|
322 /** |
|
323 Plays the previously trained utterance. |
|
324 |
|
325 @param aMessage |
|
326 The message containing the information of the request. |
|
327 |
|
328 @since 8.0 |
|
329 */ |
|
330 void DoPlayUtteranceL(TMMFMessage& aMessage); |
|
331 |
|
332 /** |
|
333 Initiates recognition; performed following loading of model bank, lexicon, and grammar. |
|
334 |
|
335 @param aMessage |
|
336 The message containing the information of the request. |
|
337 |
|
338 @since 8.0 |
|
339 */ |
|
340 void DoRecognizeL(TMMFMessage& aMessage); |
|
341 |
|
342 /** |
|
343 Records user utterance for training and recognition. |
|
344 |
|
345 @param aMessage |
|
346 The message containing the information of the request. |
|
347 |
|
348 @since 8.0 |
|
349 */ |
|
350 void DoRecordL(TMMFMessage& aMessage); |
|
351 |
|
352 /** |
|
353 Removes the specified grammar from the permanent storage. |
|
354 |
|
355 Removing a grammar will remove all rules within the grammar. |
|
356 |
|
357 @param aMessage |
|
358 The message containing the information of the request. |
|
359 |
|
360 @since 8.0 |
|
361 */ |
|
362 void DoRemoveGrammarL(TMMFMessage& aMessage); |
|
363 |
|
364 /** |
|
365 Removes the specified lexicon from the permanent storage. |
|
366 |
|
367 Removing a lexicon will remove all pronunciations within the lexicon. |
|
368 |
|
369 @param aMessage |
|
370 The message containing the information of the request. |
|
371 |
|
372 @since 8.0 |
|
373 */ |
|
374 void DoRemoveLexiconL(TMMFMessage& aMessage); |
|
375 |
|
376 /** |
|
377 Removes the specified model bank from the permanent storage. |
|
378 |
|
379 Removing a model bank will remove all models within the model bank. |
|
380 |
|
381 @param aMessage |
|
382 The message containing the information of the request. |
|
383 |
|
384 @since 8.0 |
|
385 */ |
|
386 void DoRemoveModelBankL(TMMFMessage& aMessage); |
|
387 |
|
388 /** |
|
389 Removes the specified model from the specified model bank permanently. |
|
390 |
|
391 @param aMessage |
|
392 The message containing the information of the request. |
|
393 |
|
394 @since 8.0 |
|
395 */ |
|
396 void DoRemoveModelL(TMMFMessage& aMessage); |
|
397 |
|
398 /** |
|
399 Removes the specified pronunciation from the specified lexicon permanently. |
|
400 |
|
401 @param aMessage |
|
402 The message containing the information of the request. |
|
403 |
|
404 @since 8.0 |
|
405 */ |
|
406 void DoRemovePronunciationL(TMMFMessage& aMessage); |
|
407 |
|
408 /** |
|
409 Removes the specified rule from the specified grammar permanently. |
|
410 |
|
411 @param aMessage |
|
412 The message containing the information of the request. |
|
413 |
|
414 @since 8.0 |
|
415 */ |
|
416 void DoRemoveRuleL(TMMFMessage& aMessage); |
|
417 |
|
418 /** |
|
419 Sets the UID of the client. |
|
420 |
|
421 @param aMessage |
|
422 The message containing the information of the request. |
|
423 |
|
424 @since 8.0 |
|
425 */ |
|
426 void DoSetClientUidL(TMMFMessage& aMessage); |
|
427 |
|
428 /** |
|
429 Starts a new recognition session. |
|
430 |
|
431 @param aMessage |
|
432 The message containing the information of the request. |
|
433 |
|
434 @since 8.0 |
|
435 */ |
|
436 void DoStartRecSessionL(TMMFMessage& aMessage); |
|
437 |
|
438 /** |
|
439 Trains a new model into the specified model bank. |
|
440 |
|
441 @param aMessage |
|
442 The message containing the information of the request. |
|
443 |
|
444 @since 8.0 |
|
445 */ |
|
446 void DoTrainL(TMMFMessage& aMessage); |
|
447 |
|
448 /** |
|
449 Unloads the specified rule from the specified grammar in temporary |
|
450 memory, previously loaded with LoadGrammarL(). |
|
451 |
|
452 The rule in the permanent storage remains intact. |
|
453 |
|
454 @param aMessage |
|
455 The message containing the information of the request. |
|
456 |
|
457 @since 8.0 |
|
458 */ |
|
459 void DoUnloadRuleL(TMMFMessage& aMessage); |
|
460 |
|
461 /** |
|
462 Loads the specified parameters into the engine. |
|
463 |
|
464 @param aMessage |
|
465 The message containing the information of the request. |
|
466 |
|
467 @since 8.0 |
|
468 */ |
|
469 void DoLoadEngineParametersL(TMMFMessage& aMessage); |
|
470 |
|
471 /** |
|
472 Copies the pronunciation ID array stored by a previous GetAllPronunciationIDs call. |
|
473 |
|
474 @param aMessage |
|
475 The message containing the information of the request. |
|
476 |
|
477 @since 8.0 |
|
478 */ |
|
479 void DoCopyPronunciationIDArrayL(TMMFMessage& aMessage); |
|
480 |
|
481 /** |
|
482 Copy the model ID array stored by a previous GetAllModelIDs call. |
|
483 |
|
484 @param aMessage |
|
485 The message containing the information of the request. |
|
486 |
|
487 @since 8.0 |
|
488 */ |
|
489 void DoCopyModelIDArrayL(TMMFMessage& aMessage); |
|
490 |
|
491 /** |
|
492 Copies the rule ID array stored by a previous GetAllRuleIDs call. |
|
493 |
|
494 @param aMessage |
|
495 The message containing the information of the request. |
|
496 |
|
497 @since 8.0 |
|
498 */ |
|
499 void DoCopyRuleIDArrayL(TMMFMessage& aMessage); |
|
500 /** |
|
501 Copies the grammar ID array stored by a previous GetAllGrammarIDs call. |
|
502 |
|
503 @param aMessage |
|
504 The message containing the information of the request. |
|
505 |
|
506 @since 8.0 |
|
507 */ |
|
508 void DoCopyGrammarIDArrayL(TMMFMessage& aMessage); |
|
509 |
|
510 /** |
|
511 Copies the lexicon ID array stored by a previous GetAllLexiconIDs call. |
|
512 |
|
513 @param aMessage |
|
514 The message containing the information of the request. |
|
515 |
|
516 @since 8.0 |
|
517 */ |
|
518 void DoCopyLexiconIDArrayL(TMMFMessage& aMessage); |
|
519 |
|
520 /** |
|
521 Copies the modelBank ID array stored by a previous GetAllModelBankIDs call. |
|
522 |
|
523 @param aMessage |
|
524 The message containing the information of the request. |
|
525 |
|
526 @since 8.0 |
|
527 */ |
|
528 void DoCopyModelBankIDArrayL(TMMFMessage& aMessage); |
|
529 |
|
530 /** |
|
531 Externalises the result set into a descriptor, so that it can be copied into an array. |
|
532 */ |
|
533 void DoExternalizeResultSetL(); |
|
534 |
|
535 /** |
|
536 Copies the previously externalised result set into a message. The message must be the same size as |
|
537 the stored externalized result set. |
|
538 */ |
|
539 void DoCopyResultSetL(TMMFMessage& aMessage); |
|
540 |
|
541 |
|
542 /** |
|
543 Extracts an array from first parameter of TMMFMessage. |
|
544 |
|
545 @param aMessage |
|
546 The message to copy the array from. |
|
547 @param aArray |
|
548 The array to copy into. |
|
549 |
|
550 @since 8.0 |
|
551 */ |
|
552 void DoExtractIntArrayFromData1L(TMMFMessage& aMessage, RArray<TInt>& aArray); |
|
553 |
|
554 /** |
|
555 Extracts an array from second parameter of TMMFMessage. |
|
556 |
|
557 @param aMessage |
|
558 The message to copy array from. |
|
559 @param aArray |
|
560 The array to copy into. |
|
561 |
|
562 @since 8.0 |
|
563 */ |
|
564 void DoExtractIntArrayFromData2L(TMMFMessage& aMessage, RArray<TInt>& aArray); |
|
565 |
|
566 /** |
|
567 Extracts an integer array from the descriptor. |
|
568 |
|
569 @param aDescriptor |
|
570 The descriptor containing an integer. |
|
571 @param aArray |
|
572 The array to copy into. |
|
573 |
|
574 @since 8.0 |
|
575 */ |
|
576 void DoExtractIntArrayL(TDes8& aDescriptor, RArray<TInt>& aArray); |
|
577 |
|
578 |
|
579 |
|
580 /** |
|
581 Copies the specified integer array given into a TMMFMessage. |
|
582 |
|
583 @param aMessage |
|
584 The message to copy the array into. |
|
585 @param aArray |
|
586 The array to copy from. |
|
587 |
|
588 @since 8.0 |
|
589 */ |
|
590 void DoCopyIntArrayL(TMMFMessage& aMessage, const RArray<TInt>& aArray); |
|
591 |
|
592 |
|
593 private: |
|
594 // reference to the Custom Command Implementor class |
|
595 MSpeechRecognitionCustomCommandImplementor& iImplementor; |
|
596 |
|
597 RArray<TPronunciationID> iPronunciationIDs; |
|
598 RArray<TModelID> iModelIDs; |
|
599 RArray<TRuleID> iRuleIDs; |
|
600 |
|
601 RArray<TGrammarID> iGrammarIDs; |
|
602 RArray<TLexiconID> iLexiconIDs; |
|
603 RArray<TModelBankID> iModelBankIDs; |
|
604 |
|
605 |
|
606 CSDClientResultSet* iResultSet; |
|
607 CBufFlat* iResultCopyBuffer; |
|
608 |
|
609 // Remove? |
|
610 // TAny* iReservedPtr_1; // reserved for future expansion |
|
611 // TAny* iReservedPtr_2; // reserved for future expansion |
|
612 }; |
|
613 #endif // of __SPEECHRECOGNITIONCUSTOMCOMMANDPARSER_H__ |
|
614 |
|
615 // End of file |