[TBT][tizen_3.0_mobile][Speech to Text (stt) and Text to Speech(tts) modules added] 19/82619/2
authornazib.ullah <nazib.ullah@samsung.com>
Thu, 4 Aug 2016 12:55:46 +0000 (18:55 +0600)
committernazib.ullah <nazib.ullah@samsung.com>
Fri, 5 Aug 2016 05:37:13 +0000 (11:37 +0600)
Change-Id: Ie05b2cffa0feb01d94c0b48aad4919cebfbdcfe5

14 files changed:
release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk
release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk
tbtcoreapp/inc/model/tbt-info.h
tbtcoreapp/inc/utils/app_module_config.h
tbtcoreapp/inc/utils/config.h
tbtcoreapp/inc/view/tbt-stt-view.h [new file with mode: 0644]
tbtcoreapp/inc/view/tbt-tts-view.h [new file with mode: 0644]
tbtcoreapp/res/edje/3.0/mobile/stt_viewer.edc [new file with mode: 0644]
tbtcoreapp/res/edje/3.0/mobile/tts_viewer.edc [new file with mode: 0644]
tbtcoreapp/res/sounds/start_record.wav [new file with mode: 0644]
tbtcoreapp/src/model/tbt-list.c
tbtcoreapp/src/view/tbt-genlist-view.c
tbtcoreapp/src/view/tbt-stt-view.c [new file with mode: 0644]
tbtcoreapp/src/view/tbt-tts-view.c [new file with mode: 0644]

index 1d3090a006ae0c2e33d69e297f7a2ceebd37e519..ee0ec6e49006fffb9e9f9bb7e0fcc7c344059a31 100644 (file)
Binary files a/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk and b/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk differ
index 6a044207cfa057026eab318b5dd17c6dfd7fa538..46dd80fa9fb36bd45ed8aeb5352eba5eb6f8c643 100644 (file)
Binary files a/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk and b/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk differ
index 11d4152829e4586248de5bf1bf97a4b152680025..1c5de2dc22b15387f41aff1135de60fe402d0980 100644 (file)
@@ -222,7 +222,13 @@ typedef enum {
 
     TBT_APP_D2D_CLIENT,
 
-    TBT_APP_D2D_SERVER
+    TBT_APP_D2D_SERVER,
+    
+    TBT_APP_TTS,
+
+    TBT_APP_STT,
+
+    TBT_APP_STT_ERROR
 
 } tbt_app_type_e;
 
index 8a473795c89fd301d1417590f9de0114bc4f591d..bb6518e282aa94c1a34bed1f8b5f41674a222882 100644 (file)
 #define TBT_MODULE_APP_D2D_CLIENT
 #define TBT_MODULE_APP_D2D_SERVER
 
+#define TBT_MODULE_TTS
+#define TBT_MODULE_APP_TTS
+#define TBT_MODULE_STT
+#define TBT_MODULE_APP_STT
+#define TBT_MODULE_APP_STT_ERROR
+
 #endif
index 28ce17d4ab843658392e29fc9f456cb802ebc422..95f034c63efad2935e8f4d1299dbf3488ad675a5 100644 (file)
@@ -108,6 +108,8 @@ extern bool __is_efl_test_running;
 #define PICK_VIEW_VIDEO_3GP "video/sampleH263.3gp"
 #define PICK_VIEW_VIDEO_MP4 "video/sampleMPEG4.mp4"
 
+#define STT_START_RECORDING_SOUND "sounds/start_record.wav"
+
 
 
 
