Fix prevent issue and Merge with master branch
authorKwangyoun Kim <ky85.kim@samsung.com>
Fri, 12 Apr 2013 08:41:14 +0000 (17:41 +0900)
committerKwangyoun Kim <ky85.kim@samsung.com>
Fri, 12 Apr 2013 08:41:14 +0000 (17:41 +0900)
Change-Id: I27275a679f97c895423299a4d15ca5d5fd458843

23 files changed:
CMakeLists.txt
changelog
client/CMakeLists.txt
client/stt.c
client/stt_dbus.c
client/stt_dbus.h
client/stt_setting.c
client/stt_setting.h
common/stt_defs.h
packaging/stt.spec
server/CMakeLists.txt
server/sttd_dbus.c
server/sttd_dbus_server.c
server/sttd_dbus_server.h
server/sttd_engine_agent.c
server/sttd_engine_agent.h
server/sttd_main.h
server/sttd_recorder.c
server/sttd_server.c
server/sttd_server.h
server/sttp.h
stt-server.rule
sysinfo-stt.xml [new file with mode: 0755]

index ea209e7..c1191cd 100755 (executable)
@@ -7,7 +7,7 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/common")
 ## Dependent packages ##
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED 
-       glib-2.0 dbus-1 vconf dlog ecore ecore-file capi-media-audio-io
+       glib-2.0 dbus-1 vconf dlog ecore ecore-file capi-media-audio-io capi-media-sound-manager
 )
 
 ## Client library ##
@@ -18,3 +18,4 @@ ADD_SUBDIRECTORY(server)
 
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.APLv2 RENAME stt DESTINATION /usr/share/license)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/stt-server.rule DESTINATION  /etc/smack/accesses2.d)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/sysinfo-stt.xml DESTINATION /etc/config)
index 54be60c..ac16674 100755 (executable)
--- a/changelog
+++ b/changelog
@@ -1,3 +1,38 @@
+stt (0.1.40-2) -- Fri, 12 Apr 2013
+
+  * Fix prevent issue (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.1.40-1) -- Wed, 10 Apr 2013
+
+  * Add file for sysinfo check (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.1.40) -- Fri, 05 Apr 2013
+  
+  * Release version 0.1.40 (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.1.39-3) -- Thu, 04 Apr 2013
+  
+  * Fix bug of recording close by silence (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.1.39-2) -- Mon, 01 Apr 2013
+  
+  * Add setting init api to change name (Dongyeol Lee <dy3.lee@samsung.com>)
+  
+stt (0.1.39-1) -- Mon, 01 Apr 2013
+  
+  * Update audio session for exclusive recording (Dongyeol Lee <dy3.lee@samsung.com>)
+  
+stt (0.1.39) -- Mon, 04 Mar 2013
+
+  * Add file recognition feature (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Fix prevent issue (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.1.1-38)
+
+  * Update smack rule
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Wed, 27 Feb 2013
 stt (0.1.1-37)
 
   * capi-audio-io is used
index 06e3cc7..0a15388 100755 (executable)
@@ -3,7 +3,7 @@ PROJECT(stt C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 SET(EXEC_PREFIX "${PREFIX}")
-SET(LIBDIR ${LIB_INSTALL_DIR})
+SET(LIBDIR "${PREFIX}/lib")
 SET(INCLUDEDIR "${PREFIX}/include")
 SET(VERSION 0.0.1)
 
@@ -62,7 +62,7 @@ CONFIGURE_FILE(stt.pc.in "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc" @ONLY)
 CONFIGURE_FILE(stt-setting.pc.in "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-setting.pc" @ONLY)
 
 ## Install library files ##
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
-INSTALL(TARGETS "${PROJECT_NAME}_setting" DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
-INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc" "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-setting.pc" DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT RuntimeLibraries)
+INSTALL(TARGETS "${PROJECT_NAME}_setting" DESTINATION lib COMPONENT RuntimeLibraries)
+INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc" "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-setting.pc" DESTINATION lib/pkgconfig)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/stt.h ${CMAKE_CURRENT_SOURCE_DIR}/stt_setting.h DESTINATION include)
index 836003f..76aa110 100755 (executable)
@@ -676,12 +676,15 @@ static int __stt_get_audio_volume(float* volume)
        FILE* fp = fopen(STT_AUDIO_VOLUME_PATH, "rb");
        if (!fp) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to open Volume File");
-               return -1;
+               return STT_ERROR_OPERATION_FAILED;
        }
 
-       fread((void*)volume, sizeof(*volume), 1, fp);
+       int readlen = fread((void*)volume, sizeof(*volume), 1, fp);
        fclose(fp);
 
+       if (0 == readlen)
+               *volume = 0.0f;
+
        return 0;
 }
 
@@ -715,6 +718,52 @@ int stt_get_recording_volume(stt_h stt, float* volume)
        return STT_ERROR_NONE;
 }
 
