os/mm/mmdevicefw/speechrecogsupport/ASR/src/SpeechRecognitionUtility.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <e32base.h>
sl@0
    17
#include <mmf/common/mmfcontroller.h>
sl@0
    18
#include <mmf/common/speechrecognitioncustomcommands.h>
sl@0
    19
#include <mmf/common/speechrecognitiondataclient.h>
sl@0
    20
sl@0
    21
#include <speechrecognitionutility.h>
sl@0
    22
#include "SpeechRecognitionUtilityBody.h"
sl@0
    23
sl@0
    24
_LIT(KMMFSpeechPanicCategory, "SpeechClient");
sl@0
    25
GLDEF_C void Panic(TInt aError)
sl@0
    26
	{
sl@0
    27
	User::Panic(KMMFSpeechPanicCategory, aError);
sl@0
    28
	}
sl@0
    29
sl@0
    30
EXPORT_C CSpeechRecognitionUtility* CSpeechRecognitionUtility::NewL(MSpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver, TUid aClientUid)
sl@0
    31
	{
sl@0
    32
	CSpeechRecognitionUtility* s = CSpeechRecognitionUtility::NewLC(aSpeechRecognitionUtilityObserver, aClientUid);
sl@0
    33
	CleanupStack::Pop(s);
sl@0
    34
	return s;
sl@0
    35
	}
sl@0
    36
	
sl@0
    37
EXPORT_C CSpeechRecognitionUtility* CSpeechRecognitionUtility::NewLC(MSpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver, TUid aClientUid)
sl@0
    38
	{
sl@0
    39
	CSpeechRecognitionUtility* s = new(ELeave) CSpeechRecognitionUtility;
sl@0
    40
	CleanupStack::PushL(s);
sl@0
    41
	s->iBody = CSpeechRecognitionUtility::CBody::NewL(aClientUid, aSpeechRecognitionUtilityObserver);
sl@0
    42
	return s;	
sl@0
    43
	}
sl@0
    44
	
sl@0
    45
CSpeechRecognitionUtility::CSpeechRecognitionUtility()
sl@0
    46
	{
sl@0
    47
	}
sl@0
    48
sl@0
    49
EXPORT_C CSpeechRecognitionUtility::~CSpeechRecognitionUtility()
sl@0
    50
	{
sl@0
    51
	delete iBody;
sl@0
    52
	}
sl@0
    53
sl@0
    54
EXPORT_C TInt CSpeechRecognitionUtility::GetEngineProperties(const RArray<TInt>& aArray1, RArray<TInt>& aArray2)
sl@0
    55
	{
sl@0
    56
	ASSERT(iBody);
sl@0
    57
	return iBody->GetEngineProperties(aArray1, aArray2);
sl@0
    58
	}
sl@0
    59
sl@0
    60
EXPORT_C TInt CSpeechRecognitionUtility::AddPronunciation(TLexiconID aLexiconID, TModelBankID aModelBankID, TModelID aModelID, TPronunciationID& aPronunciationID)
sl@0
    61
	{
sl@0
    62
	ASSERT(iBody);
sl@0
    63
	return iBody->AddPronunciation(aLexiconID, aModelBankID, aModelID, aPronunciationID);
sl@0
    64
	}
sl@0
    65
sl@0
    66
EXPORT_C TInt CSpeechRecognitionUtility::AddRule(TGrammarID aGrammarID, TLexiconID aLexiconID, TPronunciationID aPronunciationID, TRuleID& aRuleID)
sl@0
    67
	{
sl@0
    68
	ASSERT(iBody);
sl@0
    69
	return iBody->AddRule(aGrammarID, aLexiconID, aPronunciationID, aRuleID);
sl@0
    70
	}
sl@0
    71
sl@0
    72
EXPORT_C void CSpeechRecognitionUtility::Cancel()
sl@0
    73
	{
sl@0
    74
	ASSERT(iBody);
sl@0
    75
	iBody->Cancel();
sl@0
    76
	}
sl@0
    77
sl@0
    78
EXPORT_C TInt CSpeechRecognitionUtility::CommitChanges()
sl@0
    79
	{
sl@0
    80
	ASSERT(iBody);
sl@0
    81
	return iBody->CommitChanges();
sl@0
    82
	}
sl@0
    83
sl@0
    84
