Init commit for voice control sample description
authorWonnam Jang <wn.jang@samsung.com>
Thu, 17 Sep 2015 01:46:13 +0000 (10:46 +0900)
committerWonnam Jang <wn.jang@samsung.com>
Thu, 17 Sep 2015 01:46:13 +0000 (10:46 +0900)
Change-Id: I3458b041102f6310c14c3233aef1c1936bb54a80
Signed-off-by: Wonnam Jang <wn.jang@samsung.com>
org.tizen.sampledescriptions/html/images/vc_sample_view.png [new file with mode: 0644]
org.tizen.sampledescriptions/html/mobile_n/voice_control_sd_mn.htm [new file with mode: 0644]

diff --git a/org.tizen.sampledescriptions/html/images/vc_sample_view.png b/org.tizen.sampledescriptions/html/images/vc_sample_view.png
new file mode 100644 (file)
index 0000000..ad4d3e3
Binary files /dev/null and b/org.tizen.sampledescriptions/html/images/vc_sample_view.png differ
diff --git a/org.tizen.sampledescriptions/html/mobile_n/voice_control_sd_mn.htm b/org.tizen.sampledescriptions/html/mobile_n/voice_control_sd_mn.htm
new file mode 100644 (file)
index 0000000..0f4090c
--- /dev/null
@@ -0,0 +1,246 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+       <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+       <meta http-equiv="X-UA-Compatible" content="IE=9" />
+       <link rel="stylesheet" type="text/css" href="../css/styles.css" />
+       <link rel="stylesheet" type="text/css" href="../css/snippet.css" />
+       <script type="text/javascript" src="../scripts/snippet.js"></script>    
+       <script type="text/javascript" src="../scripts/jquery.util.js" charset="utf-8"></script>
+       <script type="text/javascript" src="../scripts/common.js" charset="utf-8"></script>
+       <script type="text/javascript" src="../scripts/core.js" charset="utf-8"></script>
+       <script type="text/javascript" src="../scripts/search.js" charset="utf-8"></script>
+
+       <title>Voice Control Sample Overview</title>  
+       <style type="text/css">
+.auto-style1 {
+       text-align: center;
+}
+</style>
+</head>
+
+<body class="no-toc" onload="prettyPrint()" style="overflow: auto;">
+
+<div id="toc-navigation">
+</div> 
+
+<div id="container"><div id="contents"><div>
+       <div id="profile">
+               <p><img alt="Mobile native" src="../images/mobile_s_n.png"/></p>
+       </div>
+
+<h1>Voice Control Sample Overview</h1> 
+
+<p>The purpose of this sample application is to demonstrate how 
+to use the voice control API to initialize, deinitialize, add commands, remove 
+commands and retrieve valuable infromation. </p>
+<p>The following figure illustrates the main view of the Voice 
+Control sample application and how it works. The application 
+can register commands using 'Select Command List' menu. If developer 
+selects first command list on first row, the 'play, stop, pause, rewind' 
+commands will be registered. And start and stop voice control can be triggered 
+by voice manager application. The voice manager application which is created by 
+manufacturer can be executed. In case of SDK mobile, you can find it as voice 
+button on quick panel as below 3rd images. When you start voice control pressing 
+voice button, voice manager application will be shown on bottom of the screen.
+</p>
+
+<p class="auto-style1">Figure: Voice control Application main view</p> 
+<p align="center"><img alt="Voice Control sample application view" src="../images/vc_sample_view_.png" /></p> 
+
+<h2>Implementation</h2>
+<p>To implement the Voice Control application:</p>
+
+<ol>
+<li>Initialize Voice Control
+<p>For using Voice control library, you should initialize Voice control at the 
+first, in the <span style="font-family: Courier New,Courier,monospace;">init_vc()</span> function. 
+It can initialize voice control and set the callback functions for the state changed and 
+receiving result from Voice control Service. And then, the application try to connect to 
+Voice control Service for handshaking information and data by vc_prepare() function.
+</p>
+
+<pre class="prettyprint">
+static void __vc_service_state_changed_cb(vc_service_state_e previous, vc_service_state_e current, void* user_data)
+{
+    ...
+}
+
+static void __vc_result_cb(vc_result_event_e event, vc_cmd_list_h vc_cmd_list, const char* result, void *user_data)
+{
+    ...
+}
+
+static int init_vc(appdata_s *ad)
+{
+    ...
+    ret = vc_initialize();
+    if (VC_ERROR_NONE != ret) {
+        ...
+        return -1;
+    }
+
+    ret = vc_set_result_cb(__vc_result_cb, ad);
+    if (VC_ERROR_NONE != ret) {
+        ...
+        return -1;
+    }
+
+    ret = vc_set_service_state_changed_cb(__vc_service_state_changed_cb, ad);
+    if (VC_ERROR_NONE != ret) {
+        ...
+    return -1;
+    }
+
+    ret = vc_prepare();
+    if (VC_ERROR_NONE != ret) {
+        ...
+        return -1;
+    }
+
+    return 0;
+}
+
+</pre>
+</li>
+
+<li>Deinitialize TTS.
+<p>The <span style="font-family: Courier New,Courier,monospace;">deinit_VC()</span> is called to disconnect service 
+and to destroy command list when the application is finalized. If you want to only disconnect service, the
+<span style="font-family: Courier New,Courier,monospace;">vc_unprepare()</span> helps you.
+</p>
+
+<pre class="prettyprint">
+static void __vc_destroy_command_list(void)
+{
+    if (0 != vc_cmd_list_destroy(g_cmd_list, true)) {
+        ...
+    }
+}
+
+static void deinit_vc(appdata_s *ad)
+{
+    __vc_destroy_command_list();
+
+    if (0 != vc_deinitialize()) {
+        ...
+    }
+}
+</pre>
+</li>
+
+<li>Create and set command list
+<p>If you want to set commands, you need to create command list and add command on command list.
+And you can also remove commands on the command list or change the command list.
+And if you don't want to use commands any more, you can destroy command list.
+</p>
+
+<pre class="prettyprint">
+static void __vc_create_command_list(cmd_list_index_e cmd_list_idx)
+{
+    if (0 != vc_cmd_list_create(&amp;g_cmd_list)) {
+        ...
+    }
+
+    int i;
+    for (i = 0; i &lt; MAX_COMMAND_NUM; i++) {
+        vc_cmd_h cmd;
+        if (0 != vc_cmd_create(&amp;cmd)) {
+            ...
+        }
+        if (0 != vc_cmd_set_command(cmd, "play")) {
+            ...
+            vc_cmd_destroy(cmd);
+        }
+        if (0 != vc_cmd_set_type(cmd, VC_COMMAND_TYPE_FOREGROUND)) {
+            ...
+            vc_cmd_destroy(cmd);
+        }
+        if (0 != vc_cmd_list_add(g_cmd_list, cmd)) {
+            ...
+            vc_cmd_destroy(cmd);
+        }
+    }
+
+    if ( 0 != vc_set_command_list(g_cmd_list, VC_COMMAND_TYPE_FOREGROUND)) {
+        ...
+        vc_cmd_list_destroy(g_cmd_list, true);
+    }
+}
+</pre>
+</li>
+
+<li>Get service state changed
+<p>If you set service state changed callback, you can check 
+voice control service state. It shows you that voice service control is ready, 
+recording or processing state. Using this service state, you can change 
+application's mode, state or look&amp;feel. 
+</p>
+
+<pre class="prettyprint">
+static void __vc_service_state_changed_cb(vc_service_state_e previous, vc_service_state_e current, void* user_data)
+{
+    ...
+}
+
+static int init_vc(appdata_s *ad)
+{
+    ...
+    ret = vc_set_service_state_changed_cb(__vc_service_state_changed_cb, ad);
+    if (VC_ERROR_NONE != ret) {
+        return -1;
+    }
+    ...
+    return 0;
+}
+</pre>
+</li>
+
+<li>Get recognized result
+<p>If you want to get the recognized command, you should set result callback function. 
+You can get not only recognized result text, but also command list which has command information. 
+</p>
+
+<pre class="prettyprint">
+static void __vc_result_cb(vc_result_event_e event, vc_cmd_list_h vc_cmd_list, const char* result, void *user_data)
+{
+    ...
+}
+
+static int init_vc(appdata_s *ad)
+{
+    ...
+    ret = vc_set_result_cb(__vc_result_cb, ad);
+    if (VC_ERROR_NONE != ret) {
+        return -1;
+    }
+    ...
+    return 0;
+}
+</pre>
+</li>
+</ol>
+
+<script type="text/javascript" src="../scripts/jquery.zclip.min.js"></script>
+<script type="text/javascript" src="../scripts/showhide.js"></script>
+</div></div></div>
+
+<a class="top sms" href="#"><img src="../images/btn_top.gif" alt="Go to top" /></a>
+
+<div id="footer">
+<p class="footer">Except as noted, this content - excluding the Code Examples - is licensed under <a href="http://creativecommons.org/licenses/by/3.0/legalcode" target="_blank">Creative Commons Attribution 3.0</a> and all of the Code Examples contained herein are licensed under <a href="https://www.tizen.org/bsd-3-clause-license" target="_blank">BSD-3-Clause</a>.<br/>For details, see the <a href="https://www.tizen.org/content-license" target="_blank">Content License</a>.</p>
+</div>
+
+<script type="text/javascript">
+var _gaq = _gaq || [];
+_gaq.push(['_setAccount', 'UA-25976949-1']);
+_gaq.push(['_trackPageview']);
+(function() {
+var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+})();
+</script>
+
+</body>
+</html>
\ No newline at end of file