+int stt_start_file_recognition(stt_h stt, const char* filepath, const char* language, const char* type)
+{
+       if (NULL == stt || NULL == type || NULL == filepath) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       stt_client_s* client = stt_client_get(stt);
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+               return STT_ERROR_INVALID_PARAMETER;
+       } 
+
+       if (STT_STATE_READY != client->current_state) {
+               SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Invalid state : NO 'Ready' state");
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       char* temp;
+       if (NULL == language) {
+               temp = strdup("default");
+       } else {
+               temp = strdup(language);
+       }
+
+       int ret; 
+       ret = stt_dbus_request_start_file_recognition(client->uid, filepath, temp, type, client->profanity, client->punctuation);
+
+       if (ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to start");
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS]");
+
+               client->before_state = client->current_state;
+               client->current_state = STT_STATE_PROCESSING;
+
+               ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
+       }
+
+       free(temp);
+
+       return STT_ERROR_NONE;
+}
+
 static Eina_Bool __stt_notify_error(void *data)
 {
        stt_h stt = (stt_h)data;
index 516dc11..4925037 100755 (executable)
@@ -970,3 +970,70 @@ int stt_dbus_request_cancel(int uid)
 
        return result;
 }
+
+int stt_dbus_request_start_file_recognition(int uid, const char* filepath, const char* lang, const char* type, int profanity, int punctuation)
+{
+       if (NULL == filepath || NULL == lang || NULL == type) {
+               SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       DBusMessage* msg;
+
+       /* create a signal & check for errors */
+       msg = dbus_message_new_method_call(
+               STT_SERVER_SERVICE_NAME,
+               STT_SERVER_SERVICE_OBJECT_PATH, 
+               STT_SERVER_SERVICE_INTERFACE,   
+               STT_METHOD_START_FILE_RECONITION);              
+
+       if (NULL == msg) { 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt start file recognition : Fail to make message"); 
+               return STT_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt start file recogntion : uid(%d), filepath(%s) language(%s), type(%s)", 
+                       uid, filepath, lang, type);
+       }
+
+       dbus_message_append_args( msg, 
+               DBUS_TYPE_INT32, &uid, 
+               DBUS_TYPE_STRING, &filepath,
+               DBUS_TYPE_STRING, &lang,
+               DBUS_TYPE_STRING, &type,
+               DBUS_TYPE_INT32, &profanity,
+               DBUS_TYPE_INT32, &punctuation,
+               DBUS_TYPE_INVALID);
+
+       DBusError err;
+       dbus_error_init(&err);
+
+       DBusMessage* result_msg;
+       int result = STT_ERROR_OPERATION_FAILED;
+
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_start_time, &err);
+
+       if (NULL != result_msg) {
+               dbus_message_get_args(result_msg, &err,
+                       DBUS_TYPE_INT32, &result,
+                       DBUS_TYPE_INVALID);
+
+               if (dbus_error_is_set(&err)) { 
+                       printf("<<<< Get arguments error (%s)", err.message);
+                       dbus_error_free(&err); 
+                       result = STT_ERROR_OPERATION_FAILED;
+               }
+               dbus_message_unref(result_msg);
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTC, "<<<< Result Message is NULL");
+       }
+
+       if (0 == result) {
+               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt start file recognition : result = %d ", result);
+       } else {
+               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt start file recognition : result = %d ", result);
+       }
+
+       dbus_message_unref(msg);
+
+       return result;
+}
\ No newline at end of file
index 5e3e9ef..4208232 100755 (executable)
@@ -45,6 +45,7 @@ int stt_dbus_request_stop(int uid);
 
 int stt_dbus_request_cancel(int uid);
 