diff --git a/tbtcoreapp/inc/view/tbt-stt-view.h b/tbtcoreapp/inc/view/tbt-stt-view.h
new file mode 100644 (file)
index 0000000..4f86030
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ *  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.
+ *
+ *******************************************************************************/
+/**
+ * @file       tbt-stt-view.h
+ * @brief      covers speech to text recognition
+ *
+ * @author     A. B. M. Nazibullah(nazib.ullah@samsung.com)
+ * @date       August, 2016
+ * @bug
+ * @credit
+ *
+ */
+
+#ifndef __TBT_STT_VIEW_H__
+#define __TBT_STT_VIEW_H__
+
+#include "utils/app_module_config.h"
+#ifdef TBT_MODULE_STT
+
+#include <Evas.h>
+#include "model/tbt-list.h"
+
+
+/**
+ * @typedef stt_viewer_view
+ * @since_tizen 2.3
+ * @brief A stt viewer view handle.
+ */
+typedef struct _stt_view stt_view;
+
+/**
+ * @brief Create stt view
+ * @since_tizen 2.3 
+ * @param[in] navi Parent naviframe
+ * @param[in] custom structute to hold tbt application information
+ * @param[in] item of the main tbt menu
+ * @return Pointer of stt on success, otherwise NULL
+ */
+stt_view *stt_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item);
+
+#endif
+#endif // __TBT_STT_VIEW_H__
diff --git a/tbtcoreapp/inc/view/tbt-tts-view.h b/tbtcoreapp/inc/view/tbt-tts-view.h
new file mode 100644 (file)
index 0000000..c9db2ea
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ *  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.
+ *
+ *******************************************************************************/
+/**
+ * @file       tbt-tts-view.h
+ * @brief      coverst text to speech operations
+ *
+ * @author     A. B. M. Nazibullah (nazib.ullah@samsung.com)
+ * @date       August, 2016
+ * @bug
+ * @credit
+ *
+ */
+
+#ifndef __TBT_TTS_VIEW_H__
+#define __TBT_TTS_VIEW_H__
+
+#include "utils/app_module_config.h"
+#ifdef TBT_MODULE_TTS
+
+#include <Evas.h>
+#include "model/tbt-list.h"
+
+
+/**
+ * @typedef tts_viewer_view
+ * @since_tizen 2.3
+ * @brief A tts viewer view handle.
+ */
+typedef struct _tts_view tts_view;
+
+/**
+ * @brief Create tts camera view
+ * @since_tizen 2.3 
+ * @param[in] navi Parent naviframe
+ * @param[in] custom structute to hold tbt application information
+ * @param[in] item of the main tbt menu
+ * @return Pointer of tts on success, otherwise NULL
+ */
+tts_view *tts_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item);
+
+#endif
+#endif // __TBT_TTS_VIEW_H__
diff --git a/tbtcoreapp/res/edje/3.0/mobile/stt_viewer.edc b/tbtcoreapp/res/edje/3.0/mobile/stt_viewer.edc
new file mode 100644 (file)
index 0000000..07f7e2e
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2014 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.
+*/
+#define TEXT_HEIGHT 0.08
+collections
+{
+   base_scale: 1.8;
+   group
+   {
+      name: "stt_viewer";
+      parts{
+         part{
+            name: "txt_part_1";
+            type: SWALLOW;
+            description{
+               state: "default" 0.0;
+               align: 0.0 0.0;
+               visible: 1;
+               rel1 {
+                  relative: 0.0 0.0;
+               }
+               rel2 {
+                  relative: 1.0 TEXT_HEIGHT;
+               }
+            }
+         }
+         
+         part{
+            name: "txt_part_2";
+            type: SWALLOW;
+            description{
+               state: "default" 0.0;
+               align: 0.0 0.0;
+               visible: 1;
+               rel1 {
+                  relative: 0.0 TEXT_HEIGHT;
+               }
+               rel2 {
+                  relative: 1.0 2*TEXT_HEIGHT;
+               }
+            }
+         }
+         
+         part{
+            name: "btn_part";
+            type: SWALLOW;
+            description{
+               state: "default" 0.0;
+               align: 0.0 0.0;
+               visible: 1;
+               rel1 {
+                  relative: 0.0 0.9;
+               }
+               rel2 {
+                  relative: 1.0 1.0;
+               }
+            }
+         }
+         
+      }
+   }
+}
\ No newline at end of file
diff --git a/tbtcoreapp/res/edje/3.0/mobile/tts_viewer.edc b/tbtcoreapp/res/edje/3.0/mobile/tts_viewer.edc
new file mode 100644 (file)
index 0000000..91194c4
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2014 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.
+*/
+#define TEXT_HEIGHT 0.08
+collections
+{
+   base_scale: 1.8;
+   group
+   {
+      name: "tts_viewer";
+      parts{
+         part{
+            name: "txt_part";
+            type: SWALLOW;
+            description{
+               state: "default" 0.0;
+               align: 0.0 0.0;
+               visible: 1;
+               rel1 {
+                  relative: 0.0 0.0;
+               }
+               rel2 {
+                  relative: 1.0 TEXT_HEIGHT;
+               }
+            }
+         }
+         
+         part{
+            name: "btn_part";
+            type: SWALLOW;
+            description{
+               state: "default" 0.0;
+               align: 0.0 0.0;
+               visible: 1;
+               rel1 {
+                  relative: 0.0 0.9;
+               }
+               rel2 {
+                  relative: 1.0 1.0;
+               }
+            }
+         }
+         
+      }
+   }
+}
\ No newline at end of file
diff --git a/tbtcoreapp/res/sounds/start_record.wav b/tbtcoreapp/res/sounds/start_record.wav
new file mode 100644 (file)
index 0000000..725a86b
Binary files /dev/null and b/tbtcoreapp/res/sounds/start_record.wav differ
index b6015f0f8f4446a54a4ccc36d1a5a7aa5e758e6b..f004b54bbd0494fea666f31a21f16dc574fbc593 100644 (file)
@@ -1849,6 +1849,40 @@ static tbt_info tbtapps[] =
                        .icon_name = "dummy",
                        .info = "Check D2d server service <br/>",
                        .result = 0
