## 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 ##
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)
+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
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)
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)
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;
}
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;
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
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
}
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");
*
* @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.
/*
-* 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
#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"
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)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(capi-media-audio-io)
+BuildRequires: pkgconfig(capi-media-sound-manager)
BuildRequires: cmake
%build
-%cmake .
+cmake . -DCMAKE_INSTALL_PREFIX=/usr
make %{?jobs:-j%jobs}
%install
%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
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)
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})
## 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)
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))
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
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
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;
}
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
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
#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"
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;
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;
}
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;
}
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;
}
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);
fclose(g_pFile);
#endif
+ SLOG(LOG_ERROR, TAG_STTD, "[Recorder] Recorder stop success");
return 0;
}
\ No newline at end of file
* limitations under the License.
*/
-
+#include <sound_manager.h>
#include "sttd_main.h"
#include "sttd_server.h"
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;
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;
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;
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;
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 */
}
-int sttd_server_stop(const int uid)
+int sttd_server_stop(int uid)
{
/* check if uid is valid */
app_state_e state;
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;
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
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
*/
/*
-* 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
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.
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 */
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
--- /dev/null
+<?xml version="1.0"?>\r
+<sys-info>\r
+ <default>\r
+ <key id="stt-support" string="true"/>\r
+ </default>\r
+</sys-info>\r