os/mm/mmdevicefw/speechrecogsupport/ASR/src/SpeechRecognitionUtility.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmdevicefw/speechrecogsupport/ASR/src/SpeechRecognitionUtility.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,300 @@
     1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <e32base.h>
    1.20 +#include <mmf/common/mmfcontroller.h>
    1.21 +#include <mmf/common/speechrecognitioncustomcommands.h>
    1.22 +#include <mmf/common/speechrecognitiondataclient.h>
    1.23 +
    1.24 +#include <speechrecognitionutility.h>
    1.25 +#include "SpeechRecognitionUtilityBody.h"
    1.26 +
    1.27 +_LIT(KMMFSpeechPanicCategory, "SpeechClient");
    1.28 +GLDEF_C void Panic(TInt aError)
    1.29 +	{
    1.30 +	User::Panic(KMMFSpeechPanicCategory, aError);
    1.31 +	}
    1.32 +
    1.33 +EXPORT_C CSpeechRecognitionUtility* CSpeechRecognitionUtility::NewL(MSpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver, TUid aClientUid)
    1.34 +	{
    1.35 +	CSpeechRecognitionUtility* s = CSpeechRecognitionUtility::NewLC(aSpeechRecognitionUtilityObserver, aClientUid);
    1.36 +	CleanupStack::Pop(s);
    1.37 +	return s;
    1.38 +	}
    1.39 +	
    1.40 +EXPORT_C CSpeechRecognitionUtility* CSpeechRecognitionUtility::NewLC(MSpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver, TUid aClientUid)
    1.41 +	{
    1.42 +	CSpeechRecognitionUtility* s = new(ELeave) CSpeechRecognitionUtility;
    1.43 +	CleanupStack::PushL(s);
    1.44 +	s->iBody = CSpeechRecognitionUtility::CBody::NewL(aClientUid, aSpeechRecognitionUtilityObserver);
    1.45 +	return s;	
    1.46 +	}
    1.47 +	
    1.48 +CSpeechRecognitionUtility::CSpeechRecognitionUtility()
    1.49 +	{
    1.50 +	}
    1.51 +
    1.52 +EXPORT_C CSpeechRecognitionUtility::~CSpeechRecognitionUtility()
    1.53 +	{
    1.54 +	delete iBody;
    1.55 +	}
    1.56 +
    1.57 +EXPORT_C TInt CSpeechRecognitionUtility::GetEngineProperties(const RArray<TInt>& aArray1, RArray<TInt>& aArray2)
    1.58 +	{
    1.59 +	ASSERT(iBody);
    1.60 +	return iBody->GetEngineProperties(aArray1, aArray2);
    1.61 +	}
    1.62 +
    1.63 +EXPORT_C TInt CSpeechRecognitionUtility::AddPronunciation(TLexiconID aLexiconID, TModelBankID aModelBankID, TModelID aModelID, TPronunciationID& aPronunciationID)
    1.64 +	{
    1.65 +	ASSERT(iBody);
    1.66 +	return iBody->AddPronunciation(aLexiconID, aModelBankID, aModelID, aPronunciationID);
    1.67 +	}
    1.68 +
    1.69 +EXPORT_C TInt CSpeechRecognitionUtility::AddRule(TGrammarID aGrammarID, TLexiconID aLexiconID, TPronunciationID aPronunciationID, TRuleID& aRuleID)
    1.70 +	{
    1.71 +	ASSERT(iBody);
    1.72 +	return iBody->AddRule(aGrammarID, aLexiconID, aPronunciationID, aRuleID);
    1.73 +	}
    1.74 +
    1.75 +EXPORT_C void CSpeechRecognitionUtility::Cancel()
    1.76 +	{
    1.77 +	ASSERT(iBody);
    1.78 +	iBody->Cancel();
    1.79 +	}
    1.80 +
    1.81 +EXPORT_C TInt CSpeechRecognitionUtility::CommitChanges()
    1.82 +	{
    1.83 +	ASSERT(iBody);
    1.84 +	return iBody->CommitChanges();
    1.85 +	}
    1.86 +
    1.87 +EXPORT_C TInt CSpeechRecognitionUtility::CreateGrammar(TGrammarID& aGrammarID)
    1.88 +	{
    1.89 +	ASSERT(iBody);
    1.90 +	return iBody->CreateGrammar(aGrammarID);
    1.91 +	}
    1.92 +
    1.93 +EXPORT_C TInt CSpeechRecognitionUtility::CreateLexicon(TLexiconID& aLexiconID)
    1.94 +	{
    1.95 +	ASSERT(iBody);
    1.96 +	return iBody->CreateLexicon(aLexiconID);
    1.97 +	}
    1.98 +
    1.99 +EXPORT_C TInt CSpeechRecognitionUtility::LoadModels(TModelBankID aModelBankID)
   1.100 +	{
   1.101 +	ASSERT(iBody);
   1.102 +	return iBody->LoadModels(aModelBankID);
   1.103 +	}
   1.104 +
   1.105 +EXPORT_C TInt CSpeechRecognitionUtility::LoadGrammar(TGrammarID aGrammarID)
   1.106 +	{
   1.107 +	ASSERT(iBody);
   1.108 +	return iBody->LoadGrammar(aGrammarID);
   1.109 +	}
   1.110 +
   1.111 +EXPORT_C TInt CSpeechRecognitionUtility::LoadLexicon(TLexiconID aLexiconID)
   1.112 +	{
   1.113 +	ASSERT(iBody);
   1.114 +	return iBody->LoadLexicon(aLexiconID);
   1.115 +	}
   1.116 +
   1.117 +EXPORT_C TInt CSpeechRecognitionUtility::GetUtteranceDuration(TModelBankID aModelBankID, TModelID aModelID, TTimeIntervalMicroSeconds32& aDuration)
   1.118 +	{
   1.119 +	ASSERT(iBody);
   1.120 +	return iBody->GetUtteranceDuration(aModelBankID, aModelID, aDuration);
   1.121 +	}
   1.122 +
   1.123 +EXPORT_C TInt CSpeechRecognitionUtility::PlayUtterance(TModelBankID aModelBankID, TModelID aModelID)
   1.124 +	{
   1.125 +	ASSERT(iBody);
   1.126 +	return iBody->PlayUtterance(aModelBankID, aModelID);
   1.127 +	}
   1.128 +
   1.129 +EXPORT_C TInt CSpeechRecognitionUtility::GetModelCount(TModelBankID aModelBankID, TInt& aModelCount)
   1.130 +	{
   1.131 +	ASSERT(iBody);
   1.132 +	return iBody->GetModelCount(aModelBankID, aModelCount);
   1.133 +	}
   1.134 +
   1.135 +EXPORT_C TInt CSpeechRecognitionUtility::EndRecSession()
   1.136 +	{
   1.137 +	ASSERT(iBody);
   1.138 +	return iBody->EndRecSession();
   1.139 +	}
   1.140 +
   1.141 +EXPORT_C TInt CSpeechRecognitionUtility::StartRecSession(TRecognitionMode aMode)
   1.142 +	{
   1.143 +	ASSERT(iBody);
   1.144 +	return iBody->StartRecSession(aMode);
   1.145 +	}
   1.146 +
   1.147 +EXPORT_C TInt CSpeechRecognitionUtility::Recognize(CSDClientResultSet& aResultSet)
   1.148 +	{
   1.149 +	ASSERT(iBody);
   1.150 +	return iBody->Recognize(aResultSet);
   1.151 +	}
   1.152 +
   1.153 +EXPORT_C TInt CSpeechRecognitionUtility::Record(TTimeIntervalMicroSeconds32 aRecordTime)
   1.154 +	{
   1.155 +	ASSERT(iBody);
   1.156 +	return iBody->Record(aRecordTime);
   1.157 +	}
   1.158 +
   1.159 +EXPORT_C TInt CSpeechRecognitionUtility::RemoveGrammar(TGrammarID aGrammarID)
   1.160 +	{
   1.161 +	ASSERT(iBody);
   1.162 +	return iBody->RemoveGrammar(aGrammarID);
   1.163 +	}
   1.164 +
   1.165 +EXPORT_C TInt CSpeechRecognitionUtility::RemovePronunciation(TLexiconID aLexiconID, TPronunciationID aPronunciationID)
   1.166 +	{
   1.167 +	ASSERT(iBody);
   1.168 +	return iBody->RemovePronunciation(aLexiconID, aPronunciationID);
   1.169 +	}
   1.170 +
   1.171 +EXPORT_C TInt CSpeechRecognitionUtility::RemoveLexicon(TLexiconID aLexiconID)
   1.172 +	{
   1.173 +	ASSERT(iBody);
   1.174 +	return iBody->RemoveLexicon(aLexiconID);
   1.175 +	}
   1.176 +
   1.177 +EXPORT_C TInt CSpeechRecognitionUtility::RemoveModel(TModelBankID aModelBankID, TModelID aModelID)
   1.178 +	{
   1.179 +	ASSERT(iBody);
   1.180 +	return iBody->RemoveModel(aModelBankID, aModelID);
   1.181 +	}
   1.182 +
   1.183 +EXPORT_C TInt CSpeechRecognitionUtility::RemoveRule(TGrammarID aGrammarID, TRuleID aRuleID)
   1.184 +	{
   1.185 +	ASSERT(iBody);
   1.186 +	return iBody->RemoveRule(aGrammarID, aRuleID);
   1.187 +	}
   1.188 +EXPORT_C TInt CSpeechRecognitionUtility::Train(TModelBankID aModelBankID, TModelID& aModelID)
   1.189 +	{
   1.190 +	ASSERT(iBody);
   1.191 +	return iBody->Train(aModelBankID, aModelID);
   1.192 +	}
   1.193 +
   1.194 +EXPORT_C TInt CSpeechRecognitionUtility::UnloadRule(TGrammarID aGrammarID, TRuleID aRuleID)
   1.195 +	{
   1.196 +	ASSERT(iBody);
   1.197 +	return iBody->UnloadRule(aGrammarID, aRuleID);
   1.198 +	}
   1.199 +
   1.200 +EXPORT_C void CSpeechRecognitionUtility::SetEventHandler(MSpeechRecognitionUtilityObserver* aSpeechRecognitionUtilityObserver)
   1.201 +	{
   1.202 +	ASSERT(iBody);
   1.203 +	iBody->SetEventHandler(aSpeechRecognitionUtilityObserver);
   1.204 +	}
   1.205 +	
   1.206 +EXPORT_C TInt CSpeechRecognitionUtility::GetAllPronunciationIDs(TLexiconID aLexiconID, RArray <TPronunciationID>& aPronunciationIDs)
   1.207 +	{
   1.208 +	ASSERT(iBody);
   1.209 +	return iBody->GetAllPronunciationIDs(aLexiconID, aPronunciationIDs);
   1.210 +	}
   1.211 +
   1.212 +EXPORT_C TInt CSpeechRecognitionUtility::GetAllModelIDs(TModelBankID aModelBankID, RArray <TModelID>& aModelIDs)
   1.213 +	{
   1.214 +	ASSERT(iBody);
   1.215 +	return iBody->GetAllModelIDs(aModelBankID, aModelIDs);
   1.216 +	}
   1.217 +
   1.218 +
   1.219 +EXPORT_C TInt CSpeechRecognitionUtility::GetAllRuleIDs(TGrammarID aGrammarID, RArray <TRuleID>& aRuleIDs)
   1.220 +	{
   1.221 +	ASSERT(iBody);
   1.222 +	return iBody->GetAllRuleIDs(aGrammarID, aRuleIDs);
   1.223 +	}
   1.224 +	
   1.225 +EXPORT_C TInt CSpeechRecognitionUtility::GetAllClientLexiconIDs(RArray <TLexiconID>& aLexiconIDs)
   1.226 +	{
   1.227 +	ASSERT(iBody);
   1.228 +	return iBody->GetAllClientLexiconIDs(aLexiconIDs);
   1.229 +	}
   1.230 +
   1.231 +EXPORT_C TInt CSpeechRecognitionUtility::GetAllClientModelBankIDs(RArray <TModelBankID>& aModelBankIDs)
   1.232 +	{
   1.233 +	ASSERT(iBody);
   1.234 +	return iBody->GetAllClientModelBankIDs(aModelBankIDs);
   1.235 +	}
   1.236 +
   1.237 +
   1.238 +EXPORT_C TInt CSpeechRecognitionUtility::GetAllClientGrammarIDs(RArray <TGrammarID>& aGrammarIDs)
   1.239 +	{
   1.240 +	ASSERT(iBody);
   1.241 +	return iBody->GetAllClientGrammarIDs(aGrammarIDs);
   1.242 +	}
   1.243 +	
   1.244 +EXPORT_C TInt CSpeechRecognitionUtility::GetAllLexiconIDs(RArray <TLexiconID>& aLexiconIDs)
   1.245 +	{
   1.246 +	ASSERT(iBody);
   1.247 +	return iBody->GetAllLexiconIDs(aLexiconIDs);
   1.248 +	}
   1.249 +
   1.250 +EXPORT_C TInt CSpeechRecognitionUtility::GetAllModelBankIDs(RArray <TModelBankID>& aModelBankIDs)
   1.251 +	{
   1.252 +	ASSERT(iBody);
   1.253 +	return iBody->GetAllModelBankIDs(aModelBankIDs);
   1.254 +	}
   1.255 +
   1.256 +
   1.257 +EXPORT_C TInt CSpeechRecognitionUtility::GetAllGrammarIDs(RArray <TGrammarID>& aGrammarIDs)
   1.258 +	{
   1.259 +	ASSERT(iBody);
   1.260 +	return iBody->GetAllGrammarIDs(aGrammarIDs);
   1.261 +	}
   1.262 +
   1.263 +
   1.264 +EXPORT_C TInt CSpeechRecognitionUtility::GetRuleValidity(TGrammarID aGrammarID, TRuleID aRuleID, TBool& aValid)
   1.265 +	{
   1.266 +	ASSERT(iBody);
   1.267 +	return iBody->GetRuleValidity(aGrammarID, aRuleID, aValid);
   1.268 +	} 
   1.269 +
   1.270 +EXPORT_C TInt CSpeechRecognitionUtility::CreateModelBank(TModelBankID& aModelBankID)
   1.271 +	{
   1.272 +	ASSERT(iBody);
   1.273 +	return iBody->CreateModelBank(aModelBankID);
   1.274 +	}
   1.275 +EXPORT_C TInt CSpeechRecognitionUtility::RemoveModelBank(TModelBankID aModelBankID)
   1.276 +	{
   1.277 +	ASSERT(iBody);
   1.278 +	return iBody->RemoveModelBank(aModelBankID);
   1.279 +	}
   1.280 +
   1.281 +EXPORT_C TInt CSpeechRecognitionUtility::GetAvailableStorage(TInt& aAvailableStorage) 
   1.282 +	{
   1.283 +	ASSERT(iBody);
   1.284 +	return iBody->GetAvailableStorage(aAvailableStorage);
   1.285 +	}
   1.286 +
   1.287 +EXPORT_C TInt CSpeechRecognitionUtility::LoadEngineParameters(const RArray<TInt>& aParameterId, const RArray<TInt>& aParameterValue)
   1.288 +	{
   1.289 +	ASSERT(iBody);
   1.290 +	return iBody->LoadEngineParameters(aParameterId, aParameterValue);
   1.291 +	}
   1.292 +
   1.293 +EXPORT_C TInt CSpeechRecognitionUtility::SetAudioPriority(TInt aPriority, TInt aTrainPreference, TInt aPlaybackPreference, TInt aRecognitionPreference)
   1.294 +	{
   1.295 +	ASSERT(iBody);
   1.296 +	return iBody->SetAudioPriority(aPriority, aTrainPreference, aPlaybackPreference, aRecognitionPreference);
   1.297 +	}
   1.298 +	
   1.299 +enum TDllReason {};
   1.300 +EXPORT_C TInt E32Dll(TDllReason /* aReason */)	
   1.301 +	{
   1.302 +	return (KErrNone);
   1.303 +	}