|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef NSSVASSIUTILITYWRAPPER_H |
|
20 #define NSSVASSIUTILITYWRAPPER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <nsssispeechrecognitiondataclient.h> |
|
25 #include <nsssispeechrecognitionutilityobserver.h> |
|
26 #include <nsssiutilitybase.h> |
|
27 |
|
28 // CLASS DECLARATION |
|
29 |
|
30 /** |
|
31 * CNssSiUtilityWrapper |
|
32 * @since 3.1 |
|
33 * @see nsssispeechrecognitionutility.h |
|
34 * @see nsssispeechrecognitionutilityobserver.h |
|
35 * @see nsssiutilitybase.h |
|
36 */ |
|
37 NONSHARABLE_CLASS ( CNssSiUtilityWrapper ) : public CActive, |
|
38 public MSISpeechRecognitionUtilityObserver |
|
39 { |
|
40 public: // Constructors & destructor |
|
41 |
|
42 /** |
|
43 * Two-phased constructor |
|
44 * |
|
45 * @since 3.1 |
|
46 */ |
|
47 static CNssSiUtilityWrapper* NewL( MSISpeechRecognitionUtilityObserver& aObserver, |
|
48 TUid aClientUid ); |
|
49 |
|
50 /** |
|
51 * Destructor. |
|
52 */ |
|
53 virtual ~CNssSiUtilityWrapper(); |
|
54 |
|
55 public: // New functions |
|
56 |
|
57 /** |
|
58 * |
|
59 * Adapts the speaker independent models to a specific speaker's voice. |
|
60 * |
|
61 * @since 2.8 |
|
62 * @param aResultSet Recognition result N-Best |
|
63 * @param aCorrect Index to N-Best pointing the correct result. |
|
64 * @return system wide error code |
|
65 */ |
|
66 TInt Adapt( const CSIClientResultSet& aResultSet, |
|
67 TInt aCorrect ); |
|
68 |
|
69 /** |
|
70 * Adds a new rules for the given phrases into the |
|
71 * specified grammar. |
|
72 * |
|
73 * @param aTextArrayArray Array of text arrays. The phrase k is the concatenation |
|
74 * of texts in array k. |
|
75 * @param aLanguageArray pronunciations will be generated for these languages |
|
76 * @param aLexiconID lexicon, where to add pronunciations |
|
77 * @param aGrammarID grammar, where to add rules |
|
78 * @param aRuleID the ID of the rule will be placed on this variable. |
|
79 * If some of the names fail while others succeed, |
|
80 * KInvalidRuleID will be placed to the array. |
|
81 * @return system wide error code |
|
82 */ |
|
83 TInt AddVoiceTags( const RPointerArray<MDesCArray> &aTextArrayArray, |
|
84 const RArray<TLanguage> &aLanguageArray, |
|
85 TSILexiconID aLexiconID, |
|
86 TSIGrammarID aGrammarID, |
|
87 RArray<TSIRuleID>& aRuleIDArray ); |
|
88 |
|
89 /** |
|
90 * Adds a new rules for the given phrases into the |
|
91 * specified grammar. |
|
92 * |
|
93 * @param aTextArrayArray Array of text arrays. The phrase k is the concatenation |
|
94 * of texts in array k. |
|
95 * @param aLanguageArray pronunciations will be generated for these languages |
|
96 * @param aLexiconID lexicon, where to add pronunciations |
|
97 * @param aGrammarID grammar, where to add rules |
|
98 * @param aRuleID the ID of the rule will be placed on this variable. |
|
99 * If some of the names fail while others succeed, |
|
100 * KInvalidRuleID will be placed to the array. |
|
101 * @return System wide error code |
|
102 */ |
|
103 TInt AddVoiceTags( const RPointerArray<MDesCArray>& aTextArrayArray, |
|
104 const RArray<RLanguageArray>& aLanguageArray, |
|
105 TSILexiconID aLexiconID, |
|
106 TSIGrammarID aGrammarID, |
|
107 RArray<TSIRuleID>& aRuleIDArray ); |
|
108 |
|
109 /** |
|
110 * Cancels the current operation |
|
111 */ |
|
112 void CancelUtility(); |
|
113 |
|
114 /** |
|
115 * Saves the changes into a permanent storage. |
|
116 * |
|
117 * @return System-wide errors |
|
118 */ |
|
119 TInt CommitChanges(); |
|
120 |
|
121 /** |
|
122 * Creates a new grammar. |
|
123 */ |
|
124 TInt CreateGrammar( TSIGrammarID& aGrammarID ); |
|
125 |
|
126 /** |
|
127 * Creates a new lexicon. |
|
128 */ |
|
129 TInt CreateLexicon( TSILexiconID& aLexiconID ); |
|
130 |
|
131 /** |
|
132 * Creates a new model bank. |
|
133 * @param aModelBankID reference where a new model |
|
134 * bank Id is assigned to |
|
135 * @return system wide error codes |
|
136 */ |
|
137 TInt CreateModelBank( TSIModelBankID& aModelBankID ); |
|
138 |
|
139 /** |
|
140 * Ends the current recognition session. Resources allocated |
|
141 * for recognition are freed. |
|
142 * @param aModelBankID reference where a new model bank Id is |
|
143 * assigned to |
|
144 * @return system wide error codes |
|
145 */ |
|
146 TInt EndRecSession(); |
|
147 |
|
148 /** |
|
149 * |
|
150 * Loads the specified grammar into the recognizer; |
|
151 * done prior to recognition. |
|
152 * @param aGrammarID grammar ID |
|
153 * @return system wide error codes |
|
154 */ |
|
155 TInt LoadGrammar( TSIGrammarID aGrammarID ); |
|
156 |
|
157 /** |
|
158 * |
|
159 * Loads the specified model bank into the recognizer; |
|
160 * done prior to recognition.. |
|
161 * @param ModelBankID model bank Id |
|
162 * @return system wide error codes |
|
163 */ |
|
164 TInt LoadModels( TSIModelBankID aModelBankID ); |
|
165 |
|
166 |
|
167 /** |
|
168 * Records uder utterance for training and recognition. |
|
169 * @param aRecordTime recording time in microseconds |
|
170 * @return system wide error codes |
|
171 */ |
|
172 TInt Record( TTimeIntervalMicroSeconds32 aRecordTime ); |
|
173 |
|
174 /** |
|
175 * Pre-starts samping before Record call. |
|
176 * |
|
177 * @since 3.2 |
|
178 * @return System wide error code |
|
179 */ |
|
180 TInt PreStartSampling(); |
|
181 |
|
182 /** |
|
183 * Initiates speaker independent recognition; performed |
|
184 * following loading of model bank, lexicon, and grammar. |
|
185 * |
|
186 * @param aResultSet reference where the recognition |
|
187 * result is set |
|
188 * @return system wide error codes |
|
189 */ |
|
190 TInt Recognize( CSIClientResultSet& aResultSet ); |
|
191 |
|
192 /** |
|
193 * Removes the specified grammar from the permanent storage. |
|
194 * Removing a grammar will remove all rules within the grammar. |
|
195 * |
|
196 * @param aGrammarID grammar Id |
|
197 * @return system wide error codes |
|
198 */ |
|
199 TInt RemoveGrammar( TSIGrammarID aGrammarID ); |
|
200 |
|
201 /** |
|
202 * Removes the specified lexicon from the permanent storage. |
|
203 * Removing a lexicon will remove all pronunciations within the |
|
204 * lexicon. |
|
205 * |
|
206 * @param aLexiconID lexicon Id |
|
207 * @return system wide error codes |
|
208 */ |
|
209 TInt RemoveLexicon( TSILexiconID aLexiconID ); |
|
210 |
|
211 |
|
212 /** |
|
213 * Removes the specified model bank from the permanent storage. |
|
214 * Removing a model bank will remove all models within the model bank. |
|
215 * |
|
216 * @param aModelBankID model bank Id |
|
217 * @return system wide error codes |
|
218 */ |
|
219 TInt RemoveModelBank( TSIModelBankID aModelBankID ); |
|
220 |
|
221 /** |
|
222 * Removes the specified rule from the specified grammar permanently. |
|
223 * |
|
224 * @param aGrammarID grammar Id |
|
225 * @param aRuleID rule Id |
|
226 * @return system wide error codes |
|
227 */ |
|
228 TInt RemoveRule( TSIGrammarID aGrammarID, TSIRuleID aRuleID ); |
|
229 |
|
230 /** |
|
231 * Removes multiple rules from the specified grammar permanently. |
|
232 * |
|
233 * @param aGrammarID grammar Id |
|
234 * @param aRuleID rule Id |
|
235 * @return system wide error codes |
|
236 */ |
|
237 TInt RemoveRules( TSIGrammarID aGrammarID, RArray<TSIRuleID>& aRuleIDs ); |
|
238 |
|
239 /** |
|
240 * Set the audio priority and preference for train, playback |
|
241 * and recognition |
|
242 * |
|
243 * @param aPriority priority for voice recognition |
|
244 * @param aTrainPreference preference for training |
|
245 * @param aPlaybackPreference preference for playback |
|
246 * @param aRecognitionPreference preference for recognition |
|
247 * @return system wide error codes |
|
248 */ |
|
249 TInt SetAudioPriority( TInt aPriority, TInt aTrainPreference, |
|
250 TInt aPlaybackPreference, TInt aRecognitionPreference ); |
|
251 |
|
252 /** |
|
253 * Set the event handler for asynchronous events |
|
254 * |
|
255 * @param aSpeechRecognitionUtilityObserver pointer to observer |
|
256 */ |
|
257 void SetEventHandler( MSISpeechRecognitionUtilityObserver* |
|
258 aSpeechRecognitionUtilityObserver ); |
|
259 |
|
260 |
|
261 /** |
|
262 * Starts a new recognition session. |
|
263 * |
|
264 * @param aMode recognition mode |
|
265 * @return system wide error codes |
|
266 */ |
|
267 TInt StartRecSession( TNSSRecognitionMode aMode ); |
|
268 |
|
269 |
|
270 /** |
|
271 * Unloads the specified rule from the specified grammar |
|
272 * in temporary memory, previously loaded with LoadGrammarL. |
|
273 * The rule in the permanent storage remains intact. |
|
274 * |
|
275 * @param aGrammarID grammar Id |
|
276 * @param aRuleID rule Id |
|
277 * @return system wide error codes |
|
278 */ |
|
279 TInt UnloadRule( TSIGrammarID aGrammarID, TSIRuleID aRuleID ); |
|
280 |
|
281 |
|
282 private: // Functions |
|
283 |
|
284 /** |
|
285 * C++ constructor. |
|
286 */ |
|
287 CNssSiUtilityWrapper( MSISpeechRecognitionUtilityObserver& iObserver, TUid aClientUid ); |
|
288 |
|
289 /** |
|
290 * EPOC constructor. |
|
291 */ |
|
292 void ConstructL(); |
|
293 |
|
294 /** |
|
295 * From CActive |
|
296 */ |
|
297 void RunL(); |
|
298 |
|
299 /** |
|
300 * From CActive |
|
301 */ |
|
302 void DoCancel(); |
|
303 |
|
304 /** |
|
305 * Sets the active object ready to be run |
|
306 */ |
|
307 void Ready(); |
|
308 |
|
309 /** |
|
310 * From MSISpeechRecognitionUtilityObserver |
|
311 */ |
|
312 void MsruoEvent( TUid aEvent, TInt aResult ); |
|
313 |
|
314 private: // Member variables |
|
315 |
|
316 // Handle to library loader |
|
317 RLibrary iLib; |
|
318 |
|
319 // UID of the client |
|
320 TUid iClientUid; |
|
321 |
|
322 // Utility API |
|
323 MSISpeechRecognitionUtilityBase* iUtility; |
|
324 |
|
325 // Reference to callback handler |
|
326 MSISpeechRecognitionUtilityObserver& iObserver; |
|
327 |
|
328 // Stored callback parameters |
|
329 TUid iEvent; |
|
330 TInt iResult; |
|
331 }; |
|
332 |
|
333 #endif // NSSVASSIUTILITYWRAPPER_H |
|
334 |
|
335 // End of file |