os/mm/mmdevicefw/speechrecogsupport/ASR/inc/mmf/common/SpeechRecognitionDataDevASR.h
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 __SPEECHRECOGNITIONDATADEVASR_H__
17 #define __SPEECHRECOGNITIONDATADEVASR_H__
20 #include <mmf/common/speechrecognitiondatacommon.h>
23 // FORWARD DECLARATION
33 Class to encapsulate a Speaker Dependent Rule.
37 class CSDRule : public CBase
39 public:// Constructors and destructor
47 Instantiates an instance of CSDRule.
52 The lexicon identifier.
53 @param aPronunciationID
54 The pronunciation identifier.
56 @return A pointer to a CSDRule object.
58 IMPORT_C static CSDRule* NewL(TRuleID aRuleID, TLexiconID aLexiconID, TPronunciationID aPronunciationID);
61 Instantiates an instance of CSDRule and leaves a pointer on the cleanup stack.
66 The lexicon identifier.
67 @param aPronunciationID
68 The pronunciation identifier.
70 @return A pointer to a CSDRule object.
72 IMPORT_C static CSDRule* NewLC(TRuleID aRuleID, TLexiconID aLexiconID, TPronunciationID aPronunciationID);
76 Returns the rule ID of the result.
78 @return The rule identifier.
82 IMPORT_C TRuleID RuleID() const;
85 Returns the lexicon ID of the result.
87 @return The lexicon identifier.
91 IMPORT_C TLexiconID LexiconID() const;
94 Returns the pronunciation ID of the result.
96 @return The pronunciation identifier.
100 IMPORT_C TPronunciationID PronunciationID() const;
104 CSDRule(TRuleID aRuleID, TLexiconID aLexiconID, TPronunciationID aPronunciationID);
108 TLexiconID iLexiconID;
109 TPronunciationID iPronunciationID;
117 Class to encapsulate a Speaker Dependent Grammar.
119 A grammar consists of a list of rules.
123 class CSDGrammar : public CBase
125 public:// Constructors and destructor
130 IMPORT_C ~CSDGrammar();
133 Instantiates an instance of CSDGrammar.
136 The grammar identifier.
138 @return A pointer to a CSDGrammar object.
140 IMPORT_C static CSDGrammar* NewL(TGrammarID aGrammarID);
143 Instantiates an instance of CSDGrammar and leaves a pointer on the cleanup stack.
146 The grammar identifier.
148 @return A pointer to CSDGrammar object.
150 IMPORT_C static CSDGrammar* NewLC(TGrammarID aGrammarID);
153 Returns the grammar ID of the result.
155 @return The grammar identifier.
159 IMPORT_C TGrammarID GrammarID() const;
162 Adds a rule to the grammar.
165 A reference to a CSDRule object.
167 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
168 another of the system-wide error codes.
172 IMPORT_C TInt Add(CSDRule& aRule);
175 Deletes a rule from the grammar.
178 The rule identifier to delete.
182 IMPORT_C void Delete(TRuleID aRuleID);
185 Returns a rule based at an index.
188 An index value. The value must not be negative and must not be greater than the number
189 of rules currently in the grammar, otherwise the function will panic.
191 @return A reference to a CSDRule object.
195 IMPORT_C const CSDRule& At(TInt aIndex) const;
198 Finds a rule in the grammar based on the rule ID.
203 @return The index of the first matching rule within the grammar. Returns KErrNotFound, if a
204 matching rule can not be found.
208 IMPORT_C TInt FindRule(TRuleID aRuleID) const;
211 Returns the number of rules in the grammar
213 @return The number of rules.
217 IMPORT_C TInt Count() const;
221 CSDGrammar(TGrammarID aGrammarID);
224 TGrammarID iGrammarID;
225 RPointerArray<CSDRule> iRuleArray;
233 Class to encapsulate a Speaker Dependent Pronunciation.
237 class CSDPronunciation : public CBase
239 public:// Constructors and destructor
244 IMPORT_C ~CSDPronunciation();
247 Instantiates an instance of CSDPronunciation.
249 @param aPronunciationID
250 The pronunciation identifier.
252 The model bank identifier.
254 The phoneme identifier.
256 @return A pointer to a CSDPronunciation object.
258 IMPORT_C static CSDPronunciation* NewL(TPronunciationID aPronunciationID, TModelBankID aModelBankID, TPhonemeID aPhonemeID);
261 Instantiates an instance of CSDPronunciation and leaves a pointer on the cleanup stack.
263 @param aPronunciationID
264 The pronunciation identifier.
266 The model bank identifier.
268 The phoneme identifier.
270 @return A pointer to a CSDPronunciation object.
272 IMPORT_C static CSDPronunciation* NewLC(TPronunciationID aPronunciationID, TModelBankID aModelBankID, TPhonemeID aPhonemeID);
275 Returns the pronunciation ID of this lexicon entry.
277 @return The pronunciation identifier.
281 IMPORT_C TPronunciationID PronunciationID() const;
284 Returns the ID of the model bank.
286 @return The model bank identifier.
290 IMPORT_C TModelBankID ModelBankID() const;
293 Returns the phoneme ID of this lexicon entry.
295 @return The phoneme identifier.
299 IMPORT_C TPhonemeID PhonemeID() const;
303 CSDPronunciation(TPronunciationID aPronunciationID, TModelBankID aModelBankID, TPhonemeID aPhonemeID);
306 TPronunciationID iPronunciationID;
307 TModelBankID iModelBankID;
308 TPhonemeID iPhonemeID;
316 Class to encapsulate a Speaker Dependent Lexicon.
320 class CSDLexicon : public CBase
322 public:// Constructors and destructor
327 IMPORT_C ~CSDLexicon();
330 Instantiates an instance of CSDLexicon.
333 The lexicon identifier.
335 @return A pointer to a CSDLexicon object.
337 IMPORT_C static CSDLexicon* NewL(TLexiconID aLexiconID);
340 Instantiates an instance of CSDGrammar and leaves a pointer on the cleanup stack.
343 The lexicon identifier.
345 @return A pointer to a CSDLexicon object.
347 IMPORT_C static CSDLexicon* NewLC(TLexiconID aLexiconID);
350 Returns the ID of the lexicon.
352 @return The lexicon identifier.
356 IMPORT_C TLexiconID LexiconID() const;
359 Adds a lexicon entry to the lexicon.
361 @param aPronunciation
362 A reference to a CSDPronunciation object.
364 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
365 another of the system-wide error codes.
369 IMPORT_C TInt Add(CSDPronunciation& aPronunciation);
372 Returns a pronunciation based at an index.
375 The pronunciation index. This value must not be negative and must not be greater than
376 the number of pronunciations currently in the lexicon, otherwise the function will
379 @return A reference to a CSDPronunciation object.
383 IMPORT_C const CSDPronunciation& At(TInt aIndex) const;
386 Finds a pronunciation based on the specified pronunciation ID.
388 @param aPronunciationID
389 The pronunciation identifier.
391 @return The index of the first matching pronunciation within the lexicon. Returns KErrNotFound,
392 if a matching pronunciation can not be found.
394 IMPORT_C TInt FindPronunciation(TPronunciationID aPronunciationID) const;
397 Returns the number of lexicon entries in the lexicon.
399 @return The number of pronunciations.
403 IMPORT_C TInt Count() const;
407 CSDLexicon(TLexiconID aLexiconID);
410 TLexiconID iLexiconID;
411 RPointerArray<CSDPronunciation> iPronunciationArray;
419 Class to encapsulate a Speaker Dependent Model created during the training process.
423 class CSDModel : public CBase
425 public:// Constructors and destructor
430 IMPORT_C ~CSDModel();
433 Instantiates an instance of a CSDModel.
435 @return A pointer to a CSDModel object.
437 IMPORT_C static CSDModel* NewL();
440 Instantiates an instance of a CSDModel.
442 @return A pointer to a CSDModel object.
444 IMPORT_C static CSDModel* NewLC();
447 Instantiates an instance of a CSDModel.
450 The phoneme identifier.
452 @return A pointer to a CSDModel object.
454 IMPORT_C static CSDModel* NewL(TPhonemeID aPhonemeID);
457 Instantiates an instance of a CSDModel.
460 The phoneme identifier.
462 @return A pointer to a CSDModel object.
464 IMPORT_C static CSDModel* NewLC(TPhonemeID aPhonemeID);
467 Sets the phoneme ID of this model.
470 The phoneme identifier.
474 IMPORT_C void SetPhonemeID(TPhonemeID aPhonemeID);
477 Returns the phoneme ID of this model.
479 @return The phoneme identifier.
483 IMPORT_C TPhonemeID PhonemeID() const;
486 Sets the acoustic model of the model.
488 @param aAcousticModel
489 A pointer descriptor containing the acoustic model (binary).
493 IMPORT_C void SetAcousticModel(TPtr8& aAcousticModel);
496 Gets a pointer to the acoustic model of this model.
498 @return A descriptor to the acoustic model data.
502 IMPORT_C const TDesC8& AcousticModel() const;
507 CSDModel(TPhonemeID aPhonemeID);
510 TPhonemeID iPhonemeID;
511 TPtr8 iAcousticModelPtr;
519 Class to encapsulate a Speaker Dependent Model Bank used by the recognizer during the
524 class CSDModelBank : public CBase
526 public:// Constructors and destructor
531 IMPORT_C ~CSDModelBank();
534 Instantiates an instance of a CSDModelBank.
537 The model bank identifier.
539 @return A pointer to a CSDModelBank object.
541 IMPORT_C static CSDModelBank* NewL(TModelBankID aModelBankID);
544 Instantiates an instance of a CSDModelBank and leaves a pointer on the cleanup stack.
547 The model bank identifier.
549 @return A pointer to a CSDModelBank object.
551 IMPORT_C static CSDModelBank* NewLC(TModelBankID aModelBankID);
554 Returns the model bank ID of the model bank.
556 @return The model bank identifier.
560 IMPORT_C TModelBankID ModelBankID() const;
563 Adds a model to the model bank.
566 The reference to CSDModel object.
568 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
569 another of the system-wide error codes.
573 IMPORT_C TInt Add(CSDModel& aModel);
576 Returns a model at the given index.
579 A reference to a CSDModel object.
581 @return The index of the first matching model within the model bank. Returns KErrNotFound, if a
582 matching model can not be found.
586 IMPORT_C const CSDModel& At(TInt aIndex) const;
589 Finds a model based on the specified phoneme ID.
594 @return The index of the first matching model within the model bank. Returns KErrNotFound, if a
595 matching model can not be found.
599 IMPORT_C TInt FindModel(TPhonemeID aPhonemeID) const;
602 Returns the number of models in the model bank.
604 @return The number of models in the model bank.
608 IMPORT_C TInt Count() const;
612 CSDModelBank(TModelBankID aModelBankID);
615 TModelBankID iModelBankID;
616 RPointerArray<CSDModel> iModelArray;
624 Class to encapsulate a Recognition Result
628 class CSDResult : public CBase
630 public:// Constructors and destructor
635 IMPORT_C ~CSDResult();
638 Instantiates an instance of a CSDResult.
640 @return A pointer to a CSDResult object.
642 IMPORT_C static CSDResult* NewL();
645 Instantiates an instance of CSDResult and leaves a pointer on the cleanup stack.
647 @return A pointer to a CSDResult object.
649 IMPORT_C static CSDResult* NewLC();
652 Instantiates an instance of a CSDResult.
655 The grammar identifier.
659 @return A pointer to a CSDResult object.
661 IMPORT_C static CSDResult* NewL(TGrammarID aGrammarID, TRuleID aRuleID);
664 Instantiates an instance of a CSDResult and leaves a pointer on the cleanup stack.
667 The grammar identifier.
671 @return A pointer to a CSDResult object.
673 IMPORT_C static CSDResult* NewLC(TGrammarID aGrammarID, TRuleID aRuleID);
676 Sets the grammar ID on the result.
679 The grammar identifier.
683 IMPORT_C void SetGrammarID(TGrammarID aGrammarID);
686 Returns the grammar ID of the result.
688 @return The grammar identifier.
692 IMPORT_C TGrammarID GrammarID() const;
695 Sets the rule ID of the result.
702 IMPORT_C void SetRuleID(TRuleID aRuleID);
705 Returns the rule ID of the result.
707 @return The rule identifier.
711 IMPORT_C TRuleID RuleID() const;
714 Sets the score for this result.
717 The score of this result.
721 IMPORT_C void SetScore(const TInt32 aScore);
724 Returns the score of this result.
726 @return The score of this result.
730 IMPORT_C TInt32 Score() const;
735 CSDResult(TGrammarID aGrammarID, TRuleID aRuleID);
738 TGrammarID iGrammarID;
748 CSDResultSet encapsulates a set of result objects returned by the recognizer at the end of the
749 recognition process. A result set may include additional diagnostic information for error analysis.
753 class CSDResultSet : public CBase
755 public:// Constructors and destructor
760 IMPORT_C ~CSDResultSet();
763 Instantiates an instance of CSDResultSet.
765 @return A pointer to a CSDResultSet object.
767 IMPORT_C static CSDResultSet* NewL();
770 Instantiates an instance of CSDResultSet and leaves a pointer on the cleanup stack.
772 @return A pointer to a CSDResultSet object.
774 IMPORT_C static CSDResultSet* NewLC();
777 Adds a result to the rule set.
780 A reference to the result object to be added.
782 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
783 another of the system-wide error codes.
787 IMPORT_C TInt Add(CSDResult& aResult);
790 Returns a result at a given index within the result set.
793 The index in the result set.
795 @return A reference to CSDResult object.
799 IMPORT_C const CSDResult& At(TInt aIndex);
802 Returns the number of results in the result set.
804 @return The number of results in the result set.
808 IMPORT_C TInt Count() const;
811 Sets the diagnostic of this result set.
814 A reference to the diagostic object.
818 IMPORT_C void SetDiagnostic(TDiagnostic& aDiagnostic);
821 Gets the diagnostic of this result set.
823 @return A reference to A TDiagnostic object.
827 IMPORT_C const TDiagnostic& Diagnostic() const;
834 RPointerArray<CSDResult> iResultArray;
835 TDiagnostic* iDiagnostic;