From: wn.jang Date: Tue, 16 Jul 2019 01:44:42 +0000 (+0900) Subject: Add far field recognition X-Git-Tag: submit/tizen/20190902.090653~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cc0728043aa79ebabf5fd7b0c7572660515c4656;p=platform%2Fcore%2Fuifw%2Fstt.git Add far field recognition Change-Id: Iac1b08b1227cda6e55c68df97ab29b76965a5baa Signed-off-by: wn.jang --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 96613db..941cc0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,12 +38,12 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include") ## Dependent packages ## INCLUDE(FindPkgConfig) IF("${_TV_PRODUCT}" STREQUAL "TRUE") -pkg_check_modules(pkgs REQUIRED +pkg_check_modules(pkgs REQUIRED aul capi-media-audio-io capi-media-wav-player capi-network-bluetooth capi-network-bluetooth-tv capi-system-info cynara-client cynara-session - dbus-1 dlog ecore glib-2.0 libgum libtzplatform-config libxml-2.0 libsystemd-login vconf vconf-internal-keys buxton2 + dbus-1 dlog ecore glib-2.0 libgum libtzplatform-config libxml-2.0 libsystemd-login vconf vconf-internal-keys buxton2 farfield-voice-api ) ELSE() -pkg_check_modules(pkgs REQUIRED +pkg_check_modules(pkgs REQUIRED aul capi-media-audio-io capi-media-wav-player capi-system-info cynara-client cynara-session dbus-1 dlog ecore glib-2.0 libgum libtzplatform-config libxml-2.0 libsystemd-login vconf vconf-internal-keys buxton2 ) diff --git a/packaging/stt.spec b/packaging/stt.spec index 4828585..997054e 100644 --- a/packaging/stt.spec +++ b/packaging/stt.spec @@ -35,6 +35,7 @@ BuildRequires: pkgconfig(vconf) %if "%{tizen_profile_name}" == "tv" BuildRequires: pkgconfig(capi-network-bluetooth) BuildRequires: pkgconfig(capi-network-bluetooth-tv) +BuildRequires: pkgconfig(farfield-voice-api) %endif BuildRequires: cmake diff --git a/server/sttd_recorder.c b/server/sttd_recorder.c index e176a2e..90639b2 100644 --- a/server/sttd_recorder.c +++ b/server/sttd_recorder.c @@ -13,6 +13,7 @@ #ifdef TV_PRODUCT #define TV_BT_MODE +#define TV_FFV_MODE #endif #include @@ -24,6 +25,9 @@ #ifdef TV_BT_MODE #include #endif +#ifdef TV_FFV_MODE +#include +#endif #include "stt_defs.h" #include "sttd_dbus.h" @@ -66,6 +70,10 @@ static int g_buffer_count; static int g_stream_focus_id; +#ifdef TV_FFV_MODE +farfield_voice_h g_farfieldvoice_h = NULL; +#endif + /* Sound buf save for test */ /* #define BUF_SAVE_MODE @@ -132,6 +140,37 @@ static void _bt_hid_audio_data_receive_cb(bt_hid_voice_data_s *voice_data, void } #endif +#ifdef TV_FFV_MODE +static void _ffv_audio_function_cb(void* data, unsigned int length, void* user_data) +{ + if (0 == g_buffer_count % 50) { + SLOG(LOG_INFO, TAG_STTD, "[Recorder INFO] farfield audio function callback is invoked"); + + if (100000 == g_buffer_count) { + g_buffer_count = 0; + } + } + + g_buffer_count++; + + if (NULL != g_audio_cb) { + if (0 != g_audio_cb(data, length)) { + SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to read audio"); + sttd_recorder_stop(); + } + + if (NULL == g_recorder) { + SLOG(LOG_INFO, TAG_STTD, "[Recorder INFO] g_recoder is NULL"); + return; + } + + float vol_db = get_volume_decibel((char*)data, (int)length, g_recorder->audio_type); + if (0 != sttdc_send_set_volume(g_recorder->uid, vol_db)) { + SLOG(LOG_ERROR, TAG_STTD, "[Recorder] Fail to send recording volume(%f)", vol_db); + } + } +} +#endif const char* __stt_get_focus_changed_reason_code(sound_stream_focus_change_reason_e reason) { @@ -193,6 +232,16 @@ int sttd_recorder_initialize(stt_recorder_audio_cb audio_cb, stt_recorder_interr SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to add focus state watch callback"); } +#ifdef TV_FFV_MODE + g_farfieldvoice_h = farfield_voice_init(); + if (NULL == g_farfieldvoice_h) { + SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to init farfield_voice_init"); + } else { + SLOG(LOG_INFO, TAG_STTD, "[Recorder INFO] Register farfield voice audio callback"); + farfield_voice_register_audio_cb(g_farfieldvoice_h, _ffv_audio_function_cb, NULL); + } +#endif + #ifdef TV_BT_MODE if (BT_ERROR_NONE != bt_product_init()) { SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to init bt"); @@ -252,6 +301,15 @@ int sttd_recorder_deinitialize() } #endif +#ifdef TV_FFV_MODE + if (NULL != g_farfieldvoice_h) { + SLOG(LOG_INFO, TAG_STTD, "[Recorder INFO] Unregister farfield voice"); + farfield_voice_unregister_audio_cb(g_farfieldvoice_h); + farfield_voice_final(g_farfieldvoice_h); + g_farfieldvoice_h = NULL; + } +#endif + #ifdef TV_BT_MODE bt_hid_host_deinitialize();