2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.Collections.Generic;
20 using System.Runtime.InteropServices;
21 using static Interop.Stt;
23 namespace Tizen.Uix.Stt
28 public enum ResultEvent
31 /// Event when the recognition full or last result is ready
35 /// Event when the recognition partial result is ready
39 /// Event when the recognition has failed
45 /// Enumeration representing the result message
47 public enum ResultMessage
54 /// Recognition failed because the speech started too soon.
58 /// Recognition failed because the speech is too short.
62 /// Recognition failed because the speech is too long.
66 /// Recognition failed because the speech is too quiet to listen.
70 /// Recognition failed because the speech is too loud to listen.
74 /// Recognition failed because the speech is too fast to listen.
80 /// Enumeration for the Token type
85 /// Event when the token is beginning type
89 /// Event when the token is middle type
93 /// Event when the token is end type
99 /// Enum for Error values that can occur
104 /// Successful, No error
116 /// Invalid parameter
120 /// No answer from the STT service
124 /// Device or resource busy
132 /// Permission denied
136 /// STT NOT supported
148 /// No available engine
156 /// Not supported feature of current engine
160 /// Recording timed out
164 /// No speech while recording
168 /// Progress to ready is not finished
172 /// Progress to recording is not finished
174 InProgressToRecording,
176 /// Progress to processing is not finished
178 InProgressToProcessing,
186 /// Enumeration for Recognition Types
188 public enum RecognitionType
191 /// Free form dictation
195 /// Continuous free dictation.
213 /// Enumeration for the State types
240 /// Enumeration for the Silence Detection types
242 public enum SilenceDetection
245 /// Silence detection type - False
249 /// Silence detection type - True
253 /// Silence detection type - Auto
259 /// A main function of Speech-To-Text (below STT) API recognizes sound data recorded by users.
260 /// After choosing a language, applications will start recording and recognizing.
261 /// After recording, the applications will receive the recognized result.
262 /// The STT has a client-server for the service of multi-applications.
263 /// The STT service always works in the background as a server. If the service is not working, client library will invoke it and client will communicate with it.
264 /// The service has engines and the recorder so client does not have the recorder itself. Only the client request commands to the STT service for using STT.
266 public class SttClient : IDisposable
268 private IntPtr _handle;
269 private Object thisLock = new Object();
270 private event EventHandler<RecognitionResultEventArgs> _recognitionResult;
271 private event EventHandler<StateChangedEventArgs> _stateChanged;
272 private event EventHandler<ErrorOccuredEventArgs> _errorOccured;
273 private event EventHandler<DefaultLanguageChangedEventArgs> _defaultLanguageChanged;
274 private event EventHandler<EngineChangedEventArgs> _engineChanged;
275 private bool disposedValue = false;
276 private Interop.Stt.RecognitionResultCallback _resultDelegate;
277 private Interop.Stt.StateChangedCallback _stateDelegate;
278 private Interop.Stt.ErrorCallback _errorDelegate;
279 private Interop.Stt.DefaultLanguageChangedCallback _languageDelegate;
280 private Interop.Stt.EngineChangedCallback _engineDelegate;
281 private ResultTime _result;
282 private ResultTimeCallback _resultTimeDelegate;
285 /// Constructor to create a STT instance.
288 /// http://tizen.org/privilege/recorder
290 /// <exception cref="InvalidOperationException">
291 /// This Exception can be due to the following reaons
293 /// 2. Operation Failed
294 /// 3. STT Not Supported
295 /// 4. Permission Denied
300 SttError error = SttCreate(out handle);
301 if (error != SttError.None)
303 Log.Error(LogTag, "Create Failed with error " + error);
304 throw ExceptionFactory.CreateException(error);
311 /// Event to be invoked when the recognition is done.
313 public event EventHandler<RecognitionResultEventArgs> RecognitionResult
319 _resultDelegate = (IntPtr handle, ResultEvent e, IntPtr data, int dataCount, IntPtr msg, IntPtr userData) =>
321 Log.Info(LogTag, "Recognition Result Event Triggered");
322 if (data != null && msg != null)
324 RecognitionResultEventArgs args = new RecognitionResultEventArgs(e, data, dataCount, Marshal.PtrToStringAnsi(msg));
325 _recognitionResult?.Invoke(this, args);
329 Log.Info(LogTag, "Recognition Result Event null received");
332 SttError error = SttSetRecognitionResultCB(_handle, _resultDelegate, IntPtr.Zero);
333 if (error != SttError.None)
335 Log.Error(LogTag, "Add RecognitionResult Failed with error " + error);
339 _recognitionResult += value;
348 SttError error = SttUnsetRecognitionResultCB(_handle);
349 if (error != SttError.None)
351 Log.Error(LogTag, "Remove RecognitionResult Failed with error " + error);
354 _recognitionResult -= value;
360 /// Event to be invoked when STT state changes.
362 public event EventHandler<StateChangedEventArgs> StateChanged
368 SttClient obj = this;
369 _stateDelegate = (IntPtr handle, State previous, State current, IntPtr userData) =>
371 StateChangedEventArgs args = new StateChangedEventArgs(previous, current);
372 _stateChanged?.Invoke(obj, args);
374 SttError error = SttSetStateChangedCB(_handle, _stateDelegate, IntPtr.Zero);
375 if (error != SttError.None)
377 Log.Error(LogTag, "Add StateChanged Failed with error " + error);
381 _stateChanged += value;
391 SttError error = SttUnsetStateChangedCB(_handle);
392 if (error != SttError.None)
394 Log.Error(LogTag, "Remove StateChanged Failed with error " + error);
397 _stateChanged -= value;
404 /// Event to be invoked when an error occurs.
406 public event EventHandler<ErrorOccuredEventArgs> ErrorOccured
412 _errorDelegate = (IntPtr handle, SttError reason, IntPtr userData) =>
414 ErrorOccuredEventArgs args = new ErrorOccuredEventArgs(handle, reason);
415 _errorOccured?.Invoke(this, args);
417 SttError error = SttSetErrorCB(_handle, _errorDelegate, IntPtr.Zero);
418 if (error != SttError.None)
420 Log.Error(LogTag, "Add ErrorOccured Failed with error " + error);
425 _errorOccured += value;
435 SttError error = SttUnsetErrorCB(_handle);
436 if (error != SttError.None)
438 Log.Error(LogTag, "Remove ErrorOccured Failed with error " + error);
441 _errorOccured -= value;
447 /// Event to be invoked when default laungage change.
449 public event EventHandler<DefaultLanguageChangedEventArgs> DefaultLanguageChanged
455 _languageDelegate = (IntPtr handle, IntPtr previousLanguage, IntPtr currentLanguage, IntPtr userData) =>
457 string previousLanguageString = Marshal.PtrToStringAnsi(previousLanguage);
458 string currentLanguageString = Marshal.PtrToStringAnsi(currentLanguage);
459 DefaultLanguageChangedEventArgs args = new DefaultLanguageChangedEventArgs(previousLanguageString, currentLanguageString);
460 _defaultLanguageChanged?.Invoke(this, args);
462 SttError error = SttSetDefaultLanguageChangedCB(_handle, _languageDelegate, IntPtr.Zero);
463 if (error != SttError.None)
465 Log.Error(LogTag, "Add DefaultLanguageChanged Failed with error " + error);
470 _defaultLanguageChanged += value;
480 SttError error = SttUnsetDefaultLanguageChangedCB(_handle);
481 if (error != SttError.None)
483 Log.Error(LogTag, "Remove DefaultLanguageChanged Failed with error " + error);
486 _defaultLanguageChanged -= value;
493 /// Event to be invoked to detect engine change.
495 public event EventHandler<EngineChangedEventArgs> EngineChanged
501 _engineDelegate = (IntPtr handle, IntPtr engineId, IntPtr language, bool supportSilence, bool needCredential, IntPtr userData) =>
503 string engineIdString = Marshal.PtrToStringAnsi(engineId);
504 string languageString = Marshal.PtrToStringAnsi(language);
505 EngineChangedEventArgs args = new EngineChangedEventArgs(engineIdString, languageString, supportSilence, needCredential);
506 _engineChanged?.Invoke(this, args);
508 SttError error = SttSetEngineChangedCB(_handle, _engineDelegate, IntPtr.Zero);
509 if (error != SttError.None)
511 Log.Error(LogTag, "Add EngineChanged Failed with error " + error);
515 _engineChanged += value;
524 SttError error = SttUnsetEngineChangedCB(_handle);
525 if (error != SttError.None)
527 Log.Error(LogTag, "Remove EngineChanged Failed with error " + error);
530 _engineChanged -= value;
536 /// Gets the default language set by the user.
537 /// The language is specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code.
538 /// For example, "ko_KR" for Korean, "en_US" for American English.
541 /// http://tizen.org/privilege/recorder
544 /// Default Lanaguage string value.
546 public string GetDefaultLanguage
553 SttError error = SttGetDefaultLanguage(_handle, out language);
554 if (error != SttError.None)
556 Log.Error(LogTag, "DefaultLanaguage Failed with error " + error);
566 /// Gets the microphone volume during recording.
569 /// http://tizen.org/privilege/recorder
572 /// The State must be Recording.
574 public float GetRecordingVolume
581 SttError error = SttGetRecordingVolume(_handle, out volume);
582 if (error != SttError.None)
584 Log.Error(LogTag, "GetRecordingVolume Failed with error " + error);
596 /// Gets the current STT state.
599 /// http://tizen.org/privilege/recorder
602 /// Current STT State value.
604 public State GetState
611 SttError error = SttGetState(_handle, out state);
612 if (error != SttError.None)
614 Log.Error(LogTag, "GetState Failed with error " + error);
615 return State.Unavailable;
625 /// This property can be used to get and set the current engine id.
627 /// <exception cref="InvalidOperationException">
628 /// This Exception can occur while setting due to the following reaons
630 /// 2. Operation Failed
631 /// 3. STT Not Supported
632 /// 4. Permission Denied
635 /// <exception cref="ArgumentException">
636 /// This can happen if Improper EngineId is provided while setting the value.
639 /// The State must be Created.
648 SttError error = SttGetEngine(_handle, out engineId);
649 if (error != SttError.None)
651 Log.Error(LogTag, "Get EngineId Failed with error " + error);
662 SttError error = SttSetEngine(_handle, value);
663 if (error != SttError.None)
665 Log.Error(LogTag, "Set EngineId Failed with error " + error);
666 throw ExceptionFactory.CreateException(error);
674 /// Retrieves the time stamp of the current recognition result
677 /// list of ResultTime
680 /// This function should only be called in RecognitionResult Event
682 /// <exception cref="InvalidOperationException">
683 /// This Exception can be due to the following reaons
684 /// 1. Opearation Failed.
685 /// 2. STT Not Supported
686 /// 3. Permission Denied.
688 public IEnumerable<ResultTime> GetDetailedResult()
690 List<ResultTime> list = new List<ResultTime>();
691 _resultTimeDelegate = (IntPtr handle, int index, TimeEvent e, IntPtr text, IntPtr startTime, IntPtr endTime, IntPtr userData) =>
693 _result = new ResultTime(index, e, Marshal.PtrToStringAnsi(text), (long)startTime, (long)endTime);
697 SttError error = SttForeachDetailedResult(_handle, _resultTimeDelegate, IntPtr.Zero);
698 if (error != SttError.None)
700 Log.Error(LogTag, "GetDetailedResult Failed with error " + error);
701 throw ExceptionFactory.CreateException(error);
708 /// Gets the private data from stt engine.
710 /// <param name="key">
714 /// The Data Corresponding to the Key provided
716 /// <exception cref="InvalidOperationException">
717 /// This Exception can be due to the following reaons
718 /// 1. No Answer from STT Service
719 /// 2. STT Not Supported
723 /// The State must be Ready.
725 public string GetPrivateData(string key)
730 SttError error = SttGetPrivateData(_handle, key, out data);
731 if (error != SttError.None)
733 Log.Error(LogTag, "GetPrivateData Failed with error " + error);
734 throw ExceptionFactory.CreateException(error);
742 /// Sets the private data to stt engine.
744 /// <param name="key">
747 /// <param name="data">
750 /// <exception cref="InvalidOperationException">
751 /// This Exception can be due to the following reaons
752 /// 1. No Answer from STT Service
753 /// 2. STT Not Supported
756 /// <exception cref="ArgumentException">
757 /// This can happen if Improper value is provided while setting the value.
760 /// The State must be Ready.
762 public void SetPrivateData(string key, string data)
766 SttError error = SttSetPrivateData(_handle, key, data);
767 if (error != SttError.None)
769 Log.Error(LogTag, "SetPrivateData Failed with error " + error);
770 throw ExceptionFactory.CreateException(error);
776 /// Gets the list of Supported Engine
779 /// IEnumerable<SupportedEngine> list of supported engines
781 /// <exception cref="InvalidOperationException">
782 /// This Exception can be due to the following reaons
784 /// 2. Operation Failed
785 /// 3. STT Not Supported
786 /// 4. Permission Denied
788 public IEnumerable<SupportedEngine> GetSupportedEngines()
790 List<SupportedEngine> engineList = new List<SupportedEngine>();
793 SupportedEngineCallback supportedEngineDelegate = (IntPtr handle, IntPtr engineId, IntPtr engineName, IntPtr userData) =>
795 string id = Marshal.PtrToStringAnsi(engineId);
796 string name = Marshal.PtrToStringAnsi(engineName);
797 SupportedEngine engine = new SupportedEngine(id, name);
798 engineList.Add(engine);
801 SttError error = SttForeEachSupportedEngines(_handle, supportedEngineDelegate, IntPtr.Zero);
802 if (error != SttError.None)
804 Log.Error(LogTag, "Create Failed with error " + error);
805 throw ExceptionFactory.CreateException(error);
813 /// Sets the app credential
815 /// <param name="credential">
816 /// The credential string
818 /// <exception cref="InvalidOperationException">
819 /// This Exception can be due to the following reaons
821 /// 2. Operation Failed
822 /// 3. STT Not Supported
823 /// 4. Permission Denied
826 /// <exception cref="ArgumentException">
827 /// This can happen if Improper value is provided while setting the value.
830 /// The State must be Created.
832 public void SetCredential(string credential)
836 SttError error = SttSetcredential(_handle, credential);
837 if (error != SttError.None)
839 Log.Error(LogTag, "SetCredential Failed with error " + error);
840 throw ExceptionFactory.CreateException(error);
846 /// Connects to the STT service asynchronously.
849 /// http://tizen.org/privilege/recorder
851 /// <exception cref="InvalidOperationException">
852 /// This Exception can be due to the following reasons
853 /// 1. STT Not Supported
854 /// 2. Permission Denied
858 /// The State must be Created.
861 /// If this function is successful, the STT state will be Ready
862 /// If this function is unsuccessful, ErrorOccured event will be invoked
864 public void Prepare()
868 SttError error = SttPrepare(_handle);
869 if (error != SttError.None)
871 Log.Error(LogTag, "SetEngine Failed with error " + error);
872 throw ExceptionFactory.CreateException(error);
878 /// Disconnects from the STT service.
881 /// http://tizen.org/privilege/recorder
883 /// <exception cref="InvalidOperationException">
884 /// This Exception can be due to the following reasons
885 /// 1. STT Not Supported
886 /// 2. Permission Denied
890 /// The State must be Ready.
893 /// If this function is successful, the STT state will be Created
895 public void Unprepare()
899 SttError error = SttUnprepare(_handle);
900 if (error != SttError.None)
902 Log.Error(LogTag, "Unprepare Failed with error " + error);
903 throw ExceptionFactory.CreateException(error);
909 /// Retrieves all supported languages of current engine.
910 /// The language is specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code.
911 /// For example, "ko_KR" for Korean, "en_US" for American English.
914 /// http://tizen.org/privilege/recorder
917 /// list of strings of supported languages.
919 /// <exception cref="InvalidOperationException">
920 /// This Exception can be due to the following reasons
921 /// 1. STT Not Supported
922 /// 2. Permission Denied
923 /// 3. Engine Not Found.
924 /// 4. Operation Failed.
926 public IEnumerable<string> GetSupportedLangauages()
928 List<string> languageList = new List<string>();
931 SupportedLanguageCallback supportedLanguageDelegate = (IntPtr handle, IntPtr language, IntPtr userData) =>
933 string lang = Marshal.PtrToStringAnsi(language);
934 languageList.Add(lang);
938 SttError error = SttForeachSupportedLanguages(_handle, supportedLanguageDelegate, IntPtr.Zero);
939 if (error != SttError.None)
941 Log.Error(LogTag, "GetSupportedLangauages Failed with error " + error);
942 throw ExceptionFactory.CreateException(error);
950 /// Checks whether the recognition type is supported.
953 /// http://tizen.org/privilege/recorder
955 /// <param name="type">
956 /// RecognitionType value.
959 /// bool value indicating whether the recognition type is supported.
961 /// <exception cref="InvalidOperationException">
962 /// This Exception can be due to the following reasons
963 /// 1. STT Not Supported
965 /// 3. Engine Not Found.
966 /// 4. Operation Failed.
969 /// The state should be Ready.
971 public bool IsRecognitionTypeSupported(RecognitionType type)
976 string recType = "stt.recognition.type.FREE";
979 case RecognitionType.Free:
981 recType = "stt.recognition.type.FREE";
985 case RecognitionType.Partial:
987 recType = "stt.recognition.type.FREE.PARTIAL";
991 case RecognitionType.Search:
993 recType = "stt.recognition.type.SEARCH";
997 case RecognitionType.WebSearch:
999 recType = "stt.recognition.type.WEB_SEARCH";
1003 case RecognitionType.Map:
1005 recType = "stt.recognition.type.MAP";
1011 SttError error = SttIsRecognitionTypeSupported(_handle, recType, out supported);
1012 if (error != SttError.None)
1014 Log.Error(LogTag, "IsRecognitionTypeSupported Failed with error " + error);
1015 throw ExceptionFactory.CreateException(error);
1024 /// Sets the silence detection.
1027 /// http://tizen.org/privilege/recorder
1029 /// <param name="type">
1030 /// SilenceDetection value.
1032 /// <exception cref="InvalidOperationException">
1033 /// This Exception can be due to the following reasons
1034 /// 1. STT Not Supported
1035 /// 2. Invalid State
1036 /// 3. Not supported feature of current engine.
1037 /// 4. Operation Failed.
1040 /// The state should be Ready.
1042 public void SetSilenceDetection(SilenceDetection type)
1046 SttError error = SttSetSilenceDetection(_handle, type);
1047 if (error != SttError.None)
1049 Log.Error(LogTag, "SetSilenceDetection Failed with error " + error);
1050 throw ExceptionFactory.CreateException(error);
1056 /// Sets the sound to start recording.
1057 /// Sound file type should be wav type.
1060 /// http://tizen.org/privilege/recorder
1062 /// <param name="filePath">
1063 /// File Path for the sound.
1065 /// <exception cref="InvalidOperationException">
1066 /// This Exception can be due to the following reasons
1067 /// 1. STT Not Supported.
1068 /// 2. Permission Denied.
1069 /// 3. Invalid State.
1070 /// 4. Operation Failed.
1072 /// <exception cref="ArgumentException">
1073 /// If an Invalid Parameter is provided.
1076 /// The state should be Ready.
1078 public void SetStartSound(string filePath)
1082 SttError error = SttSetStartSound(_handle, filePath);
1083 if (error != SttError.None)
1085 Log.Error(LogTag, "SetStartSound Failed with error " + error);
1086 throw ExceptionFactory.CreateException(error);
1092 /// Unsets the sound to start recording.
1095 /// http://tizen.org/privilege/recorder
1097 /// <exception cref="InvalidOperationException">
1098 /// This Exception can be due to the following reasons
1099 /// 1. STT Not Supported.
1100 /// 2. Permission Denied.
1101 /// 3. Invalid State.
1102 /// 4. Operation Failed.
1105 /// The state should be Ready.
1107 public void UnsetStartSound()
1111 SttError error = SttUnsetStartSound(_handle);
1112 if (error != SttError.None)
1114 Log.Error(LogTag, "UnsetStartSound Failed with error " + error);
1115 throw ExceptionFactory.CreateException(error);
1121 /// Sets the sound to stop recording.
1122 /// Sound file type should be wav type.
1125 /// http://tizen.org/privilege/recorder
1127 /// <param name="filePath">
1128 /// File Path for the sound.
1130 /// <exception cref="InvalidOperationException">
1131 /// This Exception can be due to the following reasons
1132 /// 1. STT Not Supported.
1133 /// 2. Permission Denied.
1134 /// 3. Invalid State.
1135 /// 4. Operation Failed.
1137 /// <exception cref="ArgumentException">
1138 /// If an Invalid Parameter is provided.
1141 /// The state should be Ready.
1143 public void SetStopSound(string filePath)
1147 SttError error = SttSetStopSound(_handle, filePath);
1148 if (error != SttError.None)
1150 Log.Error(LogTag, "SetStopSound Failed with error " + error);
1151 throw ExceptionFactory.CreateException(error);
1157 /// Unsets the sound to stop recording.
1160 /// http://tizen.org/privilege/recorder
1162 /// <exception cref="InvalidOperationException">
1163 /// This Exception can be due to the following reasons
1164 /// 1. STT Not Supported.
1165 /// 2. Permission Denied.
1166 /// 3. Invalid State.
1167 /// 4. Operation Failed.
1170 /// The state should be Ready.
1172 public void UnsetStopSound()
1176 SttError error = SttUnsetStopSound(_handle);
1177 if (error != SttError.None)
1179 Log.Error(LogTag, "UnsetStopSound Failed with error " + error);
1180 throw ExceptionFactory.CreateException(error);
1186 /// Starts recording and recognition asynchronously.
1187 /// This function starts recording in the STT service and sending recording data to engine.
1188 /// This work continues until Stop, Cancel or silence detected by engine
1191 /// http://tizen.org/privilege/recorder
1193 /// <param name="language">
1194 /// The language selected
1196 /// <param name="type">
1197 /// The type for recognition
1199 /// <exception cref="InvalidOperationException">
1200 /// This Exception can be due to the following reasons
1201 /// 1. STT Not Supported.
1202 /// 2. Permission Denied.
1203 /// 3. Invalid State.
1204 /// 4. Operation Failed.
1205 /// 5. Recorder Busy.
1206 /// 6. Progress to recording is not finished
1208 /// <exception cref="ArgumentException">
1209 /// If an Invalid Language is provided
1212 /// The state should be Ready.
1215 /// It will invoke StateChanged Event if registerd.
1216 /// If this function succeeds, the STT state will be Recording.
1217 /// If you call this function again before state changes, you will receive ErrorINProgressToRecording.
1218 /// </postcondition>
1219 public void Start(string language, RecognitionType type)
1223 string recType = "stt.recognition.type.FREE";
1226 case RecognitionType.Free:
1228 recType = "stt.recognition.type.FREE";
1232 case RecognitionType.Partial:
1234 recType = "stt.recognition.type.FREE.PARTIAL";
1238 case RecognitionType.Search:
1240 recType = "stt.recognition.type.SEARCH";
1244 case RecognitionType.WebSearch:
1246 recType = "stt.recognition.type.WEB_SEARCH";
1250 case RecognitionType.Map:
1252 recType = "stt.recognition.type.MAP";
1258 SttError error = SttStart(_handle, language, recType);
1259 if (error != SttError.None)
1261 Log.Error(LogTag, "Start Failed with error " + error);
1262 throw ExceptionFactory.CreateException(error);
1268 /// Finishes the recording and starts recognition processing in engine asynchronously.
1271 /// http://tizen.org/privilege/recorder
1273 /// <exception cref="InvalidOperationException">
1274 /// This Exception can be due to the following reasons
1275 /// 1. STT Not Supported.
1276 /// 2. Permission Denied.
1277 /// 3. Invalid State.
1278 /// 4. Operation Failed.
1279 /// 5. Progress to ready is not finished.
1280 /// 6. Progress to recording is not finished.
1281 /// 7. Progress to processing is not finished.
1284 /// The state should be Recording.
1287 /// It will invoke StateChanged Event if registerd.
1288 /// If this function succeeds, the STT state will be Processing.
1289 /// If you call this function again before state changes, you will receive ErrorINProgressToProcessing.
1290 /// After processing of engine, RecognitionResult event is invoked
1291 /// </postcondition>
1296 SttError error = SttStop(_handle);
1297 if (error != SttError.None)
1299 Log.Error(LogTag, "Stop Failed with error " + error);
1300 throw ExceptionFactory.CreateException(error);
1306 /// Cancels processing recognition and recording asynchronously.
1307 /// This function cancels recording and engine cancels recognition processing.
1308 /// After successful cancel, StateChanged event is invoked otherwise if error is occurred, ErrorOccured event is invoked.
1311 /// http://tizen.org/privilege/recorder
1313 /// <exception cref="InvalidOperationException">
1314 /// This Exception can be due to the following reasons
1315 /// 1. STT Not Supported.
1316 /// 2. Permission Denied.
1317 /// 3. Invalid State.
1318 /// 4. Operation Failed.
1319 /// 5. Progress to ready is not finished.
1320 /// 6. Progress to recording is not finished.
1321 /// 7. Progress to processing is not finished.
1324 /// The state should be Recording or Processing.
1327 /// It will invoke StateChanged Event if registerd.
1328 /// If this function succeeds, the STT state will be Ready.
1329 /// If you call this function again before state changes, you will receive ErrorINProgressToReady.
1330 /// </postcondition>
1331 public void Cancel()
1335 SttError error = SttCancel(_handle);
1336 if (error != SttError.None)
1338 Log.Error(LogTag, "Cancel Failed with error " + error);
1339 throw ExceptionFactory.CreateException(error);
1345 /// Method to release resources
1347 public void Dispose()
1352 protected virtual void Dispose(bool disposing)
1358 SttError error = SttDestroy(_handle);
1359 if (error != SttError.None)
1361 Log.Error(LogTag, "Destroy Failed with error " + error);
1365 disposedValue = true;