os/mm/mmdevicefw/speechrecogsupport/ASR/inc/mmf/common/SpeechRecognitionCustomCommands.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __SPEECHRECOGNITIONCUSTOMCOMMANDS_H__
    17 #define __SPEECHRECOGNITIONCUSTOMCOMMANDS_H__
    18 
    19 //  INCLUDES
    20 #include	<mmf/common/mmfcontroller.h>
    21 #include 	<mmf/common/speechrecognitiondataclient.h>
    22 
    23 /**
    24 @publishedAll
    25 @released
    26 
    27 This is the main class of Speech Recognition Custom Commands.
    28 
    29 @since  8.0
    30 */
    31 class RSpeechRecognitionCustomCommands : public RMMFCustomCommandsBase
    32 	{
    33 public:
    34 	/**
    35 	Public C++ constructor for RSpeechRecognitionCustomCommands class.
    36 
    37 	@param  aController			
    38 	        A reference to a RMMFController object.
    39 
    40 	@since  8.0
    41 	*/
    42 	IMPORT_C RSpeechRecognitionCustomCommands(RMMFController& aController);
    43 	
    44 	/** 
    45 	Adds a new pronunciation for the given model into the specified lexicon.
    46 
    47 	@param  aLexiconID
    48 	        The lexicon ID to where the new pronunciation is added.
    49 	@param  aModelBankID
    50 	        The model bank ID.
    51 	@param  aModelID
    52 	        The model ID.
    53 	@param  aPronunciationID
    54 	        A reference to where a new pronunciation ID is assigned.
    55 
    56 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
    57 	        another of the system-wide error codes.
    58 
    59 	@since  8.0
    60 	*/
    61 	IMPORT_C TInt AddPronunciation(TLexiconID aLexiconID,
    62 					TModelBankID aModelBankID, TModelID aModelID,
    63 					TPronunciationID& aPronunciationID);
    64 
    65 	/**
    66 	Adds a new rule for the given pronunciation into the specified grammar.
    67 
    68 	@param  aGrammarID			
    69 	        The grammar ID to where the new rule is added.
    70 	@param  aLexiconID			
    71 	        The lexicon ID.
    72 	@param  aPronunciationID	
    73 	        The pronunciation ID.
    74 	@param  aRuleID				
    75 	        A reference to where a new rule ID is assigned.
    76 
    77 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
    78 	        another of the system-wide error codes.
    79 
    80 	@since  8.0
    81 	*/
    82 	IMPORT_C TInt AddRule(TGrammarID aGrammarID, TLexiconID aLexiconID,
    83 					TPronunciationID aPronunciationID, TRuleID& aRuleID);
    84 
    85 	/**
    86 	Cancels the current operation.
    87 
    88 	@since  8.0
    89 	*/
    90 	IMPORT_C void Cancel();
    91 
    92 	/**
    93 	Commits the current train operation to the database.
    94 
    95 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
    96 	        another of the system-wide error codes.
    97 
    98 	@since  8.0
    99 	*/
   100 	IMPORT_C TInt CommitChanges();
   101 
   102 	/**
   103 	Creates a new grammar.
   104 
   105 	@param  aGrammarID
   106 	        A reference to where the grammar ID is stored.
   107 
   108 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   109 	        another of the system-wide error codes.
   110 
   111 	@since  8.0
   112     */
   113 	IMPORT_C TInt CreateGrammar(TGrammarID& aGrammarID);
   114 
   115 	/**
   116 	Creates a new lexicon.
   117 
   118 	@param  aLexiconID			
   119 	        A reference where lexicon ID is stored.
   120 
   121 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   122 	        another of the system-wide error codes.
   123 
   124 	@since  8.0
   125     */
   126 	IMPORT_C TInt CreateLexicon(TLexiconID& aLexiconID);
   127 
   128     /**
   129 	Creates a new model bank.
   130 
   131 	@param  aModelBankID		
   132 	        A reference to where a new model bank ID is assigned.
   133 
   134 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   135 	        another of the system-wide error codes.
   136 
   137 	@since  8.0
   138     */
   139 	IMPORT_C TInt CreateModelBank(TModelBankID& aModelBankID);
   140 
   141 	/**
   142 	Ends the current recognition session.
   143 	
   144 	The resources allocated for recognition are freed.
   145 
   146 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   147 	        another of the system-wide error codes.
   148 
   149 	@since  8.0
   150     */
   151 	IMPORT_C TInt EndRecSession();
   152 
   153 	/**
   154 	Returns all grammar IDs owned by the client.
   155 
   156 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   157 	        another of the system-wide error codes.
   158 
   159 	@since  8.0
   160     */
   161 	IMPORT_C TInt GetAllClientGrammarIDs();
   162 
   163 	/**
   164 	Returns all lexicon IDs owned by the client.
   165 
   166 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   167 	        another of the system-wide error codes.
   168 	
   169 	@since  8.0
   170     */
   171 	IMPORT_C TInt GetAllClientLexiconIDs();
   172 
   173 	/**
   174 	Returns all modelBank IDs owned by the client.
   175 
   176     @return An error code indicating if the function call was successful. KErrNone on success, otherwise
   177 	           another of the system-wide error codes.
   178 
   179 	@since  8.0
   180     */
   181 	IMPORT_C TInt GetAllClientModelBankIDs();
   182 
   183 	/**
   184 	Returns all grammar IDs owned by the client.
   185 
   186 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   187 	        another of the system-wide error codes.
   188 
   189 	@since  8.0
   190     */
   191 	IMPORT_C TInt GetAllGrammarIDs();
   192 
   193 	/**
   194 	Returns all lexicon IDs owned by the client.
   195 
   196 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   197 	        another of the system-wide error codes.
   198 
   199 	@since  8.0
   200     */
   201 	IMPORT_C TInt GetAllLexiconIDs();
   202 
   203 
   204 	/**
   205 	Returns all modelBank IDs owned by the client.
   206 
   207 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   208 	        another of the system-wide error codes.
   209 
   210 	@since  8.0
   211     */
   212 	IMPORT_C TInt GetAllModelBankIDs();
   213 
   214 	/**
   215 	Returns all model IDs that exist in the specified model bank.
   216 
   217 	@param  aModelBankID		
   218 	        The model bank ID.
   219 
   220 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   221 	        another of the system-wide error codes.
   222 
   223 	@since  8.0
   224     */
   225 	IMPORT_C TInt GetAllModelIDs(TModelBankID aModelBankID);
   226 
   227 	/**
   228 	Returns all pronunciation IDs that exist in the specified lexicon.
   229 
   230 	@param  aLexiconID			
   231 	        The lexicon ID.
   232 
   233 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   234 	        another of the system-wide error codes.
   235 
   236 	@since  8.0
   237     */
   238 	IMPORT_C TInt GetAllPronunciationIDs(TLexiconID aLexiconID);
   239 
   240 	/**
   241 	Returns all rule IDs that exist in the specified grammar.
   242 
   243     @param  aGrammarID			
   244 	        The grammar ID.
   245 
   246 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   247 	        another of the system-wide error codes.
   248 
   249 	@since  8.0
   250     */
   251 	IMPORT_C TInt GetAllRuleIDs(TGrammarID aGrammarID);
   252 
   253 	/**
   254 	Returns the number of models available for training system wide,
   255 	based on available disk space.
   256 
   257 	@param  aAvailableStorage	
   258 	        The number of models that can be held in available storage space.
   259 
   260 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   261 	        another of the system-wide error codes.
   262 
   263 	@since  8.0
   264     */
   265 	IMPORT_C TInt GetAvailableStorage(TInt& aAvailableStorage);
   266 
   267 	/**
   268 	Returns the engine properties specified by the engine property
   269 	ID array. On return aPropertyValue contains an array of engine
   270 	properties.
   271 
   272 	@param  aPropertyId		
   273 	        A constant reference to an array of engine property IDs.
   274 	@param  aPropertyValue	
   275 	        A reference to an array of engine property values.
   276 
   277 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   278 	        another of the system-wide error codes.
   279 
   280 	@since  8.0
   281     */
   282 	IMPORT_C TInt GetEngineProperties(const RArray<TInt>& aPropertyId,
   283 					RArray<TInt>& aPropertyValue);
   284 
   285 	/**
   286 	Returns the number of models in the specified model bank.
   287 
   288 	@param  aModelBankID		
   289 	        The model bank ID.
   290 	@param  aModelCount			
   291 	        The reference where the number of models is set.
   292 
   293 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   294 	        another of the system-wide error codes.
   295 
   296 	@since  8.0
   297     */
   298 	IMPORT_C TInt GetModelCount(TModelBankID aModelBankID,
   299 					TInt& aModelCount);
   300 
   301 
   302 	/**
   303 	Checks if the rule is valid or not.
   304 
   305 	@param  aGrammarID			
   306             The grammar ID.
   307 	@param  aRuleID				
   308 	        The rule ID.
   309 	@param  aValid				
   310 	        A reference where the validity of the rule is set.
   311 
   312 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   313 	        another of the system-wide error codes.
   314 
   315 	@since  8.0
   316     */
   317 	IMPORT_C TInt GetRuleValidity(TGrammarID aGrammarID, TRuleID aRuleID, 
   318 					TBool& aValid);
   319 
   320 	/**
   321     *
   322     *	Returns the duration of the utterance for the specified model.
   323     * @since 8.0
   324     * @param	aModelBankID		model bank Id
   325 	* @param	aModelID			model Id
   326 	* @param	aDuration			reference where the duration of 
   327 	*								utterance is set
   328     * @return	System-wide errors
   329     */
   330 	IMPORT_C TInt GetUtteranceDuration(TModelBankID aModelBankID, 
   331 				TModelID aModelID, TTimeIntervalMicroSeconds32& aDuration);
   332 
   333 	/**
   334     Loads the specified grammar into the recognizer; done prior to recognition.
   335 
   336     @param  aGrammarID			
   337 	        The grammar ID.
   338 
   339 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   340 	        another of the system-wide error codes.
   341 
   342     @since  8.0
   343     */
   344 	IMPORT_C TInt LoadGrammar(TGrammarID aGrammarID);
   345 
   346 	/**
   347 	Loads the specified lexicon into the recognizer; done prior to recognition.
   348 
   349 	@param  aLexiconID			
   350 	        The lexicon ID.
   351 
   352 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   353 	        another of the system-wide error codes.
   354 
   355 	@since  8.0
   356     */
   357 	IMPORT_C TInt LoadLexicon(TLexiconID aLexiconID);
   358 
   359 	/**
   360 	Loads the specified model bank into the recognizer; done prior to recognition.
   361 
   362 	@param  aModelBankID		
   363 	        The model bank ID.
   364 
   365 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   366 	        another of the system-wide error codes.
   367 
   368 	@since  8.0
   369     */
   370 	IMPORT_C TInt LoadModels(TModelBankID aModelBankID);
   371 
   372 	/**
   373 	Plays the previously trained utterance.
   374 
   375 	@param  aModelBankID		
   376 	        The model bank ID.
   377 	@param  aModelID			
   378 	        The model ID, whose utterance is played.
   379 
   380 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   381 	        another of the system-wide error codes.
   382 
   383 	@since  8.0
   384     */
   385 	IMPORT_C TInt PlayUtterance(TModelBankID aModelBankID,
   386 					TModelID aModelID);
   387 
   388 	/**
   389 	Initiates recognition; performed following loading of model bank, lexicon, and grammar.
   390 
   391 	@param  aResultSet			
   392 	        A reference where the recognition result is set.
   393 
   394     @return An error code indicating if the function call was successful. KErrNone on success, otherwise
   395             another of the system-wide error codes.
   396 
   397 	@since  8.0
   398     */
   399 	IMPORT_C TInt Recognize(CSDClientResultSet& aResultSet);
   400 
   401 	/**
   402 	Records the user utterance for training and recognition.
   403 
   404 	@param  aRecordTime			
   405 	        The recording time in microseconds.
   406 
   407 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   408 	         another of the system-wide error codes.
   409 
   410 	@since  8.0
   411     */
   412 	IMPORT_C TInt Record(TTimeIntervalMicroSeconds32 aRecordTime);
   413 
   414 	/**
   415 	Removes the specified grammar from the permanent storage.
   416 
   417 	Removing a grammar will remove all rules within the grammar.
   418 
   419 	@param  aGrammarID			
   420 	        The grammar ID.
   421 
   422 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   423 	        another of the system-wide error codes.
   424 	
   425 	@since  8.0
   426     */
   427 	IMPORT_C TInt RemoveGrammar(TGrammarID aGrammarID);
   428 
   429 	/**
   430 	Removes the specified lexicon from the permanent storage.
   431 
   432 	Removing a lexicon will remove all pronunciations within the lexicon.
   433 
   434 	@param  aLexiconID			
   435 	        The lexicon ID.
   436 
   437 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   438 	        another of the system-wide error codes.
   439 	@since  8.0
   440     */
   441 	IMPORT_C TInt RemoveLexicon(TLexiconID aLexiconID);
   442 
   443 	/**
   444 	Removes the specified model bank from the permanent storage.
   445 
   446 	Removing a model bank will remove all models within the model bank.
   447 
   448 	@param  aModelBankID		
   449 	        The model bank ID.
   450 
   451 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   452 	        another of the system-wide error codes.
   453 
   454 	@since  8.0
   455     */
   456 	IMPORT_C TInt RemoveModelBank(TModelBankID aModelBankID);
   457 
   458 	/**
   459 	Removes the specified model from the specified model bank permanently.
   460 
   461 	@param  aModelBankID		
   462 	        The model bank ID.
   463 	@param  aModelID			
   464 	        The model ID.
   465 
   466 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   467 	        another of the system-wide error codes.
   468 
   469 	@since  8.0
   470     */
   471 	IMPORT_C TInt RemoveModel(TModelBankID aModelBankID,
   472 								TModelID aModelID);
   473 
   474 	/**
   475 	Removes the specified pronunciation from the specified lexicon permanently.
   476 
   477 	@param  aLexiconID
   478 	        The lexicon ID.
   479 	@param  aPronunciationID
   480 	        The pronunciation ID.
   481 
   482 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   483 	        another of the system-wide error codes.
   484 
   485 	@since	8.0
   486     */
   487 	IMPORT_C TInt RemovePronunciation(TLexiconID aLexiconID,
   488 								TPronunciationID aPronunciationID);
   489 
   490 	/**
   491 	Removes the specified rule from the specified grammar permanently.
   492 
   493 	@param  aGrammarID			
   494 	        The grammar ID.
   495 	@param  aRuleID				
   496 	        The rule ID.
   497 
   498 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   499 	        another of the system-wide error codes.
   500 
   501 	@since  8.0
   502     */
   503 	IMPORT_C TInt RemoveRule(TGrammarID aGrammarID, TRuleID aRuleID);
   504 
   505 	/**
   506 	Sets the client UID for client.
   507 
   508 	@param  aClientUid			
   509 	        The client UID.
   510 
   511 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   512 	        another of the system-wide error codes.
   513 
   514 	@since  8.0
   515 	*/
   516 	IMPORT_C TInt SetClientUid(TUid aClientUid);
   517 
   518 	/**
   519 	Starts a new recognition session.
   520 
   521 	@param  aMode				
   522 	        The recognition mode.
   523 
   524 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   525 	        another of the system-wide error codes.
   526 
   527 	@since  8.0
   528     */
   529 	IMPORT_C TInt StartRecSession(TRecognitionMode aMode);
   530 
   531     /**
   532 	Trains a new model into the specified model bank.
   533 
   534 	@param  aModelBankID		
   535 	        The model bank ID.
   536 	@param  aModelID			
   537 	        The reference to where a new model ID is assigned.
   538 
   539 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   540 	        another of the system-wide error codes.
   541 
   542 	@since  8.0
   543     */
   544 	IMPORT_C TInt Train(TModelBankID aModelBankID, TModelID& aModelID);
   545 
   546 	/**
   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.
   550 
   551 	@param  aGrammarID
   552 	        The grammar ID.
   553 	@param  aRuleID
   554 	        The rule ID.
   555 
   556 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   557 	        another of the system-wide error codes.
   558 
   559 	@since  8.0
   560     */
   561 	IMPORT_C TInt UnloadRule(TGrammarID aGrammarID, TRuleID aRuleID);
   562 
   563 	/**
   564 	Uploads the specified parameters into the engine.
   565 
   566 	@param  aParameterId		
   567 	        An array of parameter IDs.
   568 	@param  aParameterValue
   569 	        An array of parameter values.
   570 
   571 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   572 	        another of the system-wide error codes.
   573 
   574 	@since  8.0
   575     */
   576 	IMPORT_C TInt LoadEngineParameters(const RArray<TInt>& aParameterId,
   577 								const RArray<TInt>& aParameterValue);
   578 
   579 	/**
   580 	Gets an array of pronunciation IDs previously requested by GetAllPronunciationIDs.
   581 
   582 	@param  aPronunciationIDs
   583 	        An array to store pronunciation IDs.
   584 
   585     @since  8.0
   586     */
   587 	IMPORT_C void GetPronunciationIDArrayL(RArray<TPronunciationID>& aPronunciationIDs);
   588 
   589 	/**
   590 	Gets an array of rule IDs previously requested by GetAllRuleIDs.
   591 
   592 	@param  aRuleIDs
   593 	        An array to store rule IDs.
   594 
   595     @since  8.0
   596     */
   597 	IMPORT_C void GetRuleIDArrayL(RArray<TRuleID>& aRuleIDs);
   598 
   599 	/**
   600 	Gets an array of model IDs previously requested by GetAllModelIDs.
   601 
   602 	@param  aModelIDs
   603 	        An array to store model IDs.
   604 
   605     @since  8.0
   606     */
   607 	IMPORT_C void GetModelIDArrayL(RArray<TModelID>& aModelIDs);
   608 
   609 	/**
   610 	Gets an array of grammar IDs previously requested by GetAllGrammarIDs.
   611 
   612 	@param  aGrammarIDs
   613 	        An array to store grammar IDs.
   614 
   615     @since  8.0
   616     */
   617 	IMPORT_C void GetGrammarIDArrayL(RArray<TGrammarID>& aGrammarIDs);
   618 
   619 	/**
   620 	Gets an array of lexicon IDs previously requested by GetAllLexiconIDs.
   621 
   622 	@param  aLexiconIDs
   623 	        An array to store lexicon IDs.
   624 
   625 	@since  8.0
   626     */
   627 	IMPORT_C void GetLexiconIDArrayL(RArray<TLexiconID>& aLexiconIDs);
   628 
   629 
   630 	/**
   631 	Gets an array of modelBank IDs previously requested by GetAllModelBankIDs.
   632 
   633 	@param  aModelBankIDs
   634 	        An array to store modelBank IDs.
   635 
   636     @since  8.0
   637     */
   638 	IMPORT_C void GetModelBankIDArrayL(RArray<TModelBankID>& aModelBankIDs);
   639 
   640 
   641 	/**
   642 	Gets a client result set previously created by a call to Recognise().
   643 
   644 	@param  aResultSet
   645 	        The ResultSet used to contain the recognition results
   646 
   647     @since  8.0
   648     */
   649 	IMPORT_C void GetResultSetL(CSDClientResultSet& aResultSet);
   650 	
   651 private:
   652 	void DoGetEnginePropertiesL(const RArray<TInt>& aPropertyId, 
   653 					RArray<TInt>& aPropertyValue);
   654 	void DoLoadEngineParametersL(const RArray<TInt>& aParameterId, 
   655 								const RArray<TInt>& aParameterValue);
   656 
   657 					
   658 	CBufFlat* ExternalizeIntArrayL(const RArray<TInt>& aArray);
   659 	void InternalizeIntArrayL(TDes8& aDes, TInt aNumberElements, RArray<TInt>& aArray);
   660 	
   661 	void DoRecognizeL(CSDClientResultSet& aResultSet);
   662 private:
   663 	TAny* iReservedPtr_1;	// reserved for future expansion
   664 	TAny* iReservedPtr_2;	// reserved for future expansion
   665 };
   666 
   667 #endif  // __SPEECHRECOGNITIONCUSTOMCOMMANDS_H__