+               },
+       #endif
+#endif
+#ifdef TBT_MODULE_TTS
+       #ifdef TBT_MODULE_APP_TTS
+               {
+                       .name = "TTS",
+                       .parent = "TTS/STT",
+                       .apptype = TBT_APP_TTS,
+                       .icon_name = "dummy",
+                       .info = "Text to speech <br/>",
+                       .result = 0
+               },
+       #endif
+#endif
+#ifdef TBT_MODULE_STT
+       #ifdef TBT_MODULE_APP_STT
+               {
+                       .name = "STT",
+                       .parent = "TTS/STT",
+                       .apptype = TBT_APP_STT,
+                       .icon_name = "dummy",
+                       .info = "Speech to text <br/>",
+                       .result = 0
+               },
+       #endif
+       #ifdef TBT_MODULE_APP_STT_ERROR
+               {
+                       .name = "STT Error",
+                       .parent = "TTS/STT",
+                       .apptype = TBT_APP_STT_ERROR,
+                       .icon_name = "dummy",
+                       .info = "Speech to text <br/> Error callback check",
+                       .result = 0
                }
        #endif
 #endif
index eba2eed30bfa99e009a86e8c1bc9b2b5b0974a44..e55050c5df8e314af3749a432cdebb7fd2895a4a 100644 (file)
@@ -94,6 +94,8 @@
 #include "view/tbt-systemsettings-view.h"
 #include "view/tbt-contacts-view.h"
 #include "view/tbt-d2d-view.h"
