Update contrib.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __SPEECHRECOGNITIONUTILITY_H__
17 #define __SPEECHRECOGNITIONUTILITY_H__
22 #include <mmf/common/mmfcontroller.h>
23 #include <mmf/common/speechrecognitioncustomcommands.h>
24 #include <mmf/common/speechrecognitiondataclient.h>
25 #include <speechrecognitionutilityobserver.h>
34 This is the main class of Speech Recognition Utility.
38 class CSpeechRecognitionUtility : public CBase
44 Factory function for creating this class.
47 The UID of the client.
48 @param aSpeechRecognitionUtilityObserver
49 A reference to the event observer class.
51 @return A pointer to CSpeechRecognitionUtility object
55 IMPORT_C static CSpeechRecognitionUtility* NewL(
56 MSpeechRecognitionUtilityObserver&
57 aSpeechRecognitionUtilityObserver, TUid aClientUid );
60 Factory function for creating this class. Leaves a pointer on the cleanup stack.
62 @param aSpeechRecognitionUtilityObserver
63 A reference to the event observer class.
65 A client UID for data ownership.
67 @return A pointer to a CSpeechRecognitionUtility object.
71 IMPORT_C static CSpeechRecognitionUtility* NewLC(
72 MSpeechRecognitionUtilityObserver&
73 aSpeechRecognitionUtilityObserver, TUid aClientUid );
80 IMPORT_C ~CSpeechRecognitionUtility();
83 Returns the engine properties specified by the engine property
84 ID array. On return aPropertyValue contains an array of engine
88 A constant reference to an array of engine property ID's.
90 A reference to an array of engine property values.
92 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
93 another of the system-wide error codes.
97 IMPORT_C TInt GetEngineProperties( const RArray<TInt>& aPropertyId,
98 RArray<TInt>& aPropertyValue );
101 Adds a new pronunciation for the given model into the
105 The lexicon ID, where the new pronunciation is added to.
110 @param aPronunciationID
111 A reference where the new pronunciation ID is assigned to.
113 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
114 another of the system-wide error codes.
118 IMPORT_C TInt AddPronunciation( TLexiconID aLexiconID,
119 TModelBankID aModelBankID, TModelID aModelID,
120 TPronunciationID& aPronunciationID );
123 Adds a new rule for the given pronunciation into the
127 The grammar ID, where the new rule is added to.
130 @param aPronunciationID
131 The pronunciation ID.
133 A reference where the new rule ID is assigned to.
135 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
136 another of the system-wide error codes.
140 IMPORT_C TInt AddRule( TGrammarID aGrammarID, TLexiconID aLexiconID,
141 TPronunciationID aPronunciationID, TRuleID& aRuleID );
144 Cancels the current operation.
148 IMPORT_C void Cancel();
151 Commit the current train operation to the database.
153 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
154 another of the system-wide error codes.
158 IMPORT_C TInt CommitChanges();
161 Creates a new grammar.
164 A reference where grammar ID is stored.
166 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
167 another of the system-wide error codes.
171 IMPORT_C TInt CreateGrammar( TGrammarID& aGrammarID );
174 Creates a new lexicon.
177 A reference where lexicon ID is stored.
179 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
180 another of the system-wide error codes.
184 IMPORT_C TInt CreateLexicon( TLexiconID& aLexiconID );
187 Loads the specified model bank into the recognizer;
188 done prior to recognition.
193 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
194 another of the system-wide error codes.
198 IMPORT_C TInt LoadModels( TModelBankID aModelBankID );
201 Loads the specified grammar into the recognizer;
202 done prior to recognition.
207 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
208 another of the system-wide error codes.
212 IMPORT_C TInt LoadGrammar( TGrammarID aGrammarID );
215 Loads the specified lexicon into the recognizer;
216 done prior to recognition.
221 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
222 another of the system-wide error codes.
226 IMPORT_C TInt LoadLexicon( TLexiconID aLexiconID );
229 Returns the duration of the utterance for the specified model.
236 The reference where the duration of utterance is set.
238 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
239 another of the system-wide error codes.
243 IMPORT_C TInt GetUtteranceDuration( TModelBankID aModelBankID,
245 TTimeIntervalMicroSeconds32& aDuration);
248 Plays the previously trained utterance.
253 The model ID, whose utterance is played.
255 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
256 another of the system-wide error codes.
260 IMPORT_C TInt PlayUtterance( TModelBankID aModelBankID,
264 Returns the number of models in the specified model bank.
269 The reference where the number of models is set.
271 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
272 another of the system-wide error codes.
276 IMPORT_C TInt GetModelCount( TModelBankID aModelBankID, TInt& aModelCount );
279 Ends the current recognition session. Resources allocated
280 for recognition are freed.
282 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
283 another of the system-wide error codes.
287 IMPORT_C TInt EndRecSession();
290 Starts a new recognition session.
293 The recognition mode.
295 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
296 another of the system-wide error codes.
300 IMPORT_C TInt StartRecSession( TRecognitionMode aMode );
303 Initiates recognition; performed following loading of
304 model bank, lexicon, and grammar.
307 A reference where the recognition result is set.
309 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
310 another of the system-wide error codes.
314 IMPORT_C TInt Recognize( CSDClientResultSet& aResultSet );
317 Records user utterance for training and recognition.
320 The recording time in microseconds.
322 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
323 another of the system-wide error codes.
327 IMPORT_C TInt Record( TTimeIntervalMicroSeconds32 aRecordTime );
330 Removes the specified grammar from the permanent storage.
332 Removing a grammar will remove all rules within the grammar.
337 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
338 another of the system-wide error codes.
342 IMPORT_C TInt RemoveGrammar( TGrammarID aGrammarID );
345 Removes the specified pronunciation from the specified lexicon permanently.
349 @param aPronunciationID
350 The pronunciation ID.
352 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
353 another of the system-wide error codes.
357 IMPORT_C TInt RemovePronunciation( TLexiconID aLexiconID,
358 TPronunciationID aPronunciationID );
361 Removes the specified lexicon from the permanent storage.
363 Removing a lexicon will remove all pronunciations within the lexicon.
368 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
369 another of the system-wide error codes.
373 IMPORT_C TInt RemoveLexicon( TLexiconID aLexiconID );
376 Removes the specified model from the specified model bank
384 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
385 another of the system-wide error codes.
389 IMPORT_C TInt RemoveModel( TModelBankID aModelBankID,
393 Removes the specified rule from the specified grammar permanently.
400 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
401 another of the system-wide error codes.
405 IMPORT_C TInt RemoveRule( TGrammarID aGrammarID, TRuleID aRuleID );
408 Trains a new model into the specified model bank.
413 A reference where a new model ID is assigned to.
415 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
416 another of the system-wide error codes.
420 IMPORT_C TInt Train( TModelBankID aModelBankID, TModelID& aModelID );
423 Unloads the specified rule from the specified grammar in temporary memory, previously loaded
426 The rule in the permanent storage remains intact.
433 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
434 another of the system-wide error codes.
438 IMPORT_C TInt UnloadRule( TGrammarID aGrammarID, TRuleID aRuleID );
441 Sets the event handler for asynchronous events.
443 @param aSpeechRecognitionUtilityObserver
444 A pointer to an observer.
448 IMPORT_C void SetEventHandler( MSpeechRecognitionUtilityObserver*
449 aSpeechRecognitionUtilityObserver );
452 Returns all pronunciation IDs that exist in the specified lexicon.
456 @param aPronunciationIDs
457 A reference where pronunciation IDs are stored.
459 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
460 another of the system-wide error codes.
464 IMPORT_C TInt GetAllPronunciationIDs( TLexiconID aLexiconID,
465 RArray <TPronunciationID>& aPronunciationIDs );
468 Returns all grammar IDs owned by the client.
471 A reference where rule IDs are stored.
473 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
474 another of the system-wide error codes.
478 IMPORT_C TInt GetAllClientGrammarIDs(RArray <TGrammarID>& aGrammarIDs );
481 Returns all lexicons owned by the client.
484 A reference where lexicon IDs are stored.
486 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
487 another of the system-wide error codes.
491 IMPORT_C TInt GetAllClientLexiconIDs(RArray <TLexiconID>& aLexiconIDs );
494 Returns all modelbank IDs owned by the client.
497 A reference where modelbank IDs are stored.
499 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
500 another of the system-wide error codes.
504 IMPORT_C TInt GetAllClientModelBankIDs(
505 RArray<TModelBankID>& aModelBankIDs );
507 Returns all grammar IDs.
510 A reference where rule IDs are stored.
512 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
513 another of the system-wide error codes.
517 IMPORT_C TInt GetAllGrammarIDs(RArray <TGrammarID>& aGrammarIDs );
520 Returns all lexicons IDs.
523 A reference where lexicon IDs are stored.
525 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
526 another of the system-wide error codes.
530 IMPORT_C TInt GetAllLexiconIDs(RArray <TLexiconID>& aLexiconIDs );
533 Returns all modelbank IDs.
536 A reference where modelbank IDs are stored.
538 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
539 another of the system-wide error codes.
543 IMPORT_C TInt GetAllModelBankIDs(
544 RArray<TModelBankID>& aModelBankIDs );
547 Returns all model IDs that exist in the specified model bank.
552 A reference where model IDs are stored.
554 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
555 another of the system-wide error codes.
559 IMPORT_C TInt GetAllModelIDs( TModelBankID aModelBankID,
560 RArray <TModelID>& aModelIDs );
563 Checks if the rule is valid or not.
570 A reference where the validity of the rule is set.
572 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
573 another of the system-wide error codes.
577 IMPORT_C TInt GetRuleValidity( TGrammarID aGrammarID, TRuleID aRuleID,
581 Returns all rule IDs that exist in the specified grammar.
586 A reference where rule IDs are stored.
588 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
589 another of the system-wide error codes.
593 IMPORT_C TInt GetAllRuleIDs( TGrammarID aGrammarID,
594 RArray <TRuleID>& aRuleIDs );
597 Creates a new model bank.
600 A reference where a new model bank IF is assigned to.
602 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
603 another of the system-wide error codes.
607 IMPORT_C TInt CreateModelBank( TModelBankID& aModelBankID );
610 Removes the specified model bank from the permanent storage.
612 Removing a model bank will remove all models within the model bank.
617 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
618 another of the system-wide error codes.
622 IMPORT_C TInt RemoveModelBank( TModelBankID aModelBankID );
625 Returns the number of models available for training system model storage, based on available
628 @param aAvailableStorage
629 The number of models that can be contained in available storage.
631 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
632 another of the system-wide error codes.
636 IMPORT_C TInt GetAvailableStorage( TInt& aAvailableStorage );
639 Loads the specified parameters into the recognition engine.
642 The array of parameter IDs.
643 @param aParameterValue
644 The array of parameter values.
646 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
647 another of the system-wide error codes.
651 IMPORT_C TInt LoadEngineParameters( const RArray<TInt>& aParameterId,
652 const RArray<TInt>& aParameterValue );
655 Sets the audio priority and preference for train, playback and recognition.
658 The priority for voice recognition.
659 @param aTrainPreference
660 The preference for training.
661 @param aPlaybackPreference
662 The preference for playback.
663 @param aRecognitionPreference
664 The preference for recognition.
666 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
667 another of the system-wide error codes.
672 IMPORT_C TInt SetAudioPriority( TInt aPriority, TInt aTrainPreference,
673 TInt aPlaybackPreference, TInt aRecognitionPreference );
677 Private C++ constructor for this class.
681 CSpeechRecognitionUtility();
684 Second phase constructor for this class.
686 @param aSpeechRecognitionUtilityObserver
687 A reference to the event observer class.
691 void ConstructL(MSpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver);
698 #endif // of __SPEECHRECOGNITIONUTILITY_H__