EXPORT_C TInt CSpeechRecognitionUtility::CreateGrammar(TGrammarID& aGrammarID)
sl@0
    85
	{
sl@0
    86
	ASSERT(iBody);
sl@0
    87
	return iBody->CreateGrammar(aGrammarID);
sl@0
    88
	}
sl@0
    89
sl@0
    90
EXPORT_C TInt CSpeechRecognitionUtility::CreateLexicon(TLexiconID& aLexiconID)
sl@0
    91
	{
sl@0
    92
	ASSERT(iBody);
sl@0
    93
	return iBody->CreateLexicon(aLexiconID);
sl@0
    94
	}
sl@0
    95
sl@0
    96
EXPORT_C TInt CSpeechRecognitionUtility::LoadModels(TModelBankID aModelBankID)
sl@0
    97
	{
sl@0
    98
	ASSERT(iBody);
sl@0
    99
	return iBody->LoadModels(aModelBankID);
sl@0
   100
	}
sl@0
   101
sl@0
   102
EXPORT_C TInt CSpeechRecognitionUtility::LoadGrammar(TGrammarID aGrammarID)
sl@0
   103
	{
sl@0
   104
	ASSERT(iBody);
sl@0
   105
	return iBody->LoadGrammar(aGrammarID);
sl@0
   106
	}
sl@0
   107
sl@0
   108
EXPORT_C TInt CSpeechRecognitionUtility::LoadLexicon(TLexiconID aLexiconID)
sl@0
   109
	{
sl@0
   110
	ASSERT(iBody);
sl@0
   111
	return iBody->LoadLexicon(aLexiconID);
sl@0
   112
	}
sl@0
   113
sl@0
   114
EXPORT_C TInt CSpeechRecognitionUtility::GetUtteranceDuration(TModelBankID aModelBankID, TModelID aModelID, TTimeIntervalMicroSeconds32& aDuration)
sl@0
   115
	{
sl@0
   116
	ASSERT(iBody);
sl@0
   117
	return iBody->GetUtteranceDuration(aModelBankID, aModelID, aDuration);
sl@0
   118
	}
sl@0
   119
sl@0
   120
EXPORT_C TInt CSpeechRecognitionUtility::PlayUtterance(TModelBankID aModelBankID, TModelID aModelID)
sl@0
   121
	{
sl@0
   122
	ASSERT(iBody);
sl@0
   123
	return iBody->PlayUtterance(aModelBankID, aModelID);
sl@0
   124
	}
sl@0
   125
sl@0
   126
EXPORT_C TInt CSpeechRecognitionUtility::GetModelCount(TModelBankID aModelBankID, TInt& aModelCount)
sl@0
   127
	{
sl@0
   128
	ASSERT(iBody);
sl@0
   129
	return iBody->GetModelCount(aModelBankID, aModelCount);
sl@0
   130
	}
sl@0
   131
sl@0
   132
EXPORT_C TInt CSpeechRecognitionUtility::EndRecSession()
sl@0
   133
	{
sl@0
   134
	ASSERT(iBody);
sl@0
   135
	return iBody->EndRecSession();
sl@0
   136
	}
sl@0
   137
sl@0
   138
EXPORT_C TInt CSpeechRecognitionUtility::StartRecSession(TRecognitionMode aMode)
sl@0
   139
	{
sl@0
   140
	ASSERT(iBody);
sl@0
   141
	return iBody->StartRecSession(aMode);
sl@0
   142
	}
sl@0
   143
sl@0
   144
EXPORT_C TInt CSpeechRecognitionUtility::Recognize(CSDClientResultSet& aResultSet)
sl@0
   145
	{
sl@0
   146
	ASSERT(iBody);
sl@0
   147
	return iBody->Recognize(aResultSet);
sl@0
   148
	}
sl@0
   149
sl@0
   150
EXPORT_C TInt CSpeechRecognitionUtility::Record(TTimeIntervalMicroSeconds32 aRecordTime)
sl@0
   151
	{
sl@0
   152
	ASSERT(iBody);
sl@0
   153
	return iBody->Record(aRecordTime);
sl@0
   154
	}
sl@0
   155
sl@0
   156
EXPORT_C TInt CSpeechRecognitionUtility::RemoveGrammar(TGrammarID aGrammarID)
sl@0
   157
	{
sl@0
   158
	ASSERT(iBody);
sl@0
   159
	return iBody->RemoveGrammar(aGrammarID);
sl@0
   160
	}
sl@0
   161
sl@0
   162