+#include "view/tbt-tts-view.h"
+#include "view/tbt-stt-view.h"
 
 typedef struct
 {
@@ -1062,6 +1064,21 @@ static void _gl_item_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void
                                d2d_view_add(view->navi, info, it);
                                break;
                #endif
+               
+               #ifdef TBT_MODULE_TTS
+                       case TBT_APP_TTS:
+                       tts_view_add(view->navi, info, it);
+                       break;
+               #endif
+               #ifdef TBT_MODULE_STT
+                       case TBT_APP_STT:
+                       stt_view_add(view->navi, info, it);
+                       break;
+
+                       case TBT_APP_STT_ERROR:
+                       stt_view_add(view->navi, info, it);
+                       break;
+               #endif
 
                default:
                        assert(false);
diff --git a/tbtcoreapp/src/view/tbt-stt-view.c b/tbtcoreapp/src/view/tbt-stt-view.c
new file mode 100644 (file)
index 0000000..9212fdd
--- /dev/null
@@ -0,0 +1,356 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ *  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.
+ *******************************************************************************/
+/**
+ * @file       tbt-stt-view.c
+ * @brief      covers speech to text recognition
+ *
+ * @author     A. B. M. Nazibullah(nazib.ullah@samsung.com)
+ * @date       August, 2016
+ * @bug
+ * @credit
+ *
+ */
+
+#include "utils/app_module_config.h"
+#ifdef TBT_MODULE_STT
+
+#include <Elementary.h>
+#include <stt.h>
+#include "utils/logger.h"
+#include "utils/config.h"
+#include "utils/ui-utils.h"
+#include "view/tbt-stt-view.h"
+#include "view/tbt-common-view.h"
+
+struct _stt_view
+{
+       common_view* view;
+
+    Evas_Object *input_text;
+    Evas_Object *recognized_text;
+    Evas_Object *btn_stt;
+
+    stt_h stt_handle;
+    bool is_recognition_completed;
+    bool is_unprepared;
+
+    char* res_path;
+};
+
+static void _app_destroy_cb(void* this);
+static char* get_stt_error(stt_error_e err);
+static void _btn_stt_pressed_cb(void *data, Evas_Object *obj, void *event_info);
+static char* get_stt_state_str(stt_state_e state);
+static void _stt_state_changed_cb(stt_h stt, stt_state_e previous, stt_state_e current, void* user_data);
+static void _stt_recognition_result_cb(stt_h stt, stt_result_event_e event, const char** data, int data_count, const char* msg, void *user_data);
+static bool _stt_supported_language_cb(stt_h stt, const char* language, void* user_data);
+static void _stt_error_cb(stt_h stt, stt_error_e reason, void *user_data);
+
+
+/**
+ * @function           stt_view_add
+ * @since_tizen                2.3
+ * @description                Gps View Add
+ * @parameter          Evas_Object*: Evas Object Pointer, tbt_info*: Tbt Info Pointer, Elm_Object_Item*: Elm Object Item Pointer
+ * @return             stt_view*
+ */
+stt_view *stt_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item)
+{
+       RETVM_IF(NULL == navi, NULL, "navi is null");
+
+    stt_view *this = NULL;
+    this = calloc(1, sizeof(stt_view));
+    RETVM_IF(!this, NULL, "calloc failed");
+    this->view = calloc(1, sizeof(common_view));
+    RETVM_IF(!this->view, NULL, "calloc failed");
+
+    tbt_info->layout_group = "stt_viewer";
+    tbt_info->layout_file = get_edje_path("stt_viewer.edj");
+
+    common_view_add(navi, tbt_info, item, this->view, _app_destroy_cb, this);
+
+       RETVM_IF(NULL == this->view, NULL, "navi is null");
+
+       this->is_recognition_completed = false;
+       this->is_unprepared = false;
+
+       this->res_path = app_get_resource_path();
+
+       this->input_text = ui_utils_label_add(this->view->layout, "Latitude: ");
+       this->recognized_text = ui_utils_label_add(this->view->layout, "Longitude: ");
+
+       if(this->view->tbt_info->apptype == TBT_APP_STT)
+       {
+               ui_utils_label_set_text(this->input_text, "Make sure Internet is connected", "left");
+               ui_utils_label_set_text(this->recognized_text, "", "left");
+       }
+       else if(this->view->tbt_info->apptype == TBT_APP_STT_ERROR)
+       {
+               ui_utils_label_set_text(this->input_text, "Disconnect Internet, Then press Speak button", "left");
+               ui_utils_label_set_text(this->recognized_text, "", "left");
+       }
+
+       elm_object_part_content_set(this->view->layout, "txt_part_1", this->input_text);
+       elm_object_part_content_set(this->view->layout, "txt_part_2", this->recognized_text);
+
+
+       this->btn_stt = ui_utils_push_button_add(this, this->view->layout, "Speak", _btn_stt_pressed_cb);
+       elm_object_part_content_set(this->view->layout, "btn_part", this->btn_stt);
+
+
+    return this;
+}
+
+static void _btn_stt_pressed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       DBG("_btn_stt_pressed_cb");
+       stt_view *this = NULL;
+       this = (stt_view*)data;
+       RETM_IF(NULL == this, "view is NULL");
+       int ret;
+       ret = stt_create(&this->stt_handle);
+       RETM_IF(ret != STT_ERROR_NONE, "stt_create fail > Error = %s", get_stt_error(ret));
+       ret = stt_set_state_changed_cb(this->stt_handle, _stt_state_changed_cb, this);
+       RETM_IF(ret != STT_ERROR_NONE, "stt_set_state_changed_cb fail > Error = %s", get_stt_error(ret));
+       ret = stt_set_recognition_result_cb(this->stt_handle, _stt_recognition_result_cb, this);
+       RETM_IF(ret != STT_ERROR_NONE, "stt_set_recognition_result_cb fail > Error = %s", get_stt_error(ret));
+       ret = stt_foreach_supported_languages(this->stt_handle, _stt_supported_language_cb, this);
+       RETM_IF(ret != STT_ERROR_NONE, "stt_foreach_supported_languages fail > Error = %s", get_stt_error(ret));
+       ret = stt_set_error_cb(this->stt_handle, _stt_error_cb, this);
+       RETM_IF(ret != STT_ERROR_NONE, "stt_set_error_cb fail > Error = %s", get_stt_error(ret));
+       ret = stt_prepare(this->stt_handle);
+       RETM_IF(ret != STT_ERROR_NONE, "stt_prepare fail > Error = %s", get_stt_error(ret));
+       elm_object_disabled_set(this->btn_stt, EINA_TRUE);
+}
+
+static void _stt_state_changed_cb(stt_h stt, stt_state_e previous, stt_state_e current, void* user_data)
+{
+       DBG("_stt_state_changed_cb previous: %s current %s", get_stt_state_str(previous), get_stt_state_str(current));
+       stt_view *this = NULL;
+       this = (stt_view*)user_data;
+       RETM_IF(NULL == this, "view is NULL");
+       int ret;
+       if(current == STT_STATE_CREATED)
+       {
+               if(this->is_unprepared)
+               {
+                       ret = stt_unset_state_changed_cb(this->stt_handle);
+                       RETM_IF(ret != STT_ERROR_NONE, "stt_unset_state_changed_cb fail > Error = %s", get_stt_error(ret));
+                       ret = stt_unset_recognition_result_cb(this->stt_handle);
+                       RETM_IF(ret != STT_ERROR_NONE, "stt_unset_recognition_result_cb fail > Error = %s", get_stt_error(ret));
+                       ret = stt_unset_error_cb(this->stt_handle);
+                       RETM_IF(ret != STT_ERROR_NONE, "stt_unset_error_cb fail > Error = %s", get_stt_error(ret));
+                       this->is_unprepared = false;
+               }
+
+       }
+       else if(current ==STT_STATE_READY)
+       {
+               if(this->is_recognition_completed)
+               {
+                       ret = stt_unprepare(this->stt_handle);
+                       this->is_unprepared = true;
+                       RETM_IF(ret != STT_ERROR_NONE, "stt_unprepare fail > Error = %s", get_stt_error(ret));
+                       this->is_recognition_completed = false;
+               }
+               else
+               {
+                       char* file_name = format_string("%s%s", this->res_path, STT_START_RECORDING_SOUND);
+                       ret = stt_set_start_sound(this->stt_handle, file_name);
+                       DBG("stt_set_start_sound %s", get_stt_error(ret));
+                       SAFE_DELETE(file_name);
+
+                       ret = stt_set_silence_detection(this->stt_handle, STT_OPTION_SILENCE_DETECTION_TRUE);
+                       DBG("stt_set_silence_detection %s", get_stt_error(ret));
+                       ret = stt_start(this->stt_handle, "en_US", STT_RECOGNITION_TYPE_FREE);
+                       DBG("stt_start %s", get_stt_error(ret));
+               }
+       }
+       else if(current == STT_STATE_RECORDING)
+       {
+               DBG("recording");
+               ui_utils_label_set_text(this->input_text, "Recording...", "left");
+       }
+       else if(current == STT_STATE_PROCESSING)
+       {
+               DBG("processing");
+               ui_utils_label_set_text(this->input_text, "Processing...", "left");
+       }
+
+}
+static void _stt_error_cb(stt_h stt, stt_error_e reason, void *user_data)
+{
+       DBG("_stt_error_cb %s", get_stt_error(reason));
+       stt_view *this = NULL;
+       this = (stt_view*)user_data;
+       RETM_IF(NULL == this, "view is NULL");
+       char* str = format_string("%s",get_stt_error(reason));
+       ui_utils_label_set_text(this->input_text, str, "left");
+       SAFE_DELETE(str);
+}
+
+static bool _stt_supported_language_cb(stt_h stt, const char* language, void* user_data)
+{
+       DBG("language %s", language);
+       return true;
+}
+static void _stt_recognition_result_cb(stt_h stt, stt_result_event_e event, const char** data, int data_count, const char* msg, void *user_data)
+{
+       DBG("_stt_recognition_result_cb");
+
+       stt_view *this = NULL;
+       this = (stt_view*)user_data;
+       RETM_IF(NULL == this, "view is NULL");
+
+       if(data_count)
+       {
+               this->is_recognition_completed = true;
+       }
+
+       for(int i=0; i<data_count; i++)
+       {
+               DBG("DATA: %s", data[i]);
+               char* str = format_string("%s", data[i]);
+               ui_utils_label_set_text(this->input_text, str, "left");
+               elm_object_disabled_set(this->btn_stt, EINA_FALSE);
+               SAFE_DELETE(str);
+       }
+
+
+}
+
+/**
+ * @function           _app_destroy_cb
+ * @since_tizen                2.3
+ * @description                 App Destroy Cb
+ * @parameter          void*: Void Pointer
+ * @return             static void
+ */
+static void _app_destroy_cb(void* this)
+{
+       RETM_IF(NULL == this, "data is NULL");
+
+       stt_view *view = NULL;
+       view = (stt_view*)this;
+       RETM_IF(NULL == view, "view is NULL");
+
+       int ret;
+       ret = stt_destroy(view->stt_handle);
+       DBG("stt_destroy %s", get_stt_error(ret));
+
+       SAFE_DELETE(view->view);
+       SAFE_DELETE(view);
+}
+
+static char* get_stt_error(stt_error_e err)
+{
+       char* err_msg;
+
+       switch(err)
+       {
+       case STT_ERROR_NONE:
+               err_msg = "STT_ERROR_NONE";
+               break;
+       case STT_ERROR_OUT_OF_MEMORY:
+               err_msg = "STT_ERROR_OUT_OF_MEMORY";
+               break;
+       case STT_ERROR_IO_ERROR:
+               err_msg = "STT_ERROR_IO_ERROR";
+               break;
+       case STT_ERROR_INVALID_PARAMETER:
+               err_msg = "STT_ERROR_INVALID_PARAMETER";
+               break;
+       case STT_ERROR_TIMED_OUT:
+               err_msg = "STT_ERROR_TIMED_OUT";
+               break;
+       case STT_ERROR_RECORDER_BUSY:
+               err_msg = "STT_ERROR_RECORDER_BUSY";
+               break;
+       case STT_ERROR_OUT_OF_NETWORK:
+               err_msg = "STT_ERROR_OUT_OF_NETWORK";
+               break;
+       case STT_ERROR_PERMISSION_DENIED:
+               err_msg = "STT_ERROR_PERMISSION_DENIED";
+               break;
+       case STT_ERROR_NOT_SUPPORTED:
+               err_msg = "STT_ERROR_NOT_SUPPORTED";
+               break;
+       case STT_ERROR_INVALID_STATE:
+               err_msg = "STT_ERROR_INVALID_STATE";
+               break;
+       case STT_ERROR_INVALID_LANGUAGE:
+               err_msg = "STT_ERROR_INVALID_LANGUAGE";
+               break;
+       case STT_ERROR_ENGINE_NOT_FOUND:
+               err_msg = "STT_ERROR_ENGINE_NOT_FOUND";
+               break;
+       case STT_ERROR_OPERATION_FAILED:
+               err_msg = "STT_ERROR_OPERATION_FAILED";
+               break;
+       case STT_ERROR_NOT_SUPPORTED_FEATURE:
+               err_msg = "STT_ERROR_NOT_SUPPORTED_FEATURE";
+               break;
+       case STT_ERROR_RECORDING_TIMED_OUT:
+               err_msg = "STT_ERROR_RECORDING_TIMED_OUT";
+               break;
+       case STT_ERROR_NO_SPEECH:
+               err_msg = "STT_ERROR_NO_SPEECH";
+               break;
+       case STT_ERROR_IN_PROGRESS_TO_READY:
+               err_msg = "STT_ERROR_IN_PROGRESS_TO_READY";
+               break;
+       case STT_ERROR_IN_PROGRESS_TO_RECORDING:
+               err_msg = "STT_ERROR_IN_PROGRESS_TO_RECORDING";
+               break;
+       case STT_ERROR_IN_PROGRESS_TO_PROCESSING:
+               err_msg = "STT_ERROR_IN_PROGRESS_TO_PROCESSING";
+               break;
+       case STT_ERROR_SERVICE_RESET:
+               err_msg = "STT_ERROR_SERVICE_RESET";
+               break;
+       default:
+               err_msg = "UNKNOWN_ERROR";
+               break;
+       }
+return err_msg;
+}
+
+
+static char* get_stt_state_str(stt_state_e state)
+{
+       char* state_str;
+       switch (state)
+       {
+               case STT_STATE_CREATED:
+                       state_str = "STT_STATE_CREATED";
+                       break;
+               case STT_STATE_READY:
+                       state_str = "STT_STATE_READY";
+                       break;
+               case STT_STATE_RECORDING:
+                       state_str = "STT_STATE_RECORDING";
+                       break;
+               case STT_STATE_PROCESSING:
+                       state_str = "STT_STATE_PROCESSING";
+                       break;
+               default:
+                       state_str = "UNKNOWN_STATE";
+                       break;
+               }
+       return state_str;
+}
+
+#endif
diff --git a/tbtcoreapp/src/view/tbt-tts-view.c b/tbtcoreapp/src/view/tbt-tts-view.c
new file mode 100644 (file)
index 0000000..d9cdbe8
--- /dev/null
@@ -0,0 +1,292 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ *  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.
+ *******************************************************************************/
+/**
+ * @file       tbt-tts-view.c
+ * @brief      coverst text to speech operations
+ *
+ * @author     A. B. M. Nazibullah (nazib.ullah@samsung.com)
+ * @date       August, 2016
+ * @bug
+ * @credit
+ *
+ */
+
+#include "utils/app_module_config.h"
+#ifdef TBT_MODULE_TTS
+
+#include <Elementary.h>
+#include <tts.h>
+#include "utils/logger.h"
+#include "utils/config.h"
+#include "utils/ui-utils.h"
+#include "view/tbt-tts-view.h"
+#include "view/tbt-common-view.h"
+
+struct _tts_view
+{
+       common_view* view;
+    Evas_Object *txt_label;
+    Evas_Object* btn_tts;
+
+    tts_h tts_handle;
+    bool is_utterance_completed;
+    bool is_tts_btn_pressed;
+};
+
+static void _app_destroy_cb(void* this);
+static void _btn_tts_pressed_cb(void *data, Evas_Object *obj, void *event_info);
+static char* get_tts_error(tts_error_e err);
+static void _tts_state_changed_cb(tts_h tts, tts_state_e previous, tts_state_e current, void* user_data);
+static bool _tts_supported_voice_cb(tts_h tts, const char* language, int voice_type, void* user_data);
+static char* get_tts_state_str(tts_state_e state);
+static void _tts_utterance_completed_cb(tts_h tts, int utt_id, void *user_data);
+
+
+/**
+ * @function           tts_view_add
+ * @since_tizen                2.3
+ * @description                Gps View Add
+ * @parameter          Evas_Object*: Evas Object Pointer, tbt_info*: Tbt Info Pointer, Elm_Object_Item*: Elm Object Item Pointer
+ * @return             tts_view*
+ */
+tts_view *tts_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item)
+{
+       RETVM_IF(NULL == navi, NULL, "navi is null");
+
+    tts_view *this = NULL;
+    this = calloc(1, sizeof(tts_view));
+    RETVM_IF(!this, NULL, "calloc failed");
+    this->view = calloc(1, sizeof(common_view));
+    RETVM_IF(!this->view, NULL, "calloc failed");
+
+    tbt_info->layout_group = "tts_viewer";
+    tbt_info->layout_file = get_edje_path("tts_viewer.edj");
+
+    common_view_add(navi, tbt_info, item, this->view, _app_destroy_cb, this);
+
+       RETVM_IF(NULL == this->view, NULL, "navi is null");
+
+       this->is_utterance_completed = false;
+       this->is_tts_btn_pressed = false;
+
+       this->txt_label = ui_utils_label_add(this->view->layout, "");
+       ui_utils_label_set_text(this->txt_label, "Text: The quick brown fox jumps over the lazy dog", "left");
+       elm_object_part_content_set(this->view->layout, "txt_part", this->txt_label);
+
+       this->btn_tts = ui_utils_push_button_add(this, this->view->layout, "Text to Speech", _btn_tts_pressed_cb);
+       elm_object_part_content_set(this->view->layout, "btn_part", this->btn_tts);
+
+    return this;
+}
+static bool _tts_supported_voice_cb(tts_h tts, const char* language, int voice_type, void* user_data)
+{
+       DBG("_tts_supported_voice_cb: %s %d", language, voice_type);
+       return true;
+}
+
+static void _tts_state_changed_cb(tts_h tts, tts_state_e previous, tts_state_e current, void* data)
+{
+       DBG("prev state %s current state: %s", get_tts_state_str(previous), get_tts_state_str(current));
+
+       tts_view *this = NULL;
+       this = (tts_view*)data;
+       RETM_IF(NULL == this, "view is NULL");
+
+       int ret;
+       if(current == TTS_STATE_CREATED)
+       {
+               if(this->is_utterance_completed)
+               {
+                       ret = tts_unset_state_changed_cb(this->tts_handle);
+                       RETM_IF(ret != TTS_ERROR_NONE, "tts_unset_state_changed_cb fail > Error = %s", get_tts_error(ret));
+                       ret = tts_unset_utterance_completed_cb(this->tts_handle);
+                       RETM_IF(ret != TTS_ERROR_NONE, "tts_unset_utterance_completed_cb fail > Error = %s", get_tts_error(ret));
+                       this->is_utterance_completed = false;
+
+               }
+       }
+       else if (current == TTS_STATE_READY)
+       {
+               if(this->is_tts_btn_pressed)
+               {
+                       int utt_id;
+                       ret = tts_add_text(this->tts_handle, "The quick brown fox jumps over the lazy dog", NULL, TTS_VOICE_TYPE_FEMALE, TTS_SPEED_AUTO, &utt_id);
+                       RETM_IF(ret != TTS_ERROR_NONE, "tts_add_text fail > Error = %s", get_tts_error(ret));
+                       ret = tts_play(this->tts_handle);
+                       RETM_IF(ret != TTS_ERROR_NONE, "tts_play fail > Error = %s", get_tts_error(ret));
+                       this->is_tts_btn_pressed = false;
+               }
+               else
+               {
+                       ret = tts_unprepare(this->tts_handle);
+                       RETM_IF(ret != TTS_ERROR_NONE, "tts_unprepare fail > Error = %s", get_tts_error(ret));
+
+               }
+
+       }
+       else if(current == TTS_STATE_PLAYING)
+       {
+
+       }
+       else if(current == TTS_STATE_PAUSED)
+       {
+
+       }
+}
+
+static void _tts_utterance_completed_cb(tts_h tts, int utt_id, void *user_data)
+{
+       DBG("_tts_utterance_completed_cb");
+       tts_view *this = NULL;
+       this = (tts_view*)user_data;
+       RETM_IF(NULL == this, "view is NULL");
+       int ret;
+       ret = tts_stop(this->tts_handle);
+       RETM_IF(ret != TTS_ERROR_NONE, "tts_stop fail > Error = %s", get_tts_error(ret));
+       this->is_utterance_completed = true;
+
+}
+
+static char* get_tts_state_str(tts_state_e state)
+{
+
+       char* state_str;
+       switch(state)
+       {
+               case TTS_STATE_CREATED:
+                       state_str = "TTS_STATE_CREATED";
+                       break;
+               case TTS_STATE_READY:
+                       state_str = "TTS_STATE_READY";
+                       break;
+               case TTS_STATE_PLAYING:
+                       state_str = "TTS_STATE_PLAYING";
+                       break;
+               case TTS_STATE_PAUSED:
+                       state_str = "TTS_STATE_PAUSED";
+                       break;
+               default:
+                       state_str = "UNKNOWN_STATE";
+                       break;
+       }
+       return state_str;
+}
+static void _btn_tts_pressed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       DBG("_btn_tts_pressed_cb");
+       tts_view *this = NULL;
+       this = (tts_view*)data;
+       RETM_IF(NULL == this, "view is NULL");
+       this->is_tts_btn_pressed = true;
+       int ret;
+       ret = tts_create(&this->tts_handle);
+       RETM_IF(ret != TTS_ERROR_NONE, "tts_create fail > Error = %s", get_tts_error(ret));
+       ret = tts_set_state_changed_cb(this->tts_handle, _tts_state_changed_cb, this);
+       RETM_IF(ret != TTS_ERROR_NONE, "tts_set_state_changed_cb fail > Error = %s", get_tts_error(ret));
+       ret = tts_foreach_supported_voices(this->tts_handle, _tts_supported_voice_cb, this);
+       RETM_IF(ret != TTS_ERROR_NONE, "tts_foreach_supported_voices fail > Error = %s", get_tts_error(ret));
+       ret = tts_set_utterance_completed_cb(this->tts_handle, _tts_utterance_completed_cb, this);
+       RETM_IF(ret != TTS_ERROR_NONE, "tts_set_utterance_completed_cb fail > Error = %s", get_tts_error(ret));
+       ret = tts_prepare(this->tts_handle);
+       RETM_IF(ret != TTS_ERROR_NONE, "tts_prepare fail > Error = %s", get_tts_error(ret));
+
+}
+
+
+/**
+ * @function           _app_destroy_cb
+ * @since_tizen                2.3
+ * @description                 App Destroy Cb
+ * @parameter          void*: Void Pointer
+ * @return             static void
+ */
+static void _app_destroy_cb(void* this)
+{
+       RETM_IF(NULL == this, "data is NULL");
+
+       tts_view *view = NULL;
+       view = (tts_view*)this;
+       RETM_IF(NULL == view, "view is NULL");
+
+       int ret;
+       ret = tts_destroy(view->tts_handle);
+       RETM_IF(ret != TTS_ERROR_NONE, "tts_destroy fail > Error = %s", get_tts_error(ret));
+
+       SAFE_DELETE(view->view);
+       SAFE_DELETE(view);
+}
+
+static char* get_tts_error(tts_error_e err)
+{
+       char* err_msg;
+
+       switch(err)
+       {
+       case TTS_ERROR_NONE:
+               err_msg = "TTS_ERROR_NONE";
+               break;
+       case TTS_ERROR_OUT_OF_MEMORY:
+               err_msg = "TTS_ERROR_OUT_OF_MEMORY";
+               break;
+       case TTS_ERROR_IO_ERROR:
+               err_msg = "TTS_ERROR_IO_ERROR";
+               break;
+       case TTS_ERROR_INVALID_PARAMETER:
+               err_msg = "TTS_ERROR_INVALID_PARAMETER";
+               break;
+       case TTS_ERROR_OUT_OF_NETWORK:
+               err_msg = "TTS_ERROR_OUT_OF_NETWORK";
+               break;
+       case TTS_ERROR_TIMED_OUT:
+               err_msg = "TTS_ERROR_TIMED_OUT";
+               break;
+       case TTS_ERROR_PERMISSION_DENIED:
+               err_msg = "TTS_ERROR_PERMISSION_DENIED";
+               break;
+       case TTS_ERROR_NOT_SUPPORTED:
+               err_msg = "TTS_ERROR_NOT_SUPPORTED";
+               break;
+       case TTS_ERROR_INVALID_STATE:
+               err_msg = "TTS_ERROR_INVALID_STATE";
+               break;
+       case TTS_ERROR_INVALID_VOICE:
+               err_msg = "TTS_ERROR_INVALID_VOICE";
+               break;
+       case TTS_ERROR_ENGINE_NOT_FOUND:
+               err_msg = "TTS_ERROR_ENGINE_NOT_FOUND";
+               break;
+       case TTS_ERROR_OPERATION_FAILED:
+               err_msg = "TTS_ERROR_OPERATION_FAILED";
+               break;
+       case TTS_ERROR_AUDIO_POLICY_BLOCKED:
+               err_msg = "TTS_ERROR_AUDIO_POLICY_BLOCKED";
+               break;
+       case TTS_ERROR_NOT_SUPPORTED_FEATURE:
+               err_msg = "TTS_ERROR_NOT_SUPPORTED_FEATURE";
+               break;
+       case TTS_ERROR_SERVICE_RESET:
+               err_msg = "TTS_ERROR_SERVICE_RESET";
+               break;
+       default:
+               err_msg = "UNKNOWN_ERROR";
+               break;
+       }
+
+       return err_msg;
+
+}
+
+#endif