os/mm/mmdevicefw/speechrecogsupport/ASR/inc/mmf/common/SpeechRecognitionCustomCommands.h
First public contribution.
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 "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __SPEECHRECOGNITIONCUSTOMCOMMANDS_H__
17 #define __SPEECHRECOGNITIONCUSTOMCOMMANDS_H__
20 #include <mmf/common/mmfcontroller.h>
21 #include <mmf/common/speechrecognitiondataclient.h>
27 This is the main class of Speech Recognition Custom Commands.
31 class RSpeechRecognitionCustomCommands : public RMMFCustomCommandsBase
35 Public C++ constructor for RSpeechRecognitionCustomCommands class.
38 A reference to a RMMFController object.
42 IMPORT_C RSpeechRecognitionCustomCommands(RMMFController& aController);
45 Adds a new pronunciation for the given model into the specified lexicon.
48 The lexicon ID to where the new pronunciation is added.
53 @param aPronunciationID
54 A reference to where a new pronunciation ID is assigned.
56 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
57 another of the system-wide error codes.
61 IMPORT_C TInt AddPronunciation(TLexiconID aLexiconID,
62 TModelBankID aModelBankID, TModelID aModelID,
63 TPronunciationID& aPronunciationID);
66 Adds a new rule for the given pronunciation into the specified grammar.
69 The grammar ID to where the new rule is added.
72 @param aPronunciationID
75 A reference to where a new rule ID is assigned.
77 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
78 another of the system-wide error codes.
82 IMPORT_C TInt AddRule(TGrammarID aGrammarID, TLexiconID aLexiconID,
83 TPronunciationID aPronunciationID, TRuleID& aRuleID);
86 Cancels the current operation.
90 IMPORT_C void Cancel();
93 Commits the current train operation to the database.
95 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
96 another of the system-wide error codes.
100 IMPORT_C TInt CommitChanges();
103 Creates a new grammar.
106 A reference to where the grammar ID is stored.
108 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
109 another of the system-wide error codes.
113 IMPORT_C TInt CreateGrammar(TGrammarID& aGrammarID);
116 Creates a new lexicon.
119 A reference where lexicon ID is stored.
121 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
122 another of the system-wide error codes.
126 IMPORT_C TInt CreateLexicon(TLexiconID& aLexiconID);
129 Creates a new model bank.
132 A reference to where a new model bank ID is assigned.
134 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
135 another of the system-wide error codes.
139 IMPORT_C TInt CreateModelBank(TModelBankID& aModelBankID);
142 Ends the current recognition session.
144 The resources allocated for recognition are freed.
146 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
147 another of the system-wide error codes.
151 IMPORT_C TInt EndRecSession();
154 Returns all grammar IDs owned by the client.
156 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
157 another of the system-wide error codes.
161 IMPORT_C TInt GetAllClientGrammarIDs();
164 Returns all lexicon IDs owned by the client.
166 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
167 another of the system-wide error codes.
171 IMPORT_C TInt GetAllClientLexiconIDs();
174 Returns all modelBank IDs owned by the client.
176 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
177 another of the system-wide error codes.
181 IMPORT_C TInt GetAllClientModelBankIDs();
184 Returns all grammar IDs owned by the client.
186 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
187 another of the system-wide error codes.
191 IMPORT_C TInt GetAllGrammarIDs();
194 Returns all lexicon IDs owned by the client.
196 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
197 another of the system-wide error codes.
201 IMPORT_C TInt GetAllLexiconIDs();
205 Returns all modelBank IDs owned by the client.
207 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
208 another of the system-wide error codes.
212 IMPORT_C TInt GetAllModelBankIDs();
215 Returns all model IDs that exist in the specified model bank.
220 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
221 another of the system-wide error codes.
225 IMPORT_C TInt GetAllModelIDs(TModelBankID aModelBankID);
228 Returns all pronunciation IDs that exist in the specified lexicon.
233 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
234 another of the system-wide error codes.
238 IMPORT_C TInt GetAllPronunciationIDs(TLexiconID aLexiconID);
241 Returns all rule IDs that exist in the specified grammar.
246 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
247 another of the system-wide error codes.
251 IMPORT_C TInt GetAllRuleIDs(TGrammarID aGrammarID);
254 Returns the number of models available for training system wide,
255 based on available disk space.
257 @param aAvailableStorage
258 The number of models that can be held in available storage space.
260 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
261 another of the system-wide error codes.
265 IMPORT_C TInt GetAvailableStorage(TInt& aAvailableStorage);
268 Returns the engine properties specified by the engine property
269 ID array. On return aPropertyValue contains an array of engine
273 A constant reference to an array of engine property IDs.
274 @param aPropertyValue
275 A reference to an array of engine property values.
277 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
278 another of the system-wide error codes.
282 IMPORT_C TInt GetEngineProperties(const RArray<TInt>& aPropertyId,
283 RArray<TInt>& aPropertyValue);
286 Returns the number of models in the specified model bank.
291 The reference where the number of models is set.
293 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
294 another of the system-wide error codes.
298 IMPORT_C TInt GetModelCount(TModelBankID aModelBankID,
303 Checks if the rule is valid or not.
310 A reference where the validity of the rule is set.
312 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
313 another of the system-wide error codes.
317 IMPORT_C TInt GetRuleValidity(TGrammarID aGrammarID, TRuleID aRuleID,
322 * Returns the duration of the utterance for the specified model.
324 * @param aModelBankID model bank Id
325 * @param aModelID model Id
326 * @param aDuration reference where the duration of
328 * @return System-wide errors
330 IMPORT_C TInt GetUtteranceDuration(TModelBankID aModelBankID,
331 TModelID aModelID, TTimeIntervalMicroSeconds32& aDuration);
334 Loads the specified grammar into the recognizer; done prior to recognition.
339 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
340 another of the system-wide error codes.
344 IMPORT_C TInt LoadGrammar(TGrammarID aGrammarID);
347 Loads the specified lexicon into the recognizer; done prior to recognition.
352 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
353 another of the system-wide error codes.
357 IMPORT_C TInt LoadLexicon(TLexiconID aLexiconID);
360 Loads the specified model bank into the recognizer; done prior to recognition.
365 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
366 another of the system-wide error codes.
370 IMPORT_C TInt LoadModels(TModelBankID aModelBankID);
373 Plays the previously trained utterance.
378 The model ID, whose utterance is played.
380 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
381 another of the system-wide error codes.
385 IMPORT_C TInt PlayUtterance(TModelBankID aModelBankID,
389 Initiates recognition; performed following loading of model bank, lexicon, and grammar.
392 A reference where the recognition result is set.
394 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
395 another of the system-wide error codes.
399 IMPORT_C TInt Recognize(CSDClientResultSet& aResultSet);
402 Records the user utterance for training and recognition.
405 The recording time in microseconds.
407 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
408 another of the system-wide error codes.
412 IMPORT_C TInt Record(TTimeIntervalMicroSeconds32 aRecordTime);
415 Removes the specified grammar from the permanent storage.
417 Removing a grammar will remove all rules within the grammar.
422 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
423 another of the system-wide error codes.
427 IMPORT_C TInt RemoveGrammar(TGrammarID aGrammarID);
430 Removes the specified lexicon from the permanent storage.
432 Removing a lexicon will remove all pronunciations within the lexicon.
437 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
438 another of the system-wide error codes.
441 IMPORT_C TInt RemoveLexicon(TLexiconID aLexiconID);
444 Removes the specified model bank from the permanent storage.
446 Removing a model bank will remove all models within the model bank.
451 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
452 another of the system-wide error codes.
456 IMPORT_C TInt RemoveModelBank(TModelBankID aModelBankID);
459 Removes the specified model from the specified model bank permanently.
466 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
467 another of the system-wide error codes.
471 IMPORT_C TInt RemoveModel(TModelBankID aModelBankID,
475 Removes the specified pronunciation from the specified lexicon permanently.
479 @param aPronunciationID
480 The pronunciation ID.
482 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
483 another of the system-wide error codes.
487 IMPORT_C TInt RemovePronunciation(TLexiconID aLexiconID,
488 TPronunciationID aPronunciationID);
491 Removes the specified rule from the specified grammar permanently.
498 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
499 another of the system-wide error codes.
503 IMPORT_C TInt RemoveRule(TGrammarID aGrammarID, TRuleID aRuleID);
506 Sets the client UID for client.
511 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
512 another of the system-wide error codes.
516 IMPORT_C TInt SetClientUid(TUid aClientUid);
519 Starts a new recognition session.
522 The recognition mode.
524 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
525 another of the system-wide error codes.
529 IMPORT_C TInt StartRecSession(TRecognitionMode aMode);
532 Trains a new model into the specified model bank.
537 The reference to where a new model ID is assigned.
539 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
540 another of the system-wide error codes.
544 IMPORT_C TInt Train(TModelBankID aModelBankID, TModelID& aModelID);
547 Unloads the specified rule from the specified grammar in temporary
548 memory, previously loaded with LoadGrammarL(). The rule in the
549 permanent storage remains intact.
556 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
557 another of the system-wide error codes.
561 IMPORT_C TInt UnloadRule(TGrammarID aGrammarID, TRuleID aRuleID);
564 Uploads the specified parameters into the engine.
567 An array of parameter IDs.
568 @param aParameterValue
569 An array of parameter values.
571 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
572 another of the system-wide error codes.
576 IMPORT_C TInt LoadEngineParameters(const RArray<TInt>& aParameterId,
577 const RArray<TInt>& aParameterValue);
580 Gets an array of pronunciation IDs previously requested by GetAllPronunciationIDs.
582 @param aPronunciationIDs
583 An array to store pronunciation IDs.
587 IMPORT_C void GetPronunciationIDArrayL(RArray<TPronunciationID>& aPronunciationIDs);
590 Gets an array of rule IDs previously requested by GetAllRuleIDs.
593 An array to store rule IDs.
597 IMPORT_C void GetRuleIDArrayL(RArray<TRuleID>& aRuleIDs);
600 Gets an array of model IDs previously requested by GetAllModelIDs.
603 An array to store model IDs.
607 IMPORT_C void GetModelIDArrayL(RArray<TModelID>& aModelIDs);
610 Gets an array of grammar IDs previously requested by GetAllGrammarIDs.
613 An array to store grammar IDs.
617 IMPORT_C void GetGrammarIDArrayL(RArray<TGrammarID>& aGrammarIDs);
620 Gets an array of lexicon IDs previously requested by GetAllLexiconIDs.
623 An array to store lexicon IDs.
627 IMPORT_C void GetLexiconIDArrayL(RArray<TLexiconID>& aLexiconIDs);
631 Gets an array of modelBank IDs previously requested by GetAllModelBankIDs.
634 An array to store modelBank IDs.
638 IMPORT_C void GetModelBankIDArrayL(RArray<TModelBankID>& aModelBankIDs);
642 Gets a client result set previously created by a call to Recognise().
645 The ResultSet used to contain the recognition results
649 IMPORT_C void GetResultSetL(CSDClientResultSet& aResultSet);
652 void DoGetEnginePropertiesL(const RArray<TInt>& aPropertyId,
653 RArray<TInt>& aPropertyValue);
654 void DoLoadEngineParametersL(const RArray<TInt>& aParameterId,
655 const RArray<TInt>& aParameterValue);
658 CBufFlat* ExternalizeIntArrayL(const RArray<TInt>& aArray);
659 void InternalizeIntArrayL(TDes8& aDes, TInt aNumberElements, RArray<TInt>& aArray);
661 void DoRecognizeL(CSDClientResultSet& aResultSet);
663 TAny* iReservedPtr_1; // reserved for future expansion
664 TAny* iReservedPtr_2; // reserved for future expansion
667 #endif // __SPEECHRECOGNITIONCUSTOMCOMMANDS_H__