epoc32/include/mmf/devasr/devasr.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@4
     4
// under the terms of "Eclipse Public License v1.0"
williamr@2
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
//
williamr@2
    15
williamr@2
    16
#ifndef __DEVASR_H__
williamr@2
    17
#define __DEVASR_H__
williamr@2
    18
williamr@2
    19
//  INCLUDES
williamr@2
    20
#include <e32base.h>
williamr@2
    21
#include <mmf/common/speechrecognitiondatadevasr.h>
williamr@2
    22
#include <mmf/devasr/devasrcommon.h>
williamr@2
    23
williamr@2
    24
// FORWARD DECLARATION
williamr@2
    25
class CSRSAlgorithmManager;
williamr@2
    26
class TMMFPrioritySettings;
williamr@2
    27
williamr@2
    28
/**
williamr@2
    29
*  Interface for the DevASR callbacks that are implemented by DevASR observers.
williamr@2
    30
*
williamr@2
    31
*  @publishedAll
williamr@2
    32
*  @released
williamr@2
    33
*  @since 8.0
williamr@2
    34
*/
williamr@2
    35
williamr@2
    36
class MDevASRObserver
williamr@2
    37
	{
williamr@2
    38
    public:
williamr@2
    39
williamr@2
    40
        /**
williamr@2
    41
        * DevASR notifies object implementing this interface whenever a spontaneous or non-spontaneous
williamr@2
    42
		* event occurs in DevASR.
williamr@2
    43
        * @since 8.0
williamr@2
    44
        * @param aEvent DevASR event code
williamr@2
    45
        * @param aError DevASR error code
williamr@2
    46
        */
williamr@2
    47
		virtual void DevASREvent(TDevASREvent aEvent, TDevASRError aError)=0;
williamr@2
    48
williamr@2
    49
		/**
williamr@2
    50
        * DevASR notifies object implementing this interface when feature vectors are available.
williamr@2
    51
        * @since 8.0
williamr@2
    52
        * @param aFV Buffer containing the feature vector data
williamr@2
    53
        * @param aSNR Signal-to-noise ratio
williamr@2
    54
		* @param aPosition Indicates whether the feature vector is the first, middle, or end.
williamr@2
    55
        */
williamr@2
    56
		virtual void FeatureVectorDataRcvd(const TDesC16& aFV, TInt32 aSNR, TInt32 aPosition)=0;
williamr@2
    57
williamr@2
    58
        /**
williamr@2
    59
        * DevASR calls this method to send a message in response to a custom command.
williamr@2
    60
        * @since 8.0
williamr@2
    61
        * @param aMsg Buffer containing the message
williamr@2
    62
        */
williamr@2
    63
		virtual void DevASRMessage(TDesC8& aMsg)=0;
williamr@2
    64
    };
williamr@2
    65
williamr@2
    66
/**
williamr@2
    67
*  Interface Class for the DevASR API.
williamr@2
    68
*
williamr@2
    69
*  @publishedAll
williamr@2
    70
*  @released
williamr@2
    71
*  @since 8.0
williamr@2
    72
*/
williamr@2
    73