EXPORT_C TInt CSpeechRecognitionUtility::RemovePronunciation(TLexiconID aLexiconID, TPronunciationID aPronunciationID)
sl@0
   163
	{
sl@0
   164
	ASSERT(iBody);
sl@0
   165
	return iBody->RemovePronunciation(aLexiconID, aPronunciationID);
sl@0
   166
	}
sl@0
   167
sl@0
   168
EXPORT_C TInt CSpeechRecognitionUtility::RemoveLexicon(TLexiconID aLexiconID)
sl@0
   169
	{
sl@0
   170
	ASSERT(iBody);
sl@0
   171
	return iBody->RemoveLexicon(aLexiconID);
sl@0
   172
	}
sl@0
   173
sl@0
   174
EXPORT_C TInt CSpeechRecognitionUtility::RemoveModel(TModelBankID aModelBankID, TModelID aModelID)
sl@0
   175
	{
sl@0
   176
	ASSERT(iBody);
sl@0
   177
	return iBody->RemoveModel(aModelBankID, aModelID);
sl@0
   178
	}
sl@0
   179
sl@0
   180
EXPORT_C TInt CSpeechRecognitionUtility::RemoveRule(TGrammarID aGrammarID, TRuleID aRuleID)
sl@0
   181
	{
sl@0
   182
	ASSERT(iBody);
sl@0
   183
	return iBody->RemoveRule(aGrammarID, aRuleID);
sl@0
   184
	}
sl@0
   185
EXPORT_C TInt CSpeechRecognitionUtility::Train(TModelBankID aModelBankID, TModelID& aModelID)
sl@0
   186
	{
sl@0
   187
	ASSERT(iBody);
sl@0
   188
	return iBody->Train(aModelBankID, aModelID);
sl@0
   189
	}
sl@0
   190
sl@0
   191
EXPORT_C TInt CSpeechRecognitionUtility::UnloadRule(TGrammarID aGrammarID, TRuleID aRuleID)
sl@0
   192
	{
sl@0
   193
	ASSERT(iBody);
sl@0
   194
	return iBody->UnloadRule(aGrammarID, aRuleID);
sl@0
   195
	}
sl@0
   196
sl@0
   197
EXPORT_C void CSpeechRecognitionUtility::SetEventHandler(MSpeechRecognitionUtilityObserver* aSpeechRecognitionUtilityObserver)
sl@0
   198
	{
sl@0
   199
	ASSERT(iBody);
sl@0
   200
	iBody->SetEventHandler(aSpeechRecognitionUtilityObserver);
sl@0
   201
	}
sl@0
   202
	
sl@0
   203
EXPORT_C TInt CSpeechRecognitionUtility::GetAllPronunciationIDs(TLexiconID aLexiconID, RArray <TPronunciationID>& aPronunciationIDs)
sl@0
   204
	{
sl@0
   205
	ASSERT(iBody);
sl@0
   206
	return iBody->GetAllPronunciationIDs(aLexiconID, aPronunciationIDs);
sl@0
   207
	}
sl@0
   208
sl@0
   209
EXPORT_C TInt CSpeechRecognitionUtility::GetAllModelIDs(TModelBankID aModelBankID, RArray <TModelID>& aModelIDs)
sl@0
   210
	{
sl@0
   211
	ASSERT(iBody);
sl@0
   212
	return iBody->GetAllModelIDs(aModelBankID, aModelIDs);
sl@0
   213
	}
sl@0
   214
sl@0
   215
sl@0
   216
EXPORT_C TInt CSpeechRecognitionUtility::GetAllRuleIDs(TGrammarID aGrammarID, RArray <TRuleID>& aRuleIDs)
sl@0
   217
	{
sl@0
   218
	ASSERT(iBody);
sl@0
   219
	return iBody->GetAllRuleIDs(aGrammarID, aRuleIDs);
sl@0
   220
	}
sl@0
   221
	
sl@0
   222
EXPORT_C TInt CSpeechRecognitionUtility::GetAllClientLexiconIDs(RArray <TLexiconID>& aLexiconIDs)
sl@0
   223
	{
sl@0
   224
	ASSERT(iBody);
sl@0
   225
	return iBody->GetAllClientLexiconIDs(aLexiconIDs);
sl@0
   226
	}
sl@0
   227
sl@0
   228
