<Compile Include="Interop\Interop.Libraries.cs" />
<Compile Include="Interop\Interop.VoiceControlCommand.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\RecognitionResult.cs" />
<Compile Include="Tizen.Uix.VoiceControl\VoiceCommand.cs" />
<Compile Include="Tizen.Uix.VoiceControl\VoiceCommandList.cs" />
<Compile Include="Tizen.Uix.VoiceControl\VoiceControlClient.cs" />
--- /dev/null
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using static Interop.VoiceControl;
+using static Interop.VoiceControlCommand;
+
+namespace Tizen.Uix.VoiceControl
+{
+ /// <summary>
+ /// The recognition result from the engine.
+ /// If the duplicated commands are recognized, the event(e.g. Result.Rejected) of command may be rejected
+ /// for selecting command as priority.If you set similar or same commands or the recognized results are multi-results, CommandList has the multi commands.
+ /// </summary>
+ public class RecognitionResult
+ {
+ private ResultEvent _resultEvent;
+ private VoiceCommandList _list;
+ private string _result;
+
+ internal RecognitionResult(ResultEvent evt, IntPtr cmdList, IntPtr result)
+ {
+ _resultEvent = evt;
+ SafeCommandListHandle handle = new SafeCommandListHandle(cmdList);
+ _list = new VoiceCommandList(handle);
+ _result = Marshal.PtrToStringAnsi(result);
+ }
+
+ /// <summary>
+ /// The result event
+ /// </summary>
+ public ResultEvent Result
+ {
+ get
+ {
+ return _resultEvent;
+ }
+ }
+
+ /// <summary>
+ /// The spoken text
+ /// </summary>
+ public string ResultMessage
+ {
+ get
+ {
+ return _result;
+ }
+ }
+
+
+ /// <summary>
+ /// The recognized command list
+ /// </summary>
+ public VoiceCommandList CommandList
+ {
+ get
+ {
+ return _list;
+ }
+ }
+ }
+}
*/
using System;
-using System.Collections.Generic;
-using System.Runtime.InteropServices;
-using static Interop.VoiceControl;
-using static Interop.VoiceControlCommand;
namespace Tizen.Uix.VoiceControl
{
/// <summary>
/// The recognition result from the engine.
- /// If the duplicated commands are recognized, the event(e.g. Result.Rejected) of command may be rejected
- /// for selecting command as priority.If you set similar or same commands or the recognized results are multi-results, CommandList has the multi commands.
/// </summary>
- public class RecognitionResultEventArgs
+ public class RecognitionResultEventArgs : EventArgs
{
- private ResultEvent _resultEvent;
- private VoiceCommandList _list;
- private string _result;
-
- internal RecognitionResultEventArgs(ResultEvent evt, IntPtr cmdList, IntPtr result)
+ private RecognitionResult _result;
+ internal RecognitionResultEventArgs(RecognitionResult result)
{
- _resultEvent = evt;
- SafeCommandListHandle handle = new SafeCommandListHandle(cmdList);
- _list = new VoiceCommandList(handle);
- _result = Marshal.PtrToStringAnsi(result);
- }
-
- /// <summary>
- /// The result event
- /// </summary>
- public ResultEvent Result
- {
- get
- {
- return _resultEvent;
- }
+ _result = result;
}
/// <summary>
- /// The spoken text
+ /// Gets the Recognition result
/// </summary>
- public string ResultMessage
+ public RecognitionResult Result
{
get
{
}
}
-
- /// <summary>
- /// The recognized command list
- /// </summary>
- public VoiceCommandList CommandList
- {
- get
- {
- return _list;
- }
- }
}
}
private static List<string> s_supportedLanguages;
private static VcSupportedLanguageCb s_supportedLanguagesCb;
private static VcResultCb s_resultCb;
+ private static RecognitionResult s_recognitionResult;
/// <summary>
/// Gets current language.
/// <precondition>
/// The State should be Ready or Initialized
/// </precondition>
- public static IEnumerable<string> GetSupportedLangauges()
+ public static IEnumerable<string> GetSupportedLanguages()
{
s_supportedLanguages = new List<string>();
s_supportedLanguagesCb = (IntPtr language, IntPtr userData) =>
ErrorCode error = VcForeachSupportedLanguages(s_supportedLanguagesCb, IntPtr.Zero);
if (error != ErrorCode.None)
{
- Log.Error(LogTag, "GetSupportedLangauges Failed with error " + error);
+ Log.Error(LogTag, "GetSupportedLanguages Failed with error " + error);
throw ExceptionFactory.CreateException(error);
}
/// <precondition>
/// The State should be Ready
/// </precondition>
- public static VoiceCommandList GetSytemCommandList()
+ public static VoiceCommandList GetSystemCommandList()
{
IntPtr handle = IntPtr.Zero;
ErrorCode error = VcGetSystemCommandList(out handle);
/// http://tizen.org/feature/speech.control
/// http://tizen.org/feature/microphone
/// </feature>
- /// <param name="resultDelegate">
- /// Callback function to get recognition result
- /// </param>
/// <exception cref="InvalidOperationException"> This Exception can be due to Invalid State. </exception>
/// <exception cref="ArgumentException"> This Exception can be due to Invalid Parameter. </exception>
/// <exception cref="NotSupportedException"> This Exception can be due to Not Supported. </exception>
+ /// <returns>The Recognition Result if possible else a null object</returns>
/// <precondition>
/// The State should be Ready
/// </precondition>
- public static void GetResult(RecognitionResultDelegate resultDelegate)
+ public static RecognitionResult GetResult()
{
+ s_recognitionResult = null;
s_resultCb = (ResultEvent evt, IntPtr cmdList, IntPtr result, IntPtr userData) =>
{
- VoiceCommandList list = new VoiceCommandList(new SafeCommandListHandle(cmdList));
- string resultStr = Marshal.PtrToStringAnsi(result);
- resultDelegate(evt, list, resultStr);
+ s_recognitionResult = new RecognitionResult(evt, cmdList, result);
};
ErrorCode error = VcGetResult(s_resultCb, IntPtr.Zero);
if (error != ErrorCode.None)
Log.Error(LogTag, "GetResult Failed with error " + error);
throw ExceptionFactory.CreateException(error);
}
+
+ return s_recognitionResult;
}
/// <summary>
Log.Info(LogTag, "Recognition Result Event Triggered");
if ((cmdList != null) && (result != null))
{
- RecognitionResultEventArgs args = new RecognitionResultEventArgs(evt, cmdList, result);
+ RecognitionResultEventArgs args = new RecognitionResultEventArgs(new RecognitionResult( evt, cmdList, result));
_recognitionResult?.Invoke(null, args);
}
else