srsfenginestub/recognitionhwdevice/src/asrsrecognitionhwdevice.h
changeset 0 0ce1b5ce9557
equal deleted inserted replaced
-1:000000000000 0:0ce1b5ce9557
       
     1 /*
       
     2 * Copyright (c) 2004 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:     HW Device for speech recognition
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #ifndef ASRSRECOGNITIONHWDEVICE_H
       
    24 #define ASRSRECOGNITIONHWDEVICE_H
       
    25 
       
    26 //  INCLUDES
       
    27 #include <asrshwdevice.h>
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CSDModelBank;
       
    31 class CSIModelBank;
       
    32 class CRecognitionAlgorithm;
       
    33 
       
    34 // CLASS DECLARATION
       
    35 /**
       
    36 *  Observer for recognition HW device
       
    37 *
       
    38 *  @lib asrsrecognitionhwdevice.lib
       
    39 *  @since 2.8
       
    40 */
       
    41 class MASRSRecognitionHwDeviceObserver 
       
    42     {
       
    43         
       
    44     public: // New functions
       
    45         
       
    46         /**
       
    47         * Called by the hardware device when the InitializeL() method has completed.
       
    48         * @since 2.8
       
    49         * @param aError Initialization result code. 
       
    50         *               KErrNone if successful otherwise a system-wide error code.
       
    51         * @return none
       
    52         */
       
    53         virtual void MarhdoInitializationComplete( TInt aError ) = 0;
       
    54 
       
    55         /**
       
    56         * Called by the hardware device when the  InitializeL() method has completed.
       
    57         * @since 2.8
       
    58         * @param aError Initialization result code. 
       
    59         *               KErrNone if successful otherwise a system-wide error code.
       
    60         * @return none
       
    61         */
       
    62         virtual void MarhdoInitRecognizerFEComplete( TInt aError ) = 0;
       
    63 
       
    64         /**
       
    65         * Called by the hardware device when backend initialization is completed.
       
    66         * @since 2.8
       
    67         * @param aError Initialization result code. 
       
    68         *               KErrNone if successful otherwise a system-wide error code.
       
    69         * @return none
       
    70         */
       
    71         virtual void MarhdoInitRecognizerBEComplete( TInt aError ) = 0;
       
    72 
       
    73         /**
       
    74         * Called by the hardware device when recognition result is available.
       
    75         * @since 2.8
       
    76         * @param aError Recognition result code. KErrNone if successful.  
       
    77         *               KErrRejected if the recognition result is rejected, 
       
    78         *               otherwise a system-wide error code
       
    79         * @return none
       
    80         */ 
       
    81         virtual void MarhdoRecognitionComplete( TInt aError ) = 0;
       
    82 
       
    83         /**
       
    84         * Called by the hardware device when end-of-utterance is detected by the 
       
    85         * acoustic frontend. This method must be called before MarhdoRecognitionComplete().
       
    86         * @since 2.8
       
    87         * @param aError Recognition result code. KErrNone if successful, otherwise KErrTooLong, 
       
    88         *               KErrTooShort, KErrAsrSpeechTooEarly, KErrNoSpeech
       
    89         * @return none
       
    90         */
       
    91         virtual void MarhdoEouDetected( TInt aError ) = 0;
       
    92 
       
    93         /**
       
    94         * Called by the hardware device when a feature vector is extracted by acoustic frontend.
       
    95         * @since 2.8
       
    96         * @param aFV A buffer containing a feature vector.
       
    97         * @param aSNR Signal-to-noise ratio.
       
    98         * @param aPosition Indicates whether this is the first, subsequent or last feature vector in a series.
       
    99         * @return none
       
   100         */
       
   101         virtual void MarhdoFeatureVector( const TDesC8& aFV, TInt32 aSNR, TInt32 aPosition ) = 0;
       
   102 
       
   103         /**
       
   104         * Called by the hardware device to request for utterance data. 
       
   105         * The response to the request is sent in SendSpeechData().
       
   106         * @since 2.8
       
   107         * @param none
       
   108         * @return none
       
   109         */
       
   110         virtual void MarhdoRequestSpeechData () = 0;
       
   111     };
       
   112 
       
   113 /**
       
   114 *  Recognition HW Device
       
   115 *
       
   116 *  @lib asrsrecognitionhwdevice.lib
       
   117 *  @since 2.8
       
   118 */
       
   119 class CASRSRecognitionHwDevice : public CASRSHwDevice
       
   120     {
       
   121     public:  // Constructors and destructor
       
   122         
       
   123         /**
       
   124         * Two-phased constructor.
       
   125         */
       
   126         IMPORT_C static CASRSRecognitionHwDevice* NewL( MASRSRecognitionHwDeviceObserver& aObserver );
       
   127         
       
   128         /**
       
   129         * Destructor.
       
   130         */
       
   131         IMPORT_C virtual ~CASRSRecognitionHwDevice();
       
   132         
       
   133     public: // New functions
       
   134         
       
   135         /**
       
   136         * This method initializes the backend of the recognition Hw device.
       
   137         * @since 2.8
       
   138         * @param aRecognitionData A recognition data generated by grammar compilation.
       
   139         * @param aModels A model bank containing acoustic models 
       
   140         * @return none
       
   141         */
       
   142         IMPORT_C void InitRecognizerBEL( const TDesC8& aRecognitionData, 
       
   143                                const CSIModelBank& aModels );
       
   144 
       
   145         /**
       
   146         * This method initialize the frontend of the recognition Hwdevice
       
   147         * @since 2.8
       
   148         * @param none
       
   149         * @return none
       
   150         */  
       
   151         IMPORT_C void InitRecognizerFEL( TBool aSendFeatureVectors = EFalse );
       
   152 
       
   153         /**
       
   154         * Sets the maximum number of entries wanted in the ranked list of recognition results. 
       
   155         * @since 2.8
       
   156         * @param aNBest The n-best number.
       
   157         * @return none
       
   158         */ 
       
   159     	IMPORT_C void SetNBest( TUint32 aNBest );
       
   160     	
       
   161     	/**
       
   162         * Sets the rejection threshold. 
       
   163         * @since 3.2
       
   164         * @param aRejection Rejection threshold value.
       
   165         * @return none
       
   166         */ 
       
   167     	IMPORT_C void SetRejection( TUint32 aRejection );
       
   168     	
       
   169     	/**
       
   170         * Gets the rejection threshold. 
       
   171         * @since 2.8
       
   172         * @param none
       
   173         * @return Rejection threshold value.
       
   174         */ 
       
   175     	IMPORT_C TUint32 GetRejection();
       
   176 
       
   177         /**
       
   178         * Start recognition
       
   179         * @since 2.8
       
   180         * @param aNBestList At the end of recognition, this object will contain Nbest list IDs.
       
   181         * @param aScore At the end of recognition, this object will contain scores for Nbest list.
       
   182         * @param aSendFeatureVectors ETrue send feature vector to client, EFalse do not send feature vector to client.
       
   183         * @return none
       
   184         */ 
       
   185         IMPORT_C void StartRecognitionL( RArray<TUint>& aNBestList, RArray<TInt>& aScore );
       
   186 
       
   187         /**
       
   188         * Stop a started recognition process.
       
   189         * @since 2.8
       
   190         * @param none
       
   191         * @return none
       
   192         */ 
       
   193         IMPORT_C void StopRecognition();
       
   194  
       
   195         /**
       
   196         * Use to send utterance data
       
   197         * @since 2.8
       
   198         * @param aBuffer Buffer containing utterance data.
       
   199         * @param aEnd End of utterance data indicator. ETrue indicates end of data or no data.
       
   200         * @return none
       
   201         */ 
       
   202         IMPORT_C void SendSpeechData( TPtrC8& aBuffer, TBool aEnd );
       
   203         
       
   204     public: // Functions from base classes
       
   205 
       
   206         /**
       
   207         * From CASRSHwDevice Use to initilize HW device
       
   208         * @since 2.8
       
   209         * @param none
       
   210         * @return none
       
   211         */
       
   212         IMPORT_C virtual void InitializeL();
       
   213 
       
   214         /**
       
   215         * From CASRSHwDevice Use to clear HW device
       
   216         * @since 2.8
       
   217         * @param none
       
   218         * @return none
       
   219         */
       
   220         IMPORT_C virtual void Clear();
       
   221 
       
   222 		/**
       
   223         * From CASRSHwDevice Use to get custom interface
       
   224         * @since 2.8
       
   225         * @param aInterfaceId Identifier of the intercace implementation
       
   226         * @return Pointer to the interface implementation or NULL.
       
   227         */
       
   228         IMPORT_C virtual TAny* CustomInterface( TUid aInterfaceId );
       
   229                
       
   230     private:
       
   231         
       
   232         /**
       
   233         * C++ default constructor.
       
   234         */
       
   235         CASRSRecognitionHwDevice();
       
   236         
       
   237         /**
       
   238         * By default Symbian 2nd phase constructor is private.
       
   239         */
       
   240         void ConstructL( MASRSRecognitionHwDeviceObserver& aObserver );
       
   241                 
       
   242     private:    // Data
       
   243 
       
   244         // Actual implementation of recognition
       
   245         CRecognitionAlgorithm* iRecAlgorithm;
       
   246         
       
   247         // Reserved pointer for future extension
       
   248         TAny* iReserved;
       
   249         
       
   250     };
       
   251 
       
   252 #endif      // ASRSRECOGNITIONHWDEVICE  
       
   253 
       
   254 // End of File