sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef __SPEECHRECOGNITIONCUSTOMCOMMANDS_H__ sl@0: #define __SPEECHRECOGNITIONCUSTOMCOMMANDS_H__ sl@0: sl@0: // INCLUDES sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: This is the main class of Speech Recognition Custom Commands. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: class RSpeechRecognitionCustomCommands : public RMMFCustomCommandsBase sl@0: { sl@0: public: sl@0: /** sl@0: Public C++ constructor for RSpeechRecognitionCustomCommands class. sl@0: sl@0: @param aController sl@0: A reference to a RMMFController object. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C RSpeechRecognitionCustomCommands(RMMFController& aController); sl@0: sl@0: /** sl@0: Adds a new pronunciation for the given model into the specified lexicon. sl@0: sl@0: @param aLexiconID sl@0: The lexicon ID to where the new pronunciation is added. sl@0: @param aModelBankID sl@0: The model bank ID. sl@0: @param aModelID sl@0: The model ID. sl@0: @param aPronunciationID sl@0: A reference to where a new pronunciation ID is assigned. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt AddPronunciation(TLexiconID aLexiconID, sl@0: TModelBankID aModelBankID, TModelID aModelID, sl@0: TPronunciationID& aPronunciationID); sl@0: sl@0: /** sl@0: Adds a new rule for the given pronunciation into the specified grammar. sl@0: sl@0: @param aGrammarID sl@0: The grammar ID to where the new rule is added. sl@0: @param aLexiconID sl@0: The lexicon ID. sl@0: @param aPronunciationID sl@0: The pronunciation ID. sl@0: @param aRuleID sl@0: A reference to where a new rule ID is assigned. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt AddRule(TGrammarID aGrammarID, TLexiconID aLexiconID, sl@0: TPronunciationID aPronunciationID, TRuleID& aRuleID); sl@0: sl@0: /** sl@0: Cancels the current operation. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C void Cancel(); sl@0: sl@0: /** sl@0: Commits the current train operation to the database. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt CommitChanges(); sl@0: sl@0: /** sl@0: Creates a new grammar. sl@0: sl@0: @param aGrammarID sl@0: A reference to where the grammar ID is stored. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt CreateGrammar(TGrammarID& aGrammarID); sl@0: sl@0: /** sl@0: Creates a new lexicon. sl@0: sl@0: @param aLexiconID sl@0: A reference where lexicon ID is stored. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt CreateLexicon(TLexiconID& aLexiconID); sl@0: sl@0: /** sl@0: Creates a new model bank. sl@0: sl@0: @param aModelBankID sl@0: A reference to where a new model bank ID is assigned. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt CreateModelBank(TModelBankID& aModelBankID); sl@0: sl@0: /** sl@0: Ends the current recognition session. sl@0: sl@0: The resources allocated for recognition are freed. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt EndRecSession(); sl@0: sl@0: /** sl@0: Returns all grammar IDs owned by the client. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt GetAllClientGrammarIDs(); sl@0: sl@0: /** sl@0: Returns all lexicon IDs owned by the client. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt GetAllClientLexiconIDs(); sl@0: sl@0: /** sl@0: Returns all modelBank IDs owned by the client. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt GetAllClientModelBankIDs(); sl@0: sl@0: /** sl@0: Returns all grammar IDs owned by the client. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt GetAllGrammarIDs(); sl@0: sl@0: /** sl@0: Returns all lexicon IDs owned by the client. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt GetAllLexiconIDs(); sl@0: sl@0: sl@0: /** sl@0: Returns all modelBank IDs owned by the client. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt GetAllModelBankIDs(); sl@0: sl@0: /** sl@0: Returns all model IDs that exist in the specified model bank. sl@0: sl@0: @param aModelBankID sl@0: The model bank ID. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt GetAllModelIDs(TModelBankID aModelBankID); sl@0: sl@0: /** sl@0: Returns all pronunciation IDs that exist in the specified lexicon. sl@0: sl@0: @param aLexiconID sl@0: The lexicon ID. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt GetAllPronunciationIDs(TLexiconID aLexiconID); sl@0: sl@0: /** sl@0: Returns all rule IDs that exist in the specified grammar. sl@0: sl@0: @param aGrammarID sl@0: The grammar ID. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt GetAllRuleIDs(TGrammarID aGrammarID); sl@0: sl@0: /** sl@0: Returns the number of models available for training system wide, sl@0: based on available disk space. sl@0: sl@0: @param aAvailableStorage sl@0: The number of models that can be held in available storage space. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt GetAvailableStorage(TInt& aAvailableStorage); sl@0: sl@0: /** sl@0: Returns the engine properties specified by the engine property sl@0: ID array. On return aPropertyValue contains an array of engine sl@0: properties. sl@0: sl@0: @param aPropertyId sl@0: A constant reference to an array of engine property IDs. sl@0: @param aPropertyValue sl@0: A reference to an array of engine property values. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt GetEngineProperties(const RArray& aPropertyId, sl@0: RArray& aPropertyValue); sl@0: sl@0: /** sl@0: Returns the number of models in the specified model bank. sl@0: sl@0: @param aModelBankID sl@0: The model bank ID. sl@0: @param aModelCount sl@0: The reference where the number of models is set. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt GetModelCount(TModelBankID aModelBankID, sl@0: TInt& aModelCount); sl@0: sl@0: sl@0: /** sl@0: Checks if the rule is valid or not. sl@0: sl@0: @param aGrammarID sl@0: The grammar ID. sl@0: @param aRuleID sl@0: The rule ID. sl@0: @param aValid sl@0: A reference where the validity of the rule is set. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt GetRuleValidity(TGrammarID aGrammarID, TRuleID aRuleID, sl@0: TBool& aValid); sl@0: sl@0: /** sl@0: * sl@0: * Returns the duration of the utterance for the specified model. sl@0: * @since 8.0 sl@0: * @param aModelBankID model bank Id sl@0: * @param aModelID model Id sl@0: * @param aDuration reference where the duration of sl@0: * utterance is set sl@0: * @return System-wide errors sl@0: */ sl@0: IMPORT_C TInt GetUtteranceDuration(TModelBankID aModelBankID, sl@0: TModelID aModelID, TTimeIntervalMicroSeconds32& aDuration); sl@0: sl@0: /** sl@0: Loads the specified grammar into the recognizer; done prior to recognition. sl@0: sl@0: @param aGrammarID sl@0: The grammar ID. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt LoadGrammar(TGrammarID aGrammarID); sl@0: sl@0: /** sl@0: Loads the specified lexicon into the recognizer; done prior to recognition. sl@0: sl@0: @param aLexiconID sl@0: The lexicon ID. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt LoadLexicon(TLexiconID aLexiconID); sl@0: sl@0: /** sl@0: Loads the specified model bank into the recognizer; done prior to recognition. sl@0: sl@0: @param aModelBankID sl@0: The model bank ID. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt LoadModels(TModelBankID aModelBankID); sl@0: sl@0: /** sl@0: Plays the previously trained utterance. sl@0: sl@0: @param aModelBankID sl@0: The model bank ID. sl@0: @param aModelID sl@0: The model ID, whose utterance is played. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt PlayUtterance(TModelBankID aModelBankID, sl@0: TModelID aModelID); sl@0: sl@0: /** sl@0: Initiates recognition; performed following loading of model bank, lexicon, and grammar. sl@0: sl@0: @param aResultSet sl@0: A reference where the recognition result is set. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt Recognize(CSDClientResultSet& aResultSet); sl@0: sl@0: /** sl@0: Records the user utterance for training and recognition. sl@0: sl@0: @param aRecordTime sl@0: The recording time in microseconds. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt Record(TTimeIntervalMicroSeconds32 aRecordTime); sl@0: sl@0: /** sl@0: Removes the specified grammar from the permanent storage. sl@0: sl@0: Removing a grammar will remove all rules within the grammar. sl@0: sl@0: @param aGrammarID sl@0: The grammar ID. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt RemoveGrammar(TGrammarID aGrammarID); sl@0: sl@0: /** sl@0: Removes the specified lexicon from the permanent storage. sl@0: sl@0: Removing a lexicon will remove all pronunciations within the lexicon. sl@0: sl@0: @param aLexiconID sl@0: The lexicon ID. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt RemoveLexicon(TLexiconID aLexiconID); sl@0: sl@0: /** sl@0: Removes the specified model bank from the permanent storage. sl@0: sl@0: Removing a model bank will remove all models within the model bank. sl@0: sl@0: @param aModelBankID sl@0: The model bank ID. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt RemoveModelBank(TModelBankID aModelBankID); sl@0: sl@0: /** sl@0: Removes the specified model from the specified model bank permanently. sl@0: sl@0: @param aModelBankID sl@0: The model bank ID. sl@0: @param aModelID sl@0: The model ID. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt RemoveModel(TModelBankID aModelBankID, sl@0: TModelID aModelID); sl@0: sl@0: /** sl@0: Removes the specified pronunciation from the specified lexicon permanently. sl@0: sl@0: @param aLexiconID sl@0: The lexicon ID. sl@0: @param aPronunciationID sl@0: The pronunciation ID. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt RemovePronunciation(TLexiconID aLexiconID, sl@0: TPronunciationID aPronunciationID); sl@0: sl@0: /** sl@0: Removes the specified rule from the specified grammar permanently. sl@0: sl@0: @param aGrammarID sl@0: The grammar ID. sl@0: @param aRuleID sl@0: The rule ID. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt RemoveRule(TGrammarID aGrammarID, TRuleID aRuleID); sl@0: sl@0: /** sl@0: Sets the client UID for client. sl@0: sl@0: @param aClientUid sl@0: The client UID. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt SetClientUid(TUid aClientUid); sl@0: sl@0: /** sl@0: Starts a new recognition session. sl@0: sl@0: @param aMode sl@0: The recognition mode. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt StartRecSession(TRecognitionMode aMode); sl@0: sl@0: /** sl@0: Trains a new model into the specified model bank. sl@0: sl@0: @param aModelBankID sl@0: The model bank ID. sl@0: @param aModelID sl@0: The reference to where a new model ID is assigned. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt Train(TModelBankID aModelBankID, TModelID& aModelID); sl@0: sl@0: /** sl@0: Unloads the specified rule from the specified grammar in temporary sl@0: memory, previously loaded with LoadGrammarL(). The rule in the sl@0: permanent storage remains intact. sl@0: sl@0: @param aGrammarID sl@0: The grammar ID. sl@0: @param aRuleID sl@0: The rule ID. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt UnloadRule(TGrammarID aGrammarID, TRuleID aRuleID); sl@0: sl@0: /** sl@0: Uploads the specified parameters into the engine. sl@0: sl@0: @param aParameterId sl@0: An array of parameter IDs. sl@0: @param aParameterValue sl@0: An array of parameter values. sl@0: sl@0: @return An error code indicating if the function call was successful. KErrNone on success, otherwise sl@0: another of the system-wide error codes. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C TInt LoadEngineParameters(const RArray& aParameterId, sl@0: const RArray& aParameterValue); sl@0: sl@0: /** sl@0: Gets an array of pronunciation IDs previously requested by GetAllPronunciationIDs. sl@0: sl@0: @param aPronunciationIDs sl@0: An array to store pronunciation IDs. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C void GetPronunciationIDArrayL(RArray& aPronunciationIDs); sl@0: sl@0: /** sl@0: Gets an array of rule IDs previously requested by GetAllRuleIDs. sl@0: sl@0: @param aRuleIDs sl@0: An array to store rule IDs. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C void GetRuleIDArrayL(RArray& aRuleIDs); sl@0: sl@0: /** sl@0: Gets an array of model IDs previously requested by GetAllModelIDs. sl@0: sl@0: @param aModelIDs sl@0: An array to store model IDs. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C void GetModelIDArrayL(RArray& aModelIDs); sl@0: sl@0: /** sl@0: Gets an array of grammar IDs previously requested by GetAllGrammarIDs. sl@0: sl@0: @param aGrammarIDs sl@0: An array to store grammar IDs. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C void GetGrammarIDArrayL(RArray& aGrammarIDs); sl@0: sl@0: /** sl@0: Gets an array of lexicon IDs previously requested by GetAllLexiconIDs. sl@0: sl@0: @param aLexiconIDs sl@0: An array to store lexicon IDs. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C void GetLexiconIDArrayL(RArray& aLexiconIDs); sl@0: sl@0: sl@0: /** sl@0: Gets an array of modelBank IDs previously requested by GetAllModelBankIDs. sl@0: sl@0: @param aModelBankIDs sl@0: An array to store modelBank IDs. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C void GetModelBankIDArrayL(RArray& aModelBankIDs); sl@0: sl@0: sl@0: /** sl@0: Gets a client result set previously created by a call to Recognise(). sl@0: sl@0: @param aResultSet sl@0: The ResultSet used to contain the recognition results sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C void GetResultSetL(CSDClientResultSet& aResultSet); sl@0: sl@0: private: sl@0: void DoGetEnginePropertiesL(const RArray& aPropertyId, sl@0: RArray& aPropertyValue); sl@0: void DoLoadEngineParametersL(const RArray& aParameterId, sl@0: const RArray& aParameterValue); sl@0: sl@0: sl@0: CBufFlat* ExternalizeIntArrayL(const RArray& aArray); sl@0: void InternalizeIntArrayL(TDes8& aDes, TInt aNumberElements, RArray& aArray); sl@0: sl@0: void DoRecognizeL(CSDClientResultSet& aResultSet); sl@0: private: sl@0: TAny* iReservedPtr_1; // reserved for future expansion sl@0: TAny* iReservedPtr_2; // reserved for future expansion sl@0: }; sl@0: sl@0: #endif // __SPEECHRECOGNITIONCUSTOMCOMMANDS_H__