+int stt_dbus_request_start_file_recognition(int uid, const char* filepath, const char* lang, const char* type, int profanity, int punctuation);
 
 #ifdef __cplusplus
 }
index 72b5560..f6347b3 100755 (executable)
@@ -84,64 +84,7 @@ static Eina_Bool __stt_setting_connect_daemon(void *data)
        return EINA_FALSE;
 }
 
-int stt_setting_initialize ()
-{
-       SLOG(LOG_DEBUG, TAG_STTC, "===== Initialize STT Setting");
-
-       int ret = 0;
-       if (STT_SETTING_STATE_READY == g_state) {
-               SLOG(LOG_WARN, TAG_STTC, "[WARNING] STT Setting has already been initialized. \n");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-               return STT_SETTING_ERROR_NONE;
-       }
-
-       if (0 != stt_setting_dbus_open_connection()) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to open connection\n");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       }
-
-       /* Send hello */
-       if (0 != stt_setting_dbus_request_hello()) {
-               __check_setting_stt_daemon();
-       }
-
-       /* do request */
-       int i = 1;
-       while(1) {
-               ret = stt_setting_dbus_request_initialize();
-
-               if (STT_SETTING_ERROR_ENGINE_NOT_FOUND == ret) {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Engine not found");
-                       break;
-               } else if(ret) {
-                       sleep(1);
-                       if (i == 3) {
-                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection Time out");
-                               ret = STT_SETTING_ERROR_TIMED_OUT;                          
-                               break;
-                       }
-                       i++;
-               } else {
-                       /* success to connect stt-daemon */
-                       break;
-               }
-       }
-
-       if (STT_SETTING_ERROR_NONE == ret) {
-               g_state = STT_SETTING_STATE_READY;
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Initialize");
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTC, "=====");
-       SLOG(LOG_DEBUG, TAG_STTC, " ");
-
-       return ret;
-}
-
-int stt_setting_initialize_async(stt_setting_initialized_cb callback, void* user_data)
+int stt_setting_initialize(stt_setting_initialized_cb callback, void* user_data)
 {
        SLOG(LOG_DEBUG, TAG_STTC, "===== Initialize STT Setting");
 
index 903f203..d82473d 100755 (executable)
@@ -122,8 +122,7 @@ typedef void(*stt_setting_initialized_cb)(stt_setting_state_e state, stt_setting
 *
 * @see stt_setting_finalize()
 */
-int stt_setting_initialize(void);
-int stt_setting_initialize_async(stt_setting_initialized_cb callback, void* user_data);
+int stt_setting_initialize(stt_setting_initialized_cb callback, void* user_data);
 
 /**
 * @brief finalize stt setting and disconnect to stt-daemon. 
index 9af69ac..b97f9ab 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2012, 2013 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
@@ -50,6 +50,7 @@ extern "C" {
 #define STT_METHOD_START               "stt_method_start"
 #define STT_METHOD_STOP                        "stt_method_stop"
 #define STT_METHOD_CANCEL              "stt_method_cancel"
+#define STT_METHOD_START_FILE_RECONITION "stt_method_start_recognition"
 
 #define STTD_METHOD_RESULT             "sttd_method_result"
 #define STTD_METHOD_PARTIAL_RESULT     "sttd_method_partial_result"
index 5f079c7..82bc1be 100755 (executable)
@@ -1,10 +1,10 @@
 Name:       stt
 Summary:    Speech To Text client library and daemon
-Version:    0.1.1
+Version:    0.1.40
 Release:    1
 Group:      libs
 License:    Samsung
-Source0:    stt-0.1.1.tar.gz
+Source0:    %{name}-%{version}.tar.gz
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 BuildRequires:  pkgconfig(glib-2.0)
@@ -14,6 +14,7 @@ BuildRequires:  pkgconfig(ecore-file)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(vconf)
 BuildRequires:  pkgconfig(capi-media-audio-io)
+BuildRequires:  pkgconfig(capi-media-sound-manager)
 
 BuildRequires:  cmake
 
@@ -35,7 +36,7 @@ Speech To Text header files for STT development.
 
 
 %build
-%cmake .
+cmake . -DCMAKE_INSTALL_PREFIX=/usr
 make %{?jobs:-j%jobs}
 
 %install
@@ -50,6 +51,7 @@ mkdir -p %{buildroot}/usr/share/license
 %files
 %manifest stt-server.manifest
 /etc/smack/accesses2.d/stt-server.rule
+/etc/config/sysinfo-stt.xml
 %defattr(-,root,root,-)
 %{_libdir}/libstt.so
 %{_libdir}/libstt_setting.so
index 3d35d17..15ff446 100755 (executable)
@@ -3,7 +3,7 @@ PROJECT(stt-daemon)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 SET(EXEC_PREFIX "${PREFIX}")
-SET(LIBDIR ${LIB_INSTALL_DIR})
+SET(LIBDIR "${PREFIX}/lib")
 SET(INCLUDEDIR "${PREFIX}/include")
 SET(VERSION 0.0.1)
 
@@ -40,7 +40,6 @@ SET(CMAKE_C_FLAGS_RELEASE "-O2")
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
 
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
-ADD_DEFINITIONS("-DLIBDIR_PREFIX=\"${LIB_INSTALL_DIR}\"")
 
 ## Executable ##
 ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
@@ -49,4 +48,4 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} -ldl -lm ${pkgs_LDFLAGS})
 ## Install
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/sttp.h DESTINATION include)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/sttd.conf DESTINATION ${LIB_INSTALL_DIR}/voice/stt/1.0)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/sttd.conf DESTINATION lib/voice/stt/1.0)
index 206246d..28ed7ac 100755 (executable)
@@ -476,6 +476,8 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
        else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_CANCEL)) 
                sttd_dbus_server_cancel(conn, msg);
 
+       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_START_FILE_RECONITION)) 
+               sttd_dbus_server_start_file_recognition(conn, msg);
 
        /* setting event */
        else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_HELLO))
