speechsrv_plat/nss_srs_custom_commands_api/inc/nsssispeechrecognitioncustomcommandimplementor.h
branchRCL_3
changeset 19 e36f3802f733
parent 0 bf1d17376201
equal deleted inserted replaced
18:cad71a31b7fc 19:e36f3802f733
       
     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 definition of the server side for the
       
    15 *			    speaker independent controller.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef NSSSISPEECHRECOGNITIONCUSTOMCOMMANDIMPLEMENTOR_H
       
    22 #define NSSSISPEECHRECOGNITIONCUSTOMCOMMANDIMPLEMENTOR_H
       
    23 
       
    24 // INCLUDES
       
    25 
       
    26 #include <nsssispeechrecognitiondataclient.h>
       
    27 #include <nsssispeechrecognitiondatacommon.h>
       
    28 
       
    29 // CLASS DECLARATION
       
    30 
       
    31 /**
       
    32 *  This is the main class of Speaker Independent Custom Commands Implementor
       
    33 *
       
    34 *  @lib NssSiSpeechRecognitionCustomCommands.lib
       
    35 *  @since 2.8
       
    36 */
       
    37 
       
    38 class MSISpeechRecognitionCustomCommandImplementor
       
    39 {
       
    40 
       
    41 public:
       
    42 
       
    43 		/**
       
    44 		*	Adapts speaker independent models according using a correct recognition result.
       
    45         * 
       
    46         * @since	2.8
       
    47         * @param	aResultSet          The result N-Best containing feature vectors
       
    48 		*			aCorrect            The correct index
       
    49 		*/
       
    50         virtual void MSrAdaptL(CSIClientResultSet& aResultSet, TInt aCorrect) = 0;
       
    51 
       
    52 		/**
       
    53 		*	Adds a pronunciation to the given lexicon.
       
    54         * 
       
    55         * @since	2.8
       
    56 		* @param	aLexiconID			The lexicon Id
       
    57         * @param    aTrainText          Text to be pronounced
       
    58         * @param    aLanguage           Pronunciation language
       
    59 		* @param	aPronunciationID	Reference where a new pronunciation Id is assigned to.
       
    60 		*/
       
    61         virtual void MSrAddPronunciationL(TSILexiconID aLexiconID,
       
    62                                           const TDesC& aTrainText,
       
    63                                           TLanguage aLanguage,
       
    64                                           TSIPronunciationID& aPronunciationID) = 0;
       
    65 
       
    66 		/**
       
    67         *	Adds a rule variant to a grammar.
       
    68         * 
       
    69         * @since 2.8
       
    70         * @param 	aGrammarID          Grammar identifier
       
    71         * @param    aRuleID             Rule identifier; variant is added here.
       
    72         * @param    aPronunciations     Sequence of pronunciations; these get concatenated.
       
    73         *                               in the rule variant.
       
    74         * @param    aRuleVariantID      Reference where the new variant
       
    75         *                               identifier is assigned to.
       
    76 		*/
       
    77 		virtual void MSrAddRuleVariantL(
       
    78             TSIGrammarID aGrammarID,
       
    79             TSILexiconID aLexiconID,
       
    80             RArray<TSIPronunciationID>& aPronunciationIDs,
       
    81             TSIRuleID aRuleID,
       
    82             TSIRuleVariantID& aRuleVariantID ) = 0;
       
    83 
       
    84         /**
       
    85 		*	Trains a voice tag. Adds the text to the lexicon, and creates the required
       
    86         *   rules and rule variants.
       
    87         * 
       
    88         * @since 2.8
       
    89         * @param	aTrainArray         The phrase to be trained, split into subwords
       
    90         * @param	aLanguageArray      The pronunciaiton languages
       
    91         * @param	aLexiconID          Lexicon identifier
       
    92         * @param	aGrammarID          Grammar identifier
       
    93         * @param	aRuleID             Reference, where the new rule identifier is assigned to.
       
    94         */
       
    95         virtual void MSrAddVoiceTagL(
       
    96             MDesCArray& aTrainArray,
       
    97             RArray<TLanguage>& aLanguageArray,
       
    98             TSILexiconID aLexiconID,
       
    99             TSIGrammarID aGrammarID,
       
   100             TSIRuleID& aRuleID) = 0;
       
   101 
       
   102         /**
       
   103 		*	Trains voice tags. If the training fails for some of the names (but not all),
       
   104         *   it is signaled by setting the Rule ID to KInvalidRuleID.
       
   105         * 
       
   106         * @since 2.8
       
   107         * @param	aTrainArray         The phrase to be trained, split into subwords
       
   108         * @param	aLanguageArray      The pronunciation languages
       
   109         * @param	aLexiconID          Lexicon identifier
       
   110         * @param	aGrammarID          Grammar identifier
       
   111         * @param	aRuleID             Referenceto an array, where the new
       
   112         *                               Rule identifiers are assigned to.
       
   113         */
       
   114         virtual void MSrAddVoiceTagsL(
       
   115             RPointerArray<MDesCArray>* aTrainArray,
       
   116             RArray<TLanguage>& aLanguageArray,
       
   117             TSILexiconID aLexiconID,
       
   118             TSIGrammarID aGrammarID,
       
   119             RArray<TSIRuleID>& aRuleID) = 0;
       
   120 
       
   121         /**
       
   122         *	Creates a new rule.
       
   123         * 
       
   124         * @since 2.8
       
   125         * @param 	aGrammarID          Grammar identifier
       
   126         * @param 	aRuleID             Reference where rule ID is stored
       
   127         */
       
   128         virtual void MSrCreateRuleL(TSIGrammarID aGrammarID, TSIRuleID& aRuleID) = 0;
       
   129 
       
   130 		/**
       
   131         *   Starts recognition
       
   132         *
       
   133         * @since 2.8
       
   134         * @param 	aResultSet          Recognition result is placed here, when ready.
       
   135         */
       
   136 		virtual void MSrRecognizeL( CSIClientResultSet& aResultSet ) = 0;
       
   137 
       
   138         /**
       
   139 		*	Stops recognition. Unlike Cancel(), this function gives
       
   140         *   the recognition result, if it can be guessed.
       
   141         *
       
   142         * @since	2.8
       
   143         */
       
   144 		virtual void MSrEndRecordL() = 0;
       
   145 
       
   146 		/**
       
   147 		*   Deactivates a grammar.
       
   148 		*
       
   149         * @since	2.8
       
   150         * @param	aGrammarID          Grammar identifier
       
   151         */
       
   152         virtual void MSrUnloadGrammarL( TSIGrammarID aGrammarID ) = 0;
       
   153 
       
   154         /**
       
   155 		* Trains one SINDE voice tag. Adds the text to the lexicon, and 
       
   156         * creates the required rules and rule variants.
       
   157         * 
       
   158         * @since 3.1
       
   159         * @param aTrainArray The phrase to be trained, split into subwords
       
   160         * @param aLanguageArray The pronunciation languages for each of the 
       
   161         * @param aLexiconID Lexicon identifier
       
   162         * @param aGrammarID Grammar identifier
       
   163         * @param aRuleID Reference, where the new rule identifier is assigned to.
       
   164         */
       
   165         virtual void MSrAddSindeVoiceTagL( MDesCArray& aTrainArray,
       
   166                                            RArray<RLanguageArray>& aLanguageArray,
       
   167                                            TSILexiconID aLexiconID,
       
   168                                            TSIGrammarID aGrammarID,
       
   169                                            TSIRuleID& aRuleID ) = 0;
       
   170 
       
   171         /**
       
   172 		* Trains SINDE voice tags. If the training fails for some of the names
       
   173         * (but not all), it is signaled by setting the Rule ID to KInvalidRuleID.
       
   174         * 
       
   175         * @since 3.1
       
   176         * @param aTrainArray The phrase to be trained, split into subwords
       
   177         * @param aLanguageArray The pronunciation languages
       
   178         * @param aLexiconID Lexicon identifier
       
   179         * @param aGrammarID Grammar identifier
       
   180         * @param aRuleID Referenceto an array, where the new
       
   181         *                rule identifiers are assigned to.
       
   182         */
       
   183         virtual void MSrAddSindeVoiceTagsL( RPointerArray<MDesCArray>* aTrainArray,
       
   184                                             RArray<RLanguageArray>& aLanguageArray,
       
   185                                             TSILexiconID aLexiconID,
       
   186                                             TSIGrammarID aGrammarID,
       
   187                                             RArray<TSIRuleID>& aRuleID ) = 0;
       
   188 
       
   189 /***************************** SD Legacy functions ***********************/
       
   190 
       
   191 		/**
       
   192 		*	Adds a new rule for the given pronunciation into the specified 
       
   193 		*	grammar.
       
   194         * @since	2.0
       
   195         * @param	aGrammarID			grammar Id, where the new rule is 
       
   196 		*								added to
       
   197 		* @param	aLexiconID			lexicon Id
       
   198 		* @param	aPronunciationID	pronunciation Id
       
   199 		* @param	aRuleID				reference where a new rule Id is 
       
   200 		*								assigned to
       
   201 		*/
       
   202 		virtual void MSrAddRuleL( TSIGrammarID aGrammarID, TSILexiconID aLexiconID,
       
   203 						TSIPronunciationID aPronunciationID, 
       
   204 						TSIRuleID& aRuleID ) = 0;
       
   205 
       
   206 		/**
       
   207         * 
       
   208         *	Cancels the current operation
       
   209         * @since 2.0
       
   210 		*/
       
   211 		virtual void MSrCancel() = 0;
       
   212 
       
   213         /**
       
   214 		*	Saves the current changes into a permanent storage.
       
   215         * @since 2.0
       
   216         */
       
   217 		virtual void MSrCommitChangesL() = 0;
       
   218 
       
   219 		/**
       
   220         * 
       
   221         *	Creates a new grammar.
       
   222         * @since 2.0
       
   223         * @param 	aGrammarID			reference where grammar ID is stored
       
   224         */
       
   225 		virtual void MSrCreateGrammarL( TSIGrammarID& aGrammarID ) = 0;
       
   226 
       
   227 		/**
       
   228         * 
       
   229         *	Creates a new lexicon.
       
   230         * @since 2.0
       
   231         * @param 	aLexiconID			reference where lexicon ID is stored
       
   232         */
       
   233 		virtual void MSrCreateLexiconL( TSILexiconID& aLexiconID ) = 0;
       
   234 
       
   235         /**
       
   236 		*	Creates a new model bank.
       
   237         * @since	2.0
       
   238         * @param	aModelBankID		reference where a new model bank Id 
       
   239 		*								is assigned to
       
   240         */
       
   241 		virtual void MSrCreateModelBankL( TSIModelBankID& aModelBankID ) = 0;
       
   242 
       
   243 		/**
       
   244 		*	Ends the current recognition session. Resources allocated 
       
   245 		*	for recognition are freed.
       
   246         * @since	2.0
       
   247         * @param	aModelBankID		reference where a new model bank
       
   248 		*								Id is assigned to
       
   249         */
       
   250 		virtual void MSrEndRecSessionL() = 0;
       
   251 
       
   252 		/**
       
   253         *	Returns all grammar Ids that belong to the current client, 
       
   254 		*	whose UID was set with MSrSetClientUid().
       
   255         * @since 2.0
       
   256 		* @param	aGrammarIDs			reference where grammar Ids are stored
       
   257         */
       
   258 		virtual void MSrGetAllClientGrammarIDsL( 
       
   259 						RArray<TSIGrammarID>& aGrammarIDs ) = 0;
       
   260 
       
   261 		/**
       
   262  		*	Returns all lexicon Ids that belong to the current client,
       
   263 		*	whose UID was set with MSrSetClientUid().
       
   264         * @since 2.0
       
   265 		* @param	aLexiconIDs			reference where lexicon Ids are stored
       
   266         */
       
   267 		virtual void MSrGetAllClientLexiconIDsL( 
       
   268 						RArray<TSILexiconID>& aLexiconIDs ) = 0;
       
   269 
       
   270 		/**
       
   271         *	Returns all model bank Ids that belong to the current client, 
       
   272 		*	whose UID was set with MSrSetClientUid().
       
   273         * @since 2.0
       
   274 		* @param	aModelBankIDs		reference where model bank Ids are stored
       
   275         */
       
   276 		virtual void MSrGetAllClientModelBankIDsL( 
       
   277 						RArray<TSIModelBankID>& aModelBankIDs ) = 0;
       
   278 
       
   279 		/**
       
   280 		*	Returns all grammar Ids that exist (for all clients).
       
   281         * @since 2.0
       
   282 		* @param	aGrammarIDs			reference where grammar Ids are stored
       
   283         */
       
   284 		virtual void MSrGetAllGrammarIDsL( 
       
   285 						RArray<TSIGrammarID>& aGrammarIDs ) = 0;
       
   286 
       
   287 		/**
       
   288 		*	Returns all lexicon Ids that exist (for all clients).
       
   289         * @since 2.0
       
   290 		* @param	aLexiconIDs			reference where lexicon Ids are stored
       
   291         */
       
   292 		virtual void MSrGetAllLexiconIDsL( 
       
   293 						RArray<TSILexiconID>& aLexiconIDs ) = 0;
       
   294 
       
   295 		/**
       
   296  		*	Returns all model bank Ids that exist (for all clients).
       
   297         * @since 2.0
       
   298 		* @param	aModelBankIDs		reference where model bank Ids are stored
       
   299         */
       
   300 		virtual void MSrGetAllModelBankIDsL( 
       
   301 						RArray<TSIModelBankID>& aModelBankIDs ) = 0;
       
   302 
       
   303 		/**
       
   304 		*	Returns all pronunciation Ids that exist in the specified lexicon.
       
   305         * @since	2.0
       
   306         * @param	aLexiconID			lexicon Id
       
   307 		*			aPronunciationIDs	reference where pronunciation Ids 
       
   308 		*			are stored
       
   309         */
       
   310 		virtual void MSrGetAllPronunciationIDsL( TSILexiconID aLexiconID, 
       
   311 						RArray<TSIPronunciationID>& aPronunciationIDs ) = 0;
       
   312 
       
   313 		/**
       
   314 		*	Returns all rule Ids that exist in the specified grammar.
       
   315         * @since	2.0
       
   316         * @param	aGrammarID			grammar Id
       
   317 		*			aRuleIDs			reference where rule Ids are stored
       
   318         */
       
   319 		virtual void MSrGetAllRuleIDsL( TSIGrammarID aGrammarID, 
       
   320 						RArray<TSIRuleID>& aRuleIDs ) = 0;
       
   321 
       
   322 		/**
       
   323         * 
       
   324         *	Returns the engine properties specified by the engine property 
       
   325 		*	ID array. On return aPropertyValue contains an array of engine 
       
   326 		*	properties.
       
   327         * @since 2.0
       
   328         * @param 	aPropertyId		constant reference to array of engine 
       
   329 		*							property Ids
       
   330 		* @param	aPropertyValue	reference to array of engine property 
       
   331 		*							values
       
   332         */
       
   333 		virtual void MSrGetEnginePropertiesL( const RArray<TInt>& aPropertyId, 
       
   334 						RArray<TInt>& aPropertyValue ) = 0;
       
   335 		
       
   336 		/**
       
   337 		*	Checks if the rule is valid or not.
       
   338         * @since	2.0
       
   339         * @param	aGrammarID			grammar Id
       
   340 		*			aRuleID				rule Id
       
   341 		*			aValid				reference where the validity of the 
       
   342 		*								rule is set
       
   343         */
       
   344 		virtual void MSrGetRuleValidityL( TSIGrammarID aGrammarID, 
       
   345 						TSIRuleID aRuleID, TBool& aValid ) = 0;
       
   346 
       
   347 		/**
       
   348 		*	Loads the specified grammar into the reocgnizer;
       
   349         *   done prior to recognition.
       
   350         * @since	2.0
       
   351         * @param	aGrammarID			grammar Id
       
   352         */
       
   353 		virtual void MSrLoadGrammarL( TSIGrammarID aGrammarID ) = 0;
       
   354 
       
   355 		/**
       
   356 		*	Activates the specified grammar,
       
   357         *   which has been previously deactivated.
       
   358         *
       
   359         * @since	2.8
       
   360         * @param	aGrammarID			grammar Id
       
   361         */
       
   362 		virtual void MSrActivateGrammarL( TSIGrammarID aGrammarID ) = 0;
       
   363 
       
   364 		/**
       
   365 		*	Deactivates a loaded grammar so that it is not recognized.
       
   366         *
       
   367         * @since	2.8
       
   368         * @param	aGrammarID			grammar Id
       
   369         */
       
   370 		virtual void MSrDeactivateGrammarL( TSIGrammarID aGrammarID ) = 0;
       
   371 
       
   372         /**
       
   373         * 
       
   374         *	Loads the specified lexicon into the recognizer; 
       
   375 		*	done prior to recognition.
       
   376         * @since 2.0
       
   377         * @param 	aLexiconID			lexicon ID
       
   378         */
       
   379 		virtual void MSrLoadLexiconL( TSILexiconID aLexiconID ) = 0;
       
   380 
       
   381 		/**
       
   382         * 
       
   383         *	Loads the specified model bank into the recognizer; 
       
   384 		*	done prior to recognition..
       
   385         * @since 2.0
       
   386         * @param 	ModelBankID			model bank Id
       
   387         */
       
   388 		virtual void MSrLoadModelsL( TSIModelBankID aModelBankID ) = 0;
       
   389 
       
   390 		/**
       
   391 		*	Records an utterance for training and recognition.
       
   392         * @since	2.0
       
   393         * @param	aRecordTime			recording time in microseconds
       
   394         */
       
   395 		virtual void MSrRecordL( TTimeIntervalMicroSeconds32 aRecordTime ) = 0;
       
   396 
       
   397         /**
       
   398         * Pre-starts sampling before MSrRecordL call.
       
   399         *
       
   400         * @since 3.2
       
   401         */
       
   402         virtual void MSrPreStartSamplingL() = 0;
       
   403 
       
   404 		/**
       
   405 		*	Removes the specified grammar from the permanent storage.
       
   406 		*	Removing a grammar will remove all rules and rule variants
       
   407         *   within the grammar.
       
   408         * @since	2.0
       
   409         * @param	aGrammarID			grammar Id
       
   410         */
       
   411 		virtual void MSrRemoveGrammarL( TSIGrammarID aGrammarID ) = 0;
       
   412 
       
   413 		/**
       
   414 		*	Removes the specified lexicon from the permanent storage.
       
   415 		*	Removing a lexicon will remove all pronunciations within the 
       
   416 		*	lexicon.
       
   417         * @since	2.0
       
   418         * @param	aLexiconID			lexicon Id
       
   419         */
       
   420 		virtual void MSrRemoveLexiconL( TSILexiconID aLexiconID ) = 0;
       
   421 
       
   422 		/**
       
   423 		*	Removes the specified model bank from the permanent storage.
       
   424 		*	Removing a model bank will remove all models within the model bank.
       
   425         * @since	2.0
       
   426         * @param	aModelBankID		model bank Id
       
   427         */
       
   428 		virtual void MSrRemoveModelBankL( TSIModelBankID aModelBankID ) = 0;
       
   429 
       
   430 		/**
       
   431 		*	Removes the specified model from the specified model bank 
       
   432 		*	permanently.
       
   433         * @since	2.0
       
   434         * @param	aModelBankID		model bank Id
       
   435 		* @param	aModelID			model Id
       
   436         */
       
   437 		virtual void MSrRemoveModelL( TSIModelBankID aModelBankID, 
       
   438 						TSIModelID aModelID ) = 0;
       
   439 
       
   440 		/**
       
   441 		*	Removes the specified pronunciation from the specified lexicon 
       
   442 		*	permanently.
       
   443         * @since	2.0
       
   444         * @param	aLexiconID			lexicon Id
       
   445 		* @param	aPronunciationID	pronunciation Id
       
   446         */
       
   447 		virtual void MSrRemovePronunciationL( TSILexiconID aLexiconID, 
       
   448 						TSIPronunciationID aPronunciationID ) = 0;
       
   449 
       
   450 		/**
       
   451 		*	Removes the specified rule from the specified grammar permanently.
       
   452         *   If the rule contains rule variants, they are also destoryed.
       
   453         * @since	2.0
       
   454         * @param	aGrammarID			grammar Id
       
   455 		* @param	aRuleID				rule Id
       
   456         */
       
   457 		virtual void MSrRemoveRuleL( TSIGrammarID aGrammarID, 
       
   458 						TSIRuleID aRuleID ) = 0;
       
   459 
       
   460 		/**
       
   461 		*	Removes the specified rules from the specified grammar permanently.
       
   462         *   If the rule contains rule variants, they are also destoryed.
       
   463         * @since	2.0
       
   464         * @param	aGrammarID			grammar Id
       
   465 		* @param	aRuleIDs			array of rule ids
       
   466         */
       
   467 		virtual void MSrRemoveRulesL( TSIGrammarID aGrammarID, 
       
   468 						RArray<TSIRuleID>& aRuleIDs ) = 0;
       
   469 
       
   470 		/**
       
   471         *	Sets the client's UID for data ownership identification.
       
   472         * @since 2.0
       
   473         * @param	aClientUid			client's UID
       
   474         */
       
   475 		virtual void MSrSetClientUid( TUid aClientUid ) = 0;
       
   476 
       
   477 		/**
       
   478 		*	Starts a new recognition session.
       
   479         * @since	2.0
       
   480         * @param	aMode				recognition mode
       
   481         */
       
   482 		virtual void MSrStartRecSessionL( TNSSRecognitionMode aMode ) = 0;
       
   483 
       
   484 		/**
       
   485 		*	Unloads the specified rule from the specified grammar in temporary 
       
   486 		*	memory, previously loaded with LoadGrammarL.  The rule in the 
       
   487 		*	permanent storage remains intact.
       
   488         * @since	2.0
       
   489         * @param	aGrammarID			grammar Id
       
   490 		* @param	aRuleID				rule Id
       
   491         */
       
   492 		virtual void MSrUnloadRuleL( TSIGrammarID aGrammarID, 
       
   493 						TSIRuleID aRuleID ) = 0;
       
   494 
       
   495 		/**
       
   496 		*	Unloads the specified parameters to the engine.
       
   497         * @since	2.0
       
   498         * @param	aParameterId		array of parameter IDs
       
   499 		* @param	aParameterValue		array of parameter values
       
   500         */
       
   501 		virtual void MSrLoadEngineParametersL( 
       
   502 						const RArray<TInt>& aParameterId, 
       
   503 						const RArray<TInt>& aParameterValue ) = 0;
       
   504 
       
   505 private:
       
   506 		TAny* iReservedPtr_1;	// reserved for future expansion
       
   507 		TAny* iReservedPtr_2;	// reserved for future expansion
       
   508 
       
   509 };
       
   510 
       
   511 #endif  // NSSSISPEECHRECOGNITIONCUSTOMCOMMANDIMPLEMENTOR_H