EXPORT_C TInt CSpeechRecognitionUtility::GetAllClientModelBankIDs(RArray <TModelBankID>& aModelBankIDs)
sl@0
   229
	{
sl@0
   230
	ASSERT(iBody);
sl@0
   231
	return iBody->GetAllClientModelBankIDs(aModelBankIDs);
sl@0
   232
	}
sl@0
   233
sl@0
   234
sl@0
   235
EXPORT_C TInt CSpeechRecognitionUtility::GetAllClientGrammarIDs(RArray <TGrammarID>& aGrammarIDs)
sl@0
   236
	{
sl@0
   237
	ASSERT(iBody);
sl@0
   238
	return iBody->GetAllClientGrammarIDs(aGrammarIDs);
sl@0
   239
	}
sl@0
   240
	
sl@0
   241
EXPORT_C TInt CSpeechRecognitionUtility::GetAllLexiconIDs(RArray <TLexiconID>& aLexiconIDs)
sl@0
   242
	{
sl@0
   243
	ASSERT(iBody);
sl@0
   244
	return iBody->GetAllLexiconIDs(aLexiconIDs);
sl@0
   245
	}
sl@0
   246
sl@0
   247
EXPORT_C TInt CSpeechRecognitionUtility::GetAllModelBankIDs(RArray <TModelBankID>& aModelBankIDs)
sl@0
   248
	{
sl@0
   249
	ASSERT(iBody);
sl@0
   250
	return iBody->GetAllModelBankIDs(aModelBankIDs);
sl@0
   251
	}
sl@0
   252
sl@0
   253
sl@0
   254
EXPORT_C TInt CSpeechRecognitionUtility::GetAllGrammarIDs(RArray <TGrammarID>& aGrammarIDs)
sl@0
   255
	{
sl@0
   256
	ASSERT(iBody);
sl@0
   257
	return iBody->GetAllGrammarIDs(aGrammarIDs);
sl@0
   258
	}
sl@0
   259
sl@0
   260
sl@0
   261
EXPORT_C TInt CSpeechRecognitionUtility::GetRuleValidity(TGrammarID aGrammarID, TRuleID aRuleID, TBool& aValid)
sl@0
   262
	{
sl@0
   263
	ASSERT(iBody);
sl@0
   264
	return iBody->GetRuleValidity(aGrammarID, aRuleID, aValid);
sl@0
   265
	} 
sl@0
   266
sl@0
   267
EXPORT_C TInt CSpeechRecognitionUtility::CreateModelBank(TModelBankID& aModelBankID)
sl@0
   268
	{
sl@0
   269
	ASSERT(iBody);
sl@0
   270
	return iBody->CreateModelBank(aModelBankID);
sl@0
   271
	}
sl@0
   272
EXPORT_C TInt CSpeechRecognitionUtility::RemoveModelBank(TModelBankID aModelBankID)
sl@0
   273
	{
sl@0
   274
	ASSERT(iBody);
sl@0
   275
	return iBody->RemoveModelBank(aModelBankID);
sl@0
   276
	}
sl@0
   277
sl@0
   278
EXPORT_C TInt CSpeechRecognitionUtility::GetAvailableStorage(TInt& aAvailableStorage) 
sl@0
   279
	{
sl@0
   280
	ASSERT(iBody);
sl@0
   281
	return iBody->GetAvailableStorage(aAvailableStorage);
sl@0
   282
	}
sl@0
   283
sl@0
   284
EXPORT_C TInt CSpeechRecognitionUtility::LoadEngineParameters(const RArray<TInt>& aParameterId, const RArray<TInt>& aParameterValue)
sl@0
   285
	{
sl@0
   286
	ASSERT(iBody);
sl@0
   287
	return iBody->LoadEngineParameters(aParameterId, aParameterValue);
sl@0
   288
	}
sl@0
   289
sl@0
   290
EXPORT_C TInt CSpeechRecognitionUtility::SetAudioPriority(TInt aPriority, TInt aTrainPreference, TInt aPlaybackPreference, TInt aRecognitionPreference)
sl@0
   291
	{
sl@0
   292
	ASSERT(iBody);
sl@0
   293
	return iBody->SetAudioPriority(aPriority, aTrainPreference, aPlaybackPreference, aRecognitionPreference);
sl@0
   294
	}
sl@0
   295
	
sl@0
   296
enum TDllReason {};
sl@0
   297
EXPORT_C TInt E32Dll(TDllReason /* aReason */)	
sl@0
   298
	{
sl@0
   299
	return (KErrNone);
sl@0
   300
	}