index 8344c98..4fe2e25 100755 (executable)
@@ -510,6 +510,68 @@ int sttd_dbus_server_cancel(DBusConnection* conn, DBusMessage* msg)
        return 0;
 }
 
+int sttd_dbus_server_start_file_recognition(DBusConnection* conn, DBusMessage* msg)
+{
+       DBusError err;
+       dbus_error_init(&err);
+
+       int uid;
+       char* filepath;
+       char* lang;
+       char* type;
+       int profanity;
+       int punctuation;
+       int ret = STTD_ERROR_OPERATION_FAILED;
+
+       dbus_message_get_args(msg, &err, 
+               DBUS_TYPE_INT32, &uid, 
+               DBUS_TYPE_STRING, &filepath,
+               DBUS_TYPE_STRING, &lang,
+               DBUS_TYPE_STRING, &type,
+               DBUS_TYPE_INT32, &profanity,
+               DBUS_TYPE_INT32, &punctuation,
+               DBUS_TYPE_INVALID);
+
+       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Start File Recognition");
+
+       if (dbus_error_is_set(&err)) { 
+               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt start file recognition : get arguments error (%s)", err.message);
+               dbus_error_free(&err); 
+               ret = STTD_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt start file recognition : uid(%d), filepath(%s), lang(%s), type(%s), profanity(%d), punctuation(%d)"
+                       , uid, filepath, lang, type, profanity, punctuation); 
+
+               ret = sttd_server_start_file_recognition(uid, filepath, lang, type,profanity, punctuation);
+       }
+
+       DBusMessage* reply;
+       reply = dbus_message_new_method_return(msg);
+
+       if (NULL != reply) {
+               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
+
+               if (0 == ret) {
+                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
+               }
+
+               if (!dbus_connection_send(conn, reply, NULL)) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
+               }
+
+               dbus_connection_flush(conn);
+               dbus_message_unref(reply);
+       } else {
+               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); 
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
+       SLOG(LOG_DEBUG, TAG_STTD, "  ");
+
+       return 0;
+}
 
 /*
 * Dbus Setting-Daemon Server
index e530a2e..4582016 100755 (executable)
@@ -46,6 +46,7 @@ int sttd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg);
 
 int sttd_dbus_server_cancel(DBusConnection* conn, DBusMessage* msg);
 
+int sttd_dbus_server_start_file_recognition(DBusConnection* conn, DBusMessage* msg);
 
 /*
 * Dbus Server functions for Setting
index 9521bdc..acd1ef6 100755 (executable)
@@ -991,7 +991,7 @@ int sttd_engine_recognize_start(const char* lang, const char* recognition_type,
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       if (0 != __set_option(profanity, punctuation, silence)) {
+       if (0 != __set_option(profanity, punctuation, g_default_silence_detected)) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set options"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
@@ -1130,6 +1130,53 @@ int sttd_engine_get_audio_format(sttp_audio_type_e* types, int* rate, int* chann
        return 0;
 }
 
+int sttd_engine_recognize_start_file(const char* filepath, const char* lang, const char* recognition_type, 
+                                    int profanity, int punctuation, void* user_param)
+{
+       if (false == g_agent_init) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
+               return STTD_ERROR_OPERATION_FAILED;
+       }
+
+       if (false == g_cur_engine.is_loaded) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
+               return STTD_ERROR_OPERATION_FAILED;
+       }
+
+       if (NULL == filepath || NULL == lang || NULL == recognition_type) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       if (0 != __set_option(profanity, punctuation, g_default_silence_detected)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set options"); 
+               return STTD_ERROR_OPERATION_FAILED;
+       }
+
+       if (NULL == g_cur_engine.pefuncs->start_file_recognition) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] start() of engine is NULL!!");
+               return STTD_ERROR_OPERATION_FAILED;
+       }
+
+       char* temp;
+       if (0 == strncmp(lang, "default", strlen("default"))) {
+               temp = strdup(g_cur_engine.default_lang);
+       } else {
+               temp = strdup(lang);
+       }
+
+       int ret = g_cur_engine.pefuncs->start_file_recognition(filepath, temp, recognition_type, user_param);
+       free(temp);
+
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to start file recognition(%d)", ret); 
+               return ret;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] File recognition");
+
+       return 0;
+}
 
 /*
 * STT Engine Interfaces for client and setting
index 83bb44f..e807c37 100755 (executable)
@@ -86,6 +86,8 @@ int sttd_engine_recognize_cancel();
 
 int sttd_engine_get_audio_format(sttp_audio_type_e* types, int* rate, int* channels);
 
+int sttd_engine_recognize_start_file(const char* filepath, const char* lang, const char* recognition_type, 
+                                    int profanity, int punctuation, void* user_param);
 
 /*
 * STT Engine Interfaces for setting
index 378dc13..3245197 100755 (executable)
@@ -34,9 +34,9 @@ extern "C" {
 
 #define TAG_STTD "sttd"
 
-#define BASE_DIRECTORY_DEFAULT         LIBDIR_PREFIX "/voice/stt/1.0/"
-#define ENGINE_DIRECTORY_DEFAULT       LIBDIR_PREFIX "/voice/stt/1.0/engine"
-#define ENGINE_DIRECTORY_DEFAULT_SETTING LIBDIR_PREFIX "/voice/stt/1.0/setting"
+#define BASE_DIRECTORY_DEFAULT                 "/usr/lib/voice/stt/1.0/"
+#define ENGINE_DIRECTORY_DEFAULT               "/usr/lib/voice/stt/1.0/engine"
+#define ENGINE_DIRECTORY_DEFAULT_SETTING       "/usr/lib/voice/stt/1.0/setting"
 
 #define CONFIG_DIRECTORY                       "/opt/home/app/.voice"
 
index 8bea200..6e0e340 100755 (executable)
@@ -83,12 +83,6 @@ int sttd_recorder_create(stt_recorder_audio_cb callback, sttp_audio_type_e type,
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       //ret = audio_in_ignore_session(g_audio_in_h);
-       //if (AUDIO_IO_ERROR_NONE != ret) {
-       //      SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to ignore session : %d", ret);
-       //      return STTD_ERROR_OPERATION_FAILED;
-       //}
-
        g_audio_cb = callback;
        g_recorder_state = STTD_RECORDER_STATE_READY;
        g_audio_type = type;
@@ -98,16 +92,27 @@ int sttd_recorder_create(stt_recorder_audio_cb callback, sttp_audio_type_e type,
 
 int sttd_recorder_destroy()
 {
-       if (STTD_RECORDER_STATE_RECORDING == g_recorder_state)
-               audio_in_unprepare(g_audio_in_h);
+       int ret;
+       if (STTD_RECORDER_STATE_RECORDING == g_recorder_state) {
+               ret = audio_in_unprepare(g_audio_in_h);
+               if (AUDIO_IO_ERROR_NONE != ret) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to unprepare audio_in");
+               }
+       }
 
-       audio_in_destroy(g_audio_in_h);
+       ret = audio_in_destroy(g_audio_in_h);
+       if (AUDIO_IO_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to destroy audio_in");
+       }
 
        g_audio_cb = NULL;
        g_recorder_state = -1;
 
-       if (0 == access(STT_AUDIO_VOLUME_PATH, R_OK)) 
-               remove(STT_AUDIO_VOLUME_PATH);
+       if (0 == access(STT_AUDIO_VOLUME_PATH, R_OK)) {
+               if (0 == remove(STT_AUDIO_VOLUME_PATH)) {
+                       SLOG(LOG_WARN, TAG_STTD, "[Recorder WARN] Fail to remove volume file"); 
+               }
+       }
 
        return 0;
 }
@@ -155,22 +160,23 @@ static float get_volume_decibel(char* data, int size, sttp_audio_type_e type)
 
 Eina_Bool __read_audio_func(void *data)
 {
-       int ret = -1;
+       int read_byte = -1;
 
        if (STTD_RECORDER_STATE_READY == g_recorder_state) {
                SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Exit audio reading func");
                return EINA_FALSE;
        }
 
-       ret = audio_in_read(g_audio_in_h, g_buffer, BUFFER_LENGTH);
-       if (0 > ret) {
-               SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Fail to read audio : %d", ret);
+       read_byte = audio_in_read(g_audio_in_h, g_buffer, BUFFER_LENGTH);
+       if (0 > read_byte) {
+               SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Fail to read audio : %d", read_byte);
                g_recorder_state = STTD_RECORDER_STATE_READY;
                return EINA_FALSE;
        }
 
-       if (0 != g_audio_cb(g_buffer, BUFFER_LENGTH)) {
-               g_recorder_state = STTD_RECORDER_STATE_READY;
+       if (0 != g_audio_cb(g_buffer, read_byte)) {
+               SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Fail audio callback");
+               sttd_recorder_stop();
                return EINA_FALSE;
        }
 
@@ -195,7 +201,7 @@ int sttd_recorder_start()
        int ret = -1; 
        ret = audio_in_prepare(g_audio_in_h);
        if (AUDIO_IO_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to start audio : %d", ret);
+               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to prepare audio in : %d", ret);
                return STTD_ERROR_OPERATION_FAILED;
        }
 
@@ -238,8 +244,7 @@ int sttd_recorder_stop()
        int ret = STTD_ERROR_OPERATION_FAILED; 
        ret = audio_in_unprepare(g_audio_in_h);
        if (AUDIO_IO_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to stop audio : %d", ret);
-               return STTD_ERROR_OPERATION_FAILED;
+               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to unprepare audio_in : %d", ret);
        }
 
        fclose(g_pFile_vol);
@@ -248,5 +253,6 @@ int sttd_recorder_stop()
        fclose(g_pFile);
 #endif 
 
+       SLOG(LOG_ERROR, TAG_STTD, "[Recorder] Recorder stop success");
        return 0;
 }
\ No newline at end of file
index 8269900..441bb81 100755 (executable)
@@ -11,7 +11,7 @@
 *  limitations under the License.
 */
 
