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 __SPEECHRECOGNITIONUTILITY_H__ sl@0: #define __SPEECHRECOGNITIONUTILITY_H__ sl@0: sl@0: // INCLUDES sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: sl@0: // CLASS DECLARATION sl@0: sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: This is the main class of Speech Recognition Utility. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: class CSpeechRecognitionUtility : public CBase sl@0: { sl@0: class CBody; sl@0: public: sl@0: sl@0: /** sl@0: Factory function for creating this class. sl@0: sl@0: @param aClientUid sl@0: The UID of the client. sl@0: @param aSpeechRecognitionUtilityObserver sl@0: A reference to the event observer class. sl@0: sl@0: @return A pointer to CSpeechRecognitionUtility object sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C static CSpeechRecognitionUtility* NewL( sl@0: MSpeechRecognitionUtilityObserver& sl@0: aSpeechRecognitionUtilityObserver, TUid aClientUid ); sl@0: sl@0: /** sl@0: Factory function for creating this class. Leaves a pointer on the cleanup stack. sl@0: sl@0: @param aSpeechRecognitionUtilityObserver sl@0: A reference to the event observer class. sl@0: @param aClientUid sl@0: A client UID for data ownership. sl@0: sl@0: @return A pointer to a CSpeechRecognitionUtility object. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C static CSpeechRecognitionUtility* NewLC( sl@0: MSpeechRecognitionUtilityObserver& sl@0: aSpeechRecognitionUtilityObserver, TUid aClientUid ); sl@0: sl@0: /** sl@0: Destructor. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C ~CSpeechRecognitionUtility(); 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 ID's. 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: Adds a new pronunciation for the given model into the sl@0: specified lexicon. sl@0: sl@0: @param aLexiconID sl@0: The lexicon ID, where the new pronunciation is added to. 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 where the new pronunciation ID is assigned to. 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 sl@0: specified grammar. sl@0: sl@0: @param aGrammarID sl@0: The grammar ID, where the new rule is added to. 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 where the new rule ID is assigned to. 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: Commit 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 where 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: Loads the specified model bank into the recognizer; sl@0: 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: Loads the specified grammar into the recognizer; sl@0: 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; sl@0: 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: Returns the duration of the utterance for the specified model. sl@0: sl@0: @param aModelBankID sl@0: The model bank ID. sl@0: @param aModelID sl@0: The model ID. sl@0: @param aDuration sl@0: The reference where the duration of utterance 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 GetUtteranceDuration( TModelBankID aModelBankID, sl@0: TModelID aModelID, sl@0: TTimeIntervalMicroSeconds32& aDuration); 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: 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, TInt& aModelCount ); sl@0: sl@0: /** sl@0: Ends the current recognition session. Resources allocated sl@0: 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: 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: Initiates recognition; performed following loading of sl@0: 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 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 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 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: 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 from the specified model bank sl@0: 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 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: 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: A reference where a new model ID is assigned to. 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 memory, previously loaded sl@0: with LoadGrammarL. sl@0: sl@0: The rule in the 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: Sets the event handler for asynchronous events. sl@0: sl@0: @param aSpeechRecognitionUtilityObserver sl@0: A pointer to an observer. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: IMPORT_C void SetEventHandler( MSpeechRecognitionUtilityObserver* sl@0: aSpeechRecognitionUtilityObserver ); 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: @param aPronunciationIDs sl@0: A reference where pronunciation IDs are 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 GetAllPronunciationIDs( TLexiconID aLexiconID, sl@0: RArray & aPronunciationIDs ); sl@0: sl@0: /** sl@0: Returns all grammar IDs owned by the client. sl@0: sl@0: @param aGrammarIDs sl@0: A reference where rule IDs are 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 GetAllClientGrammarIDs(RArray & aGrammarIDs ); sl@0: sl@0: /** sl@0: Returns all lexicons owned by the client. sl@0: sl@0: @param aLexiconIDs sl@0: A reference where lexicon IDs are 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 GetAllClientLexiconIDs(RArray & aLexiconIDs ); sl@0: sl@0: /** sl@0: Returns all modelbank IDs owned by the client. sl@0: sl@0: @param aModelBankIDs sl@0: A reference where modelbank IDs are 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 GetAllClientModelBankIDs( sl@0: RArray& aModelBankIDs ); sl@0: /** sl@0: Returns all grammar IDs. sl@0: sl@0: @param aGrammarIDs sl@0: A reference where rule IDs are 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 GetAllGrammarIDs(RArray & aGrammarIDs ); sl@0: sl@0: /** sl@0: Returns all lexicons IDs. sl@0: sl@0: @param aLexiconIDs sl@0: A reference where lexicon IDs are 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 GetAllLexiconIDs(RArray & aLexiconIDs ); sl@0: sl@0: /** sl@0: Returns all modelbank IDs. sl@0: sl@0: @param aModelBankIDs sl@0: A reference where modelbank IDs are 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 GetAllModelBankIDs( sl@0: RArray& aModelBankIDs ); 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: @param aModelIDs sl@0: A reference where model IDs are 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 GetAllModelIDs( TModelBankID aModelBankID, sl@0: RArray & aModelIDs ); 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: Returns all rule IDs that exist in the specified grammar. sl@0: sl@0: @param aGrammarID sl@0: The grammar ID. sl@0: @param aRuleIDs sl@0: A reference where rule IDs are 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 GetAllRuleIDs( TGrammarID aGrammarID, sl@0: RArray & aRuleIDs ); sl@0: sl@0: /** sl@0: Creates a new model bank. sl@0: sl@0: @param aModelBankID sl@0: A reference where a new model bank IF is assigned to. 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: 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: Returns the number of models available for training system model storage, based on available sl@0: disk space. sl@0: sl@0: @param aAvailableStorage sl@0: The number of models that can be contained in available storage. 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: Loads the specified parameters into the recognition engine. sl@0: sl@0: @param aParameterId sl@0: The array of parameter IDs. sl@0: @param aParameterValue sl@0: The 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: Sets the audio priority and preference for train, playback and recognition. sl@0: sl@0: @param aPriority sl@0: The priority for voice recognition. sl@0: @param aTrainPreference sl@0: The preference for training. sl@0: @param aPlaybackPreference sl@0: The preference for playback. sl@0: @param aRecognitionPreference sl@0: The preference for recognition. 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: */ sl@0: IMPORT_C TInt SetAudioPriority( TInt aPriority, TInt aTrainPreference, sl@0: TInt aPlaybackPreference, TInt aRecognitionPreference ); sl@0: sl@0: private: sl@0: /** sl@0: Private C++ constructor for this class. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: CSpeechRecognitionUtility(); sl@0: sl@0: /** sl@0: Second phase constructor for this class. sl@0: sl@0: @param aSpeechRecognitionUtilityObserver sl@0: A reference to the event observer class. sl@0: sl@0: @since 8.0 sl@0: */ sl@0: void ConstructL(MSpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver); sl@0: sl@0: private: sl@0: CBody* iBody; sl@0: friend class CBody; sl@0: }; sl@0: sl@0: #endif // of __SPEECHRECOGNITIONUTILITY_H__ sl@0: sl@0: // End of File