|
1 /* |
|
2 * Copyright (c) 2004 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: ARM hardware device for grammar compiling |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef ASRSGRCOMPILERHWDEVICE_H |
|
24 #define ASRSGRCOMPILERHWDEVICE_H |
|
25 |
|
26 // INCLUDES |
|
27 #include <asrshwdevice.h> |
|
28 #include <nsssispeechrecognitiondatadevasr.h> |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CAsrsGrCompilerAlgorithm; |
|
32 class CSDCompiledGrammar; // For future extensions; the class doesn't exist yet. |
|
33 class CSDLexicon; |
|
34 class CSDModelBank; |
|
35 class CSDResultSet; |
|
36 |
|
37 // CLASS DECLARATION |
|
38 /** |
|
39 * Callback class for Grammar Compiler. |
|
40 * |
|
41 * @lib asrgrcompilerhwdevice.lib |
|
42 * @since 2.8 |
|
43 */ |
|
44 class MASRSGrCompilerHwDeviceObserver |
|
45 { |
|
46 public: // New functions |
|
47 |
|
48 /** |
|
49 * Called after grammar compilation has finished or stopped. |
|
50 * @since 2.8 |
|
51 * @param aError KErrNone or a system-wide error code |
|
52 * @return none |
|
53 */ |
|
54 virtual void MghdoGrammarCompilerComplete(TInt aError) = 0; |
|
55 |
|
56 /** |
|
57 * Called after grammar combination has finished or stopped. |
|
58 * @since 2.8 |
|
59 * @param aResult The compiled grammar. Format dependes on the technology provider. |
|
60 * @param aError KErrNone or a system-wide error code |
|
61 * @return none |
|
62 */ |
|
63 virtual void MghdoGrammarCombinerComplete(HBufC8* aResult, TInt aError) = 0; |
|
64 |
|
65 /** |
|
66 * Combination and compilation operations require lexicons. To provide those |
|
67 * lexicons when needed, the client must implement these functions. |
|
68 * CASRGrCompilerHwDevice takes ownership of the data. |
|
69 * @since 2.8 |
|
70 * @param aID The lexicon identifier |
|
71 * @return The lexicon. CASRGrCompiler takes ownership. |
|
72 */ |
|
73 virtual CSILexicon* MghdoSILexiconL(TSILexiconID aID) = 0; |
|
74 |
|
75 /** |
|
76 * Callback function to load configuration data. |
|
77 * Client provides an implementation. |
|
78 * |
|
79 * @param aPackageType Type identifier. |
|
80 * @param aPackageID Package identifier. |
|
81 * @param aStartPosition First byte. |
|
82 * @param aEndPosition Last byte. If greater than the size of |
|
83 * the data, rest of the data is given. |
|
84 * @return Pointer to the data buffer, HW Device takes ownership. |
|
85 */ |
|
86 virtual HBufC8* MghdoConfigurationData( TUint32 aPackageType, |
|
87 TUint32 aPackageID, |
|
88 TUint32 aStartPosition = 0, |
|
89 TUint32 aEndPosition = KMaxTUint32 ) = 0; |
|
90 |
|
91 }; |
|
92 |
|
93 /** |
|
94 * Grammar compilation algortithms |
|
95 * |
|
96 * @lib asrgrcompilerhwdevice.lib |
|
97 * @since 2.8 |
|
98 */ |
|
99 class CASRSGrCompilerHwDevice : public CASRSHwDevice |
|
100 { |
|
101 public: // Constructors and destructor |
|
102 |
|
103 /** |
|
104 * Two-phased constructor. |
|
105 */ |
|
106 IMPORT_C static CASRSGrCompilerHwDevice* NewL( |
|
107 MASRSGrCompilerHwDeviceObserver& aObserver |
|
108 ); |
|
109 |
|
110 /** |
|
111 * Destructor. |
|
112 */ |
|
113 IMPORT_C virtual ~CASRSGrCompilerHwDevice(); |
|
114 |
|
115 public: // New functions |
|
116 |
|
117 /** |
|
118 * Compiles a speaker independent grammar. Asynchronous. |
|
119 * Callback is MghdoGrammarCompilerComplete. |
|
120 * @since 2.8 |
|
121 * @param aSICompiledGrammar The grammar to be compiled. |
|
122 * @return none |
|
123 */ |
|
124 IMPORT_C void CompileGrammarL( CSICompiledGrammar& aSICompiledGrammar ); |
|
125 |
|
126 /** |
|
127 * Combines several speaker independent grammars. The result is a combined grammar |
|
128 * in internal data format. |
|
129 * If some rules are excluded (blacklisted), then they are absent from the combined |
|
130 * grammar, but the compiled grammars are left untouched. |
|
131 * @since 2.8 |
|
132 * @param aCompiledGrammars Array of previously compiled grammar |
|
133 * @param aExcludedRules Rules to be blacklisted. |
|
134 * @return none |
|
135 */ |
|
136 IMPORT_C void CombineGrammarL(const RPointerArray<CSICompiledGrammar>& aCompiledGrammars, |
|
137 const RPointerArray<TSIRuleVariantInfo>& aExcludedRules); |
|
138 |
|
139 /** |
|
140 * Cancels grammar compilation. No callback is sent to the client. |
|
141 * @since 2.8 |
|
142 * @param none |
|
143 * @return none |
|
144 */ |
|
145 IMPORT_C void CancelCompilation(); |
|
146 |
|
147 /** |
|
148 * Cancels grammar combination. No callback is sent to the client. |
|
149 * @since 2.8 |
|
150 * @param none |
|
151 * @return none |
|
152 */ |
|
153 IMPORT_C void CancelCombination(); |
|
154 |
|
155 /** |
|
156 * Decodes an N-Best list from internal format into a recognition result. |
|
157 * @since 2.8 |
|
158 * @param aNBestIDs - N-Best result, as it came from the Recognition HW Device |
|
159 * @param aSIResultSet - Empty recognition result to be populated. |
|
160 * @param aSICompiledGrammar - The grammars, which were combined to get aCombinedGrammar |
|
161 * @param aCombinedData - The combined grammar, which was used in recognition |
|
162 * @return none |
|
163 */ |
|
164 IMPORT_C void ResolveResult(const RArray<TUint>& aNBestIDs, |
|
165 CSIResultSet& aSIResultSet, |
|
166 const RPointerArray<CSICompiledGrammar>& aSICompiledGrammar, |
|
167 const TDesC8& aCombinedData |
|
168 ) const; |
|
169 |
|
170 public: // Functions from base classes |
|
171 |
|
172 /** |
|
173 * From CASRSHwDevice |
|
174 * Retrieve a custom interface |
|
175 * @since 2.8 |
|
176 * @param aInterfaceId - UID of the interface |
|
177 * @return Pointer to a custom interface |
|
178 */ |
|
179 IMPORT_C TAny* CustomInterface(TUid aInterfaceId); |
|
180 |
|
181 /** |
|
182 * From CASRSHwDevice |
|
183 * Initializes the device. Subsequent calls reset the device. |
|
184 * @since 2.8 |
|
185 * @param none |
|
186 * @return none |
|
187 */ |
|
188 IMPORT_C void InitializeL(); |
|
189 |
|
190 /** |
|
191 * From CASRSHwDevice |
|
192 * Clears the device. |
|
193 * @since 2.8 |
|
194 * @param none |
|
195 * @return none |
|
196 */ |
|
197 IMPORT_C void ClearL(); |
|
198 |
|
199 private: |
|
200 |
|
201 /** |
|
202 * C++ default constructor. |
|
203 */ |
|
204 CASRSGrCompilerHwDevice(MASRSGrCompilerHwDeviceObserver& aObserver); |
|
205 |
|
206 /** |
|
207 * By default Symbian 2nd phase constructor is private. |
|
208 */ |
|
209 void ConstructL(); |
|
210 |
|
211 // Prohibit copy constructor if not deriving from CBase. |
|
212 CASRSGrCompilerHwDevice( const CASRSGrCompilerHwDevice& ); |
|
213 // Prohibit assigment operator if not deriving from CBase. |
|
214 CASRSGrCompilerHwDevice& operator=( const CASRSGrCompilerHwDevice& ); |
|
215 |
|
216 private: // Data |
|
217 |
|
218 // The observer |
|
219 MASRSGrCompilerHwDeviceObserver& iObserver; |
|
220 |
|
221 // Implementation-specific functions and data |
|
222 CAsrsGrCompilerAlgorithm *iAlgorithm; |
|
223 |
|
224 // Has Initialize() been called |
|
225 TBool iIsInitialised; |
|
226 |
|
227 // Reserved pointer for future extension. |
|
228 TAny* iReserved; |
|
229 }; |
|
230 |
|
231 #endif // ASRSGRCOMPILERHWDEVICE_H |
|
232 |
|
233 // End of File |