-
+#include <sound_manager.h>
 #include "sttd_main.h"
 #include "sttd_server.h"
 
@@ -244,6 +244,13 @@ int sttd_initialize()
                g_is_engine = true;
        }
 
+       /* Set audio session */
+       ret = sound_manager_set_session_type(SOUND_SESSION_TYPE_EXCLUSIVE);
+       if (SOUND_MANAGER_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set sound session : result(%d)", ret);
+               return STTD_ERROR_OPERATION_FAILED;
+       }
+
        SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] initialize"); 
 
        return 0;
@@ -364,7 +371,7 @@ static Eina_Bool __quit_ecore_loop(void *data)
        return EINA_FALSE;
 }
 
-int sttd_server_finalize(const int uid)
+int sttd_server_finalize(int uid)
 {
        /* check if uid is valid */
        app_state_e state;
@@ -394,7 +401,7 @@ int sttd_server_finalize(const int uid)
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_get_supported_languages(const int uid, GList** lang_list)
+int sttd_server_get_supported_languages(int uid, GList** lang_list)
 {
        /* check if uid is valid */
        app_state_e state;
@@ -415,7 +422,7 @@ int sttd_server_get_supported_languages(const int uid, GList** lang_list)
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_get_current_langauage(const int uid, char** current_lang)
+int sttd_server_get_current_langauage(int uid, char** current_lang)
 {
        /* check if uid is valid */
        app_state_e state;
@@ -500,7 +507,7 @@ Eina_Bool __check_recording_state(void *data)
        return EINA_FALSE;
 }
 
-int sttd_server_start(const int uid, const char* lang, const char* recognition_type, 
+int sttd_server_start(int uid, const char* lang, const char* recognition_type, 
                      int profanity, int punctuation, int silence)
 {
        /* check if uid is valid */
@@ -598,7 +605,7 @@ Eina_Bool __time_out_for_processing(void *data)
 }
 
 
-int sttd_server_stop(const int uid)
+int sttd_server_stop(int uid)
 {
        /* check if uid is valid */
        app_state_e state;
@@ -640,7 +647,7 @@ int sttd_server_stop(const int uid)
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_cancel(const int uid)
+int sttd_server_cancel(int uid)
 {
        /* check if uid is valid */
        app_state_e state;
@@ -676,6 +683,72 @@ int sttd_server_cancel(const int uid)
        return STTD_ERROR_NONE;
 }
 
+int sttd_server_start_file_recognition(int uid, const char* filepath, const char* lang, const char* type, 
+                                      int profanity, int punctuation)
+{
+       /* check if uid is valid */
+       app_state_e state;
+       if (0 != sttd_client_get_state(uid, &state)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       /* check uid state */
+       if (APP_STATE_READY != state) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current state is not ready"); 
+               return STTD_ERROR_INVALID_STATE;
+       }
+
+       if (0 < sttd_client_get_current_recording()) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current STT Engine is busy because of recording");
+               return STTD_ERROR_RECORDER_BUSY;
+       }
+
+       if (0 < sttd_client_get_current_thinking()) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current STT Engine is busy because of thinking");
+               return STTD_ERROR_RECORDER_BUSY;
+       }
+
+       /* check if engine use network */
+       if (true == sttd_engine_agent_need_network()) {
+               if (false == sttd_network_is_connected()) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Disconnect network. Current engine needs to network connection.");
+                       return STTD_ERROR_OUT_OF_NETWORK;
+               }
+       }
+
+       /* engine start recognition */
+       int* user_data;
+       user_data = (int*)malloc( sizeof(int) * 1);
+
+       /* free on result callback */
+       *user_data = uid;
+
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server] start file recognition : uid(%d), filepath(%s), lang(%s), recog_type(%s)", 
+               *user_data, filepath, lang, type ); 
+
+       int ret = sttd_engine_recognize_start_file(filepath, (char*)lang, type, profanity, punctuation, (void*)user_data);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to start recognition : result(%d)", ret); 
+               return STTD_ERROR_OPERATION_FAILED;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server] start file recognition"); 
+
+       Ecore_Timer* timer;
+       sttd_cliet_get_timer(uid, &timer);
+
+       if (NULL != timer)
+               ecore_timer_del(timer);
+
+       /* change uid state */
+       sttd_client_set_state(uid, APP_STATE_PROCESSING);
+
+       timer = ecore_timer_add(g_state_check_time, __time_out_for_processing, NULL);
+       sttd_cliet_set_timer(uid, timer);
+
+       return STTD_ERROR_NONE;
+}
 
 /******************************************************************************************
 * STT Server Functions for setting
index 297e84d..6fe4c96 100755 (executable)
@@ -38,25 +38,27 @@ Eina_Bool sttd_cleanup_client(void *data);
 
 int sttd_server_initialize(int pid, int uid, bool* silence, bool* profanity, bool* punctuation);
 
-int sttd_server_finalize(const int uid);
+int sttd_server_finalize(int uid);
 
-int sttd_server_get_supported_languages(const int uid, GList** lang_list);
+int sttd_server_get_supported_languages(int uid, GList** lang_list);
 
-int sttd_server_get_current_langauage(const int uid, char** current_lang);
+int sttd_server_get_current_langauage(int uid, char** current_lang);
 
 int sttd_server_set_engine_data(int uid, const char* key, const char* value);
 
 int sttd_server_is_partial_result_supported(int uid, int* partial_result);
 
-int sttd_server_get_audio_volume(const int uid, float* current_volume);
+int sttd_server_get_audio_volume(int uid, float* current_volume);
 
-int sttd_server_start(const int uid, const char* lang, const char* recognition_type, 
+int sttd_server_start(int uid, const char* lang, const char* recognition_type, 
                        int profanity, int punctuation, int silence);
 
-int sttd_server_stop(const int uid);
+int sttd_server_stop(int uid);
 
-int sttd_server_cancel(const int uid);
+int sttd_server_cancel(int uid);
 
+int sttd_server_start_file_recognition(int uid, const char* filepath, const char* lang, const char* type, 
+                                      int profanity, int punctuation);
 /*
 * API for setting
 */
