PKG_CHECK_MODULES(VCONF REQUIRED vconf)
PKG_CHECK_MODULES(DB_UTIL_PKG REQUIRED db-util)
PKG_CHECK_MODULES(SQLITE3_PKG REQUIRED sqlite3)
+pkg_check_modules(CAPI_MEDIA_AUDIO_IO REQUIRED capi-media-audio-io)
#PKG_CHECK_MODULES(GRAPHICS_EXTENSION REQUIRED graphics-extension)
#PKG_CHECK_MODULES(WNOTI_SERVICE REQUIRED wnoti-service2)
#PKG_CHECK_MODULES(SAP_CLIENT_STUB_API REQUIRED sap-client-stub-api)
${SQLITE3_PKG_INCLUDE_DIRS}
${DATA_CONTROL_INCLUDE_DIRS}
${WNOTI_SERVICE_INCLUDE_DIRS}
- ${SAP_CLIENT_STUB_API_INCLUDE_DIRS})
+ ${SAP_CLIENT_STUB_API_INCLUDE_DIRS}
+ ${CAPI_MEDIA_AUDIO_IO_INCLUDE_DIRS})
LINK_DIRECTORIES(${DLOG_LIBRARY_DIRS}
${VCONF_LIBRARY_DIRS}
${WNOTI_SERVICE_LIBRARY_DIRS}
${SAP_CLIENT_STUB_API_LIBRARY_DIRS}
+ ${CAPI_MEDIA_AUDIO_IO_LIBRARY_DIRS}
)
ADD_EXECUTABLE(${W_INPUT_SELECTOR}
${DB_UTIL_PKG_LIBRARIES}
${SQLITE3_PKG_LIBRARIES}
${VCONF_LIBRARIES}
+ ${CAPI_MEDIA_AUDIO_IO_LIBRARIES}
)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE")
#include <assert.h>
#include <vconf.h>
#include <vconf-keys.h>
+#include <sound_manager.h>
#include "Debug.h"
#include "SttManager.h"
CREATE = 0x1000
};
+static sound_stream_info_h g_stream_info_h = NULL;
+
static inline const char *stt_state_str(stt_state_e cur) {
if (cur == STT_STATE_CREATED)
return (const char *) "STT_STATE_CREATED";
return (const char *) "ABNORMAL CASE";
}
+static void player_focus_state_cb(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *extra_info, void *user_data)
+{
+}
+
SttManager::SttManager(ISttFeedback& feedback)
: ifeedback(feedback),
iscancelled(false)
if(ret != STT_ERROR_NONE)
throw SttException(ret, ErrorString((stt_error_e)ret));
+ ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_VOICE_RECOGNITION, player_focus_state_cb, NULL, &g_stream_info_h);
+ if (SOUND_MANAGER_ERROR_NONE != ret) {
+ LOGW("Fail to create stream info. ret : %d", ret);
+ }
+
/**
* Set default properties
*
PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
stt_destroy(handle);
}
+
+ ReleaseSoundFocus();
+
+ sound_manager_destroy_stream_information(g_stream_info_h);
}
void SttManager::Prepare() {
*/
asrtype = STT_RECOGNITION_TYPE_FREE_PARTIAL;
int ret;
- ret = stt_start(handle, language.c_str(), asrtype.c_str());
+
+ ret = sound_manager_acquire_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
+ if (SOUND_MANAGER_ERROR_NONE != ret) {
+ LOGW("Fail to acquire focus. ret : %d, stream handle : %p", ret, g_stream_info_h);
+ }
+
+ ret = stt_start(handle, language.c_str(), asrtype.c_str());
if(ret != STT_ERROR_NONE)
throw SttException(ret, ErrorString((stt_error_e)ret));
SttManager& manager = *((SttManager *) user_data);
if (current== STT_STATE_READY) {
+ if (previous == STT_STATE_RECORDING ||
+ previous == STT_STATE_PROCESSING) {
+ ReleaseSoundFocus();
+ }
+
if (previous == STT_STATE_CREATED) {
manager.EnableSilenceDetection();
manager.ifeedback.AutoStart();
}
}
+void SttManager::ReleaseSoundFocus()
+{
+ int ret = sound_manager_release_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
+ if (SOUND_MANAGER_ERROR_NONE != ret) {
+ LOGW("Fail to release focus. ret : %d", ret);
+ }
+}