class CDevASR : public CBase
williamr@2
    74
    {
williamr@2
    75
    public:  // Constructors and destructor
williamr@2
    76
williamr@2
    77
        /**
williamr@2
    78
        * Two-phased constructor.
williamr@2
    79
        *
williamr@2
    80
        * @param aObserver The observer to call back when events occur
williamr@2
    81
        *
williamr@2
    82
        * @return pointer to object of type CDevASR
williamr@2
    83
        */
williamr@2
    84
        IMPORT_C static CDevASR* NewL(MDevASRObserver& aObserver);
williamr@2
    85
        
williamr@2
    86
        /**
williamr@2
    87
        * Two-phased constructor.
williamr@2
    88
        *
williamr@2
    89
        * @param aObserver The observer to call back when events occur        
williamr@2
    90
        *
williamr@2
    91
        * @return pointer to object of type CDevASR
williamr@2
    92
        */
williamr@2
    93
        IMPORT_C static CDevASR* NewLC(MDevASRObserver& aObserver);
williamr@2
    94
williamr@2
    95
        /**
williamr@2
    96
        * Destructor.
williamr@2
    97
        */
williamr@2
    98
        IMPORT_C virtual ~CDevASR();
williamr@2
    99
williamr@2
   100
    public: // New functions
williamr@2
   101
williamr@2
   102
		/**
williamr@2
   103
        * Cancels the current or started tasks.
williamr@2
   104
        * @since 8.0
williamr@2
   105
        */
williamr@2
   106
        IMPORT_C void Cancel();
williamr@2
   107
williamr@2
   108
		/**
williamr@2
   109
        * Use to request a custom interface implementation from the component.
williamr@2
   110
		* through the DevASR API.
williamr@2
   111
        * @since 8.0
williamr@2
   112
        * @param aInterfaceId - Interface UID, defined with the custom interface.
williamr@2
   113
		* @return a pointer to the interface implementation, or NULL if the requested interface is
williamr@2
   114
		* not implemented. The return value must be cast to the correct type by the user.
williamr@2
   115
        */
williamr@2
   116
		IMPORT_C TAny* CustomInterface(TUid aInterfaceId);
williamr@2
   117
williamr@2
   118
		/**
williamr@2
   119
        * This method is used to indicate the end of a recognition session. All loaded grammars,
williamr@2
   120
		* lexicon, and models become invalid after this call.
williamr@2
   121
        * @since 8.0
williamr@2
   122
        */
williamr@2
   123
		IMPORT_C void EndRecSession();
williamr@2
   124
williamr@2
   125
williamr@2
   126
		/**
williamr@2
   127
        Retreive the properties of the underlying speech recognition engine.
williamr@2
   128
williamr@2
   129
        @param  aPropertyId
williamr@2
   130
		        An array of identifiers being querried
williamr@2
   131
        @param  aPropertyValue
williamr@2
   132
		        An array of values corresponding to the querried identifiers
williamr@2
   133
williamr@2
   134
        @since  8.0
williamr@2
   135
        */
williamr@2
   136
        IMPORT_C void GetEnginePropertiesL(const RArray<TInt>& aPropertyId, RArray<TInt>& aPropertyValue);
williamr@2
   137
williamr@2
   138
		/**
williamr@2
   139
        * Initializes the front-end module in the speech recognition engine.
williamr@2
   140
		* The frontend module used during training/recognition functions is started
williamr@2
   141
		* as a result. This method is intended to be used in conjunction with InitTrainBE().
williamr@2
   142
        * @since 8.0
williamr@2
   143
        * @param aMode - Mode of the recognizer
williamr@2
   144
        */
williamr@2
   145
        IMPORT_C void InitFrontEnd(TRecognizerMode aMode);
williamr@2
   146
williamr@2
   147
		/**
williamr@2
   148
        * Perform any necessary initialization or allocation of the audio resource
williamr@2
   149
		* for playing a voice sample. A buffer to hold audio data to play is allocated.
williamr@2
   150
		* If allocation fails, this method will leave. Client is responsible for filling
williamr@2
   151
		* the buffer with their audio data and invoke Play() on DevASR.
williamr@2
   152
        * @since 8.0
williamr@2
   153
        * @param aPlayDuration - Specifies the duration of playback in microseconds
williamr@2
   154
		* @return A reference to the buffer to be filled with source audio data.
williamr@2
   155
        */
williamr@2
   156
		IMPORT_C TDes8& InitPlayL(TTimeIntervalMicroSeconds32 aPlayDuration);
williamr@2
   157
williamr@2
   158
		/**
williamr@2
   159
        * Initialize the recognition engine back-end. The module responsible for recognition
williamr@2
   160
		* function is started as a result. This method must be used before any recognition
williamr@2
   161
		* operations and intended to be used in conjunction with InitFrontEnd().
williamr@2
   162
        * @since 8.0
williamr@2
   163
        * @param aResult - a reference to an object where the recognition result will be written
williamr@2
   164
        */
williamr@2
   165
        IMPORT_C void InitRecognizerBE(CSDResultSet& aResult);
williamr@2
   166
williamr@2
   167
		/**
williamr@2
   168
        * Initializes the back-end module in the speech recognition engine.
williamr@2
   169
		* The back-end module responsible for training functions is started as a result.
williamr@2
   170
		* This method is intended to be used in conjunction with InitFrontEnd().
williamr@2
   171
        * @since 8.0
williamr@2
   172
        * @param aModel	- Buffer in which the newly created model will be written
williamr@2
   173
        */
williamr@2
   174
        IMPORT_C void InitTrainBE(CSDModel& aModel);
williamr@2
   175
williamr@2
   176
		/**
williamr@2
   177
        * Load the specified recognizer parameter(s). These parameters are used to alter the
williamr@2
   178
        * recognizer's default parameters. The parameters are specified as attribute-value pairs.
williamr@2
   179
        * @since 8.0
williamr@2
   180
        * @param aParameterId - An array of parameter identifiers
williamr@2
   181
        * @param aParameterValue - An array of parameter values
williamr@2
   182
        */
williamr@2
   183
        IMPORT_C void LoadEngineParametersL(const RArray<TInt>& aParameterId, const RArray<TInt>& aParameterValue);
williamr@2
   184
williamr@2
   185
		/**
williamr@2
   186
        * Load the specified grammar into the recognizer.
williamr@2
   187
        * @since 8.0
williamr@2
   188
        * @param aGrammar - A reference to a grammar in an internal format
williamr@2
   189
        */
williamr@2
   190
        IMPORT_C void LoadGrammar(const CSDGrammar& aGrammar);
williamr@2
   191
williamr@2
   192
		/**
williamr@2
   193
        * Load the specified grammar into the recognizer.
williamr@2
   194
        * @since 8.0
williamr@2
   195
        * @param aLexicon - A reference to a lexicon in an internal format
williamr@2
   196
        */
williamr@2
   197
        IMPORT_C void LoadLexicon(const CSDLexicon& aLexicon);
williamr@2
   198
williamr@2
   199
		/**
williamr@2
   200
        * Load the specified Lexicon into the recognizer.
williamr@2
   201
        * @since 8.0
williamr@2
   202
        * @param aModels - A reference to a model bank
williamr@2
   203
        */
williamr@2
   204
        IMPORT_C void LoadModels(const CSDModelBank& aModels);
williamr@2
   205
williamr@2
   206
		/**
williamr@2
   207
        * Request DevASR to play the contents of its own buffer. The buffer was previously
williamr@2
   208
		* allocated by invoking method InitPlay().
williamr@2
   209
        * @since 8.0
williamr@2
   210
        */
williamr@2
   211
        IMPORT_C void Play();
williamr@2
   212
williamr@2
   213
		/**
williamr@2
   214
        * Request to begin recording.
williamr@2
   215
        * @since 8.0
williamr@2
   216
        * @param aRecordDuration - Length of time to record, expressed in microseconds
williamr@2
   217
        */
williamr@2
   218
        IMPORT_C void Record(TTimeIntervalMicroSeconds32 aRecordDuration);
williamr@2
   219
williamr@2
   220
		/**
williamr@2
   221
        * Use to set the priority of the sound device
williamr@2
   222
        * @since 8.0
williamr@2
   223
        * @param aPrioritySettings Priority settings structure
williamr@2
   224
williamr@2
   225
        */
williamr@2
   226
		IMPORT_C void SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
williamr@2
   227
williamr@2
   228
		/**
williamr@2
   229
        * This method is used to start a recognition session with the recognition engine.
williamr@2
   230
        * @since 8.0
williamr@2
   231
		* @param aMode Mode of the recognizer
williamr@2
   232
		* @return result code of operation
williamr@2
   233
        */
williamr@2
   234
        IMPORT_C TInt StartRecSession(TRecognizerMode aMode);
williamr@2
   235
williamr@2
   236
		/**
williamr@2
   237
        * Request to unload the specified rule in the grammar from recognizer.
williamr@2
   238
        * @since 8.0
williamr@2
   239
        * @param aGrammarID - Identifer of the grammar to operate on
williamr@2
   240
		* @param aRuleID - Identifier of the rule to remove
williamr@2
   241
        */
williamr@2
   242
        IMPORT_C void UnloadRule(TGrammarID aGrammarID, TRuleID aRuleID);
williamr@2
   243
williamr@2
   244
		/**
williamr@2
   245
        * Retreive the raw audio data accumulated during recording.
williamr@2
   246
        * @since 8.0
williamr@2
   247
		* @param aBuffer Reference to a buffer containing the data
williamr@2
   248
		* @param aDuration Duration of the utterance
williamr@2
   249
        */
williamr@2
   250
        IMPORT_C void GetUtteranceData(TDes8* aBuffer, TTimeIntervalMicroSeconds32& aDuration);
williamr@2
   251
williamr@2
   252
williamr@2
   253
    private:
williamr@2
   254
williamr@2
   255
        /**
williamr@2
   256
        * C++ default constructor.
williamr@2
   257
        */
williamr@2
   258
        CDevASR();
williamr@2
   259
williamr@2
   260
        /**
williamr@2
   261
        * By default Symbian 2nd phase constructor is private.
williamr@2
   262
        */
williamr@2
   263
        void ConstructL(MDevASRObserver& aObserver);
williamr@2
   264
williamr@2
   265
    private:    // Data
williamr@2
   266
        // Pointer to algorithm manager
williamr@2
   267
   		CSRSAlgorithmManager* iSRSAlgorithmManager;
williamr@2
   268
    };
williamr@2
   269
williamr@2
   270
#endif // __DEVASR_H__
williamr@2
   271
williamr@2
   272
// End of File