index 27c5d24..5f6814d 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2012, 2013 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
@@ -411,6 +411,28 @@ typedef int (* sttpe_stop)(void);
 typedef int (* sttpe_cancel)(void);
 
 /**
+* @brief Convert file to text.
+*
+* @param[in] filepath Sound file. 
+* @param[in] language A language. 
+* @param[in] type A recognition type. (e.g. #STTP_RECOGNITION_TYPE_FREE, #STTP_RECOGNITION_TYPE_WEB_SEARCH)
+* @param[in] user_data The user data to be passed to the callback function. 
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #STTP_ERROR_NONE Successful
+* @retval #STTP_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STTP_ERROR_INVALID_STATE Invalid state
+* @retval #STTP_ERROR_INVALID_LANGUAGE Invalid language
+* @retval #STTP_ERROR_OPERATION_FAILED Operation failed
+* @retval #STTP_ERROR_OUT_OF_NETWORK Out of network
+*
+* @pre The engine is not in recognition processing.
+*
+* @see sttpe_result_cb()
+*/
+typedef int (* sttpe_start_file_recognition)(const char* filepath, const char* language, const char* type, void *user_data);
+
+/**
 * @brief Gets setting information of the engine.
 *
 * @param[in] callback A callback function.
@@ -472,7 +494,8 @@ typedef struct {
        sttpe_set_recording_data        set_recording;          /**< Set recording data */
        sttpe_stop                      stop;                   /**< Shutdown function */
        sttpe_cancel                    cancel;                 /**< Cancel recognition or cancel thinking */
-               
+       sttpe_start_file_recognition    start_file_recognition; /**< Start file recognition */
+       
        /* Engine setting */
        sttpe_foreach_engine_settings   foreach_engine_settings;/**< Foreach engine specific info */
        sttpe_set_engine_setting        set_engine_setting;     /**< Set engine specific info */
index 49d540c..6aadbe6 100755 (executable)
@@ -1,5 +1,5 @@
 stt-server system::homedir rwx
-stt-server system::app_logging wx
+stt-server device::app_logging wx
 stt-server dbus rw
 stt-server system::vconf rwx
 stt-server system::share rwx
diff --git a/sysinfo-stt.xml b/sysinfo-stt.xml
new file mode 100755 (executable)
index 0000000..a60aec8
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>\r
+<sys-info>\r
+  <default>\r
+    <key id="stt-support" string="true"/>\r
+  </default>\r
+</sys-info>\r