bool set_assistant_enabled(string appid, bool enabled);
bool get_assistant_enabled(string appid);
bool set_default_assistant(string appid);
+ bool process_default_assistant_changed(string appid);
string get_default_assistant();
bool update_voice_feedback_state(string appid, bool state);
if (info.activated) {
try {
info.interface.activate();
+ MWR_LOGW("Activating wakeup engine : %s", info.engine_name.c_str());
} catch (const std::exception& e) {
MWR_LOGE("[ERROR] wakeup engine %s threw exception : %s",
info.engine_name.c_str(), e.what());
} else {
try {
info.interface.deactivate();
+ MWR_LOGW("Deactivating wakeup engine : %s", info.engine_name.c_str());
} catch (const std::exception& e) {
MWR_LOGE("[ERROR] wakeup engine %s threw exception : %s",
info.engine_name.c_str(), e.what());
if (0 != ret) {
/* empty queue */
- MWR_LOGD("[DEBUG] No feedback data. Waiting mode : %d", ret);
+ MWR_LOGD("[DEBUG] No feedback data. Waiting mode : %d %d", ret, cnt);
/* waiting */
while (!(mStopStreamingThread.load())) {
burst_count = 0;
this_thread::sleep_for(chrono::milliseconds(10));
if (index < interface->get_utterance_data_count()) {
- MWR_LOGD("[INFO] Resume thread");
+ MWR_LOGD("[INFO] Resume thread, %d", cnt);
break;
}
mStreamingHistory.last_count_fetched.store(get_current_milliseconds_after_epoch());
if (g_speech_pcm_wait_count < cnt) {
unsigned char final_buffer[2] = {'\0', };
- MWR_LOGE("[ERROR] Wrong request, there's no pcm data");
+ MWR_LOGE("[ERROR] Wrong request, there's no pcm data : %d", cnt);
#ifdef BUF_SAVE_MODE
if (g_pFile) {
fwrite(final_buffer, 1, sizeof(final_buffer), g_pFile);
void CWakeupEngineManager::engine_feed_audio_data(long time, void* data, int len)
{
+ bool print = false;
+ const std::chrono::seconds interval(3);
+ static auto last = std::chrono::steady_clock::now();
+ auto now = std::chrono::steady_clock::now();
+ if (now - last > interval) {
+ print = true;
+ last = now;
+ }
for (const auto& info : mEngineInfo) {
+ bool filtered_out = false;
if (info.activated &&
info.audio_data_require_status &&
info.interface.feed_audio_data) {
try {
- bool filtered_out = false;
/* After a wakeup event, wakeup engines other than the selected one
does not need to receive audio data. */
if (WAKEUP_MANAGER_STATE_UTTERANCE == mWakeupManagerState) {
}
if (!filtered_out) {
int ret = info.interface.feed_audio_data(time, data, len);
- if (0 != ret) {
- LOGE("[ERROR] Fail to feed speech data, ret(%d) : %s", ret, info.engine_name.c_str());
+ if (ret != 0 || print) {
+ LOGE("Feed speech data, ret(%d) : %s", ret, info.engine_name.c_str());
}
}
} catch (const std::exception& e) {
info.engine_name.c_str(), e.what());
}
}
+ if (print) {
+ MWR_LOGE("Feeding audio data to %s : %d %d %p %d",
+ info.engine_name.c_str(),
+ info.activated, info.audio_data_require_status,
+ info.interface.feed_audio_data, filtered_out);
+ }
}
}
if (false == mAssistantSupportsCurrentLanguage[appid]) {
activated = false;
}
- if (0 == appid.compare(mCurrentDefaultAssistant)) {
+ if (0 == appid.compare(mWakeupSettings.get_default_assistant_appid())) {
activated = true;
}
mWakeupEngineManager.set_assistant_activated(appid, activated);
bool CWakeupManager::set_default_assistant(string appid)
{
- MWR_LOGE("[ENTER] %s", appid.c_str());
+ MWR_LOGE("[ENTER] %s %s", appid.c_str(), mCurrentDefaultAssistant.c_str());
+
+ process_default_assistant_changed(appid);
+
+ mWakeupSettings.set_default_assistant_appid(appid);
+
+ return true;
+}
+
+bool CWakeupManager::process_default_assistant_changed(string appid)
+{
+ MWR_LOGE("[ENTER] %s %s", appid.c_str(), mCurrentDefaultAssistant.c_str());
+
+ if (mCurrentDefaultAssistant.compare(appid) == 0) {
+ MWR_LOGE("Default assistant appid not changed, ignoring...");
+ return false;
+ }
if (mWakeupManagerState == WAKEUP_MANAGER_STATE_UTTERANCE ||
mWakeupManagerState == WAKEUP_MANAGER_STATE_PROCESSING) {
- if (mCurrentDefaultAssistant.compare(appid) != 0) {
- update_recognition_result(mCurrentDefaultAssistant, MA_RECOGNITION_RESULT_EVENT_ERROR);
- }
+ update_recognition_result(mCurrentDefaultAssistant, MA_RECOGNITION_RESULT_EVENT_ERROR);
}
/* Check if previous default assistant has to be deactivated */
/* New default assistant has to be activated no matter what */
mWakeupEngineManager.set_assistant_activated(appid, true);
+
mCurrentDefaultAssistant = appid;
MWR_LOGD("[END]");
string CWakeupManager::get_default_assistant()
{
- return mCurrentDefaultAssistant;
+ return mWakeupSettings.get_default_assistant_appid();
}
bool CWakeupManager::get_assistant_enabled(string appid)
if (false == mAssistantEnabled[info.appid]) {
disable = true;
}
- if (0 == info.appid.compare(mCurrentDefaultAssistant)) {
+ if (0 == info.appid.compare(mWakeupSettings.get_default_assistant_appid())) {
/* Default Assistant should be activated no matter what */
disable = false;
}
wakeup_info.wakeup_end_time = get_current_milliseconds_after_epoch();
wakeup_info.wakeup_engine = WAKEUP_ENGINE_VOICE_KEY;
- wakeup_info.wakeup_appid = mCurrentDefaultAssistant.c_str();
+ std::string default_assistant_appid = mWakeupSettings.get_default_assistant_appid();
+ wakeup_info.wakeup_appid = default_assistant_appid.c_str();
MWR_LOGD("wakeup_appid : %s", wakeup_info.wakeup_appid);
set_last_wakeup_event_info(wakeup_info);
bool CWakeupManager::set_voice_key_support_mode(VOICE_KEY_SUPPORT_MODE mode)
{
+ MWR_LOGI("Voice key support mode : %d", mode);
mCurrentVoiceKeySupportMode = mode;
return true;
}
if (nullptr == audio_manager || nullptr == engine_manager || nullptr == settings) return;
if (wakeup_info.wakeup_appid && strlen(wakeup_info.wakeup_appid) > 0) {
- settings->set_default_assistant_appid(wakeup_info.wakeup_appid);
+ mWakeupManager->set_default_assistant(wakeup_info.wakeup_appid);
}
mWakeupManager->stop_streaming_utterance_data();
const char* appid)
{
if (nullptr == mWakeupManager || nullptr == appid) return false;
- mWakeupManager->set_default_assistant(std::string(appid));
+ mWakeupManager->process_default_assistant_changed(std::string(appid));
vector<ISettingValueObserver*> observers = mWakeupManager->get_setting_observers();
for (const auto& observer : observers) {
observer->on_value_changed();
#include <memory>
+#if 0
+#define BUF_SAVE_MODE
+#endif
+#if 0
+#define BUF_LOAD_MODE
+#endif
+
+#ifdef BUF_SAVE_MODE
+static char g_temp_file_name[128] = {'\0', };
+
+static FILE* g_pFile = NULL;
+
+static int g_count = 1;
+#endif
+
+#ifdef BUF_LOAD_MODE
+static FILE* g_pFile = NULL;
+#endif
+
using namespace multiassistant::wakeup;
static wakeup_service_wakeup_event_cb g_wakeup_event_cb;
static std::unique_ptr<CSettingValueObserver> g_setting_value_observer;
static std::unique_ptr<CWakeupManager> g_wakeup_manager;
+int wakeup_manager_feed_audio_data(mas_speech_streaming_event_e event, void* buffer, int len);
+
+#ifdef BUF_LOAD_MODE
+static Eina_Bool file_read_feed(void *data)
+{
+ if (g_pFile == NULL) {
+ g_pFile = fopen("/tmp/ma_feed_file", "rb");
+ if (g_pFile == NULL) return EINA_FALSE;
+ }
+
+ if (feof(g_pFile)) {
+ fclose(g_pFile);
+ return EINA_FALSE;
+ }
+
+ const size_t BUFFER_SIZE = 4096;
+ unsigned char buffer[BUFFER_SIZE];
+ size_t len = fread(buffer, sizeof(unsigned char), BUFFER_SIZE, g_pFile);
+ wakeup_manager_feed_audio_data(MAS_SPEECH_STREAMING_EVENT_CONTINUE, buffer, len);
+
+ return EINA_TRUE;
+}
+#endif
+
int wakeup_manager_initialize(void)
{
MWR_LOGI("[ENTER]");
g_wakeup_manager->initialize();
MWR_LOGD("[END]");
+
+#ifdef BUF_SAVE_MODE
+ if (g_pFile) {
+ fclose(g_pFile);
+ g_pFile = NULL;
+ } else {
+ MWR_LOGD("[Recorder Info] File not found!");
+ }
+
+ while (1) {
+ snprintf(g_temp_file_name, sizeof(g_temp_file_name), "/tmp/wakeup_manager_%d_%d", getpid(), g_count);
+ int ret = access(g_temp_file_name, 0);
+
+ if (0 == ret) {
+ MWR_LOGD("[Recorder ERROR] File is already exist");
+ if (0 == remove(g_temp_file_name)) {
+ MWR_LOGD("[Recorder] Remove file");
+ break;
+ } else {
+ g_count++;
+ }
+ } else {
+ break;
+ }
+ }
+
+ MWR_LOGD("[Recorder] Temp file name=[%s]", g_temp_file_name);
+
+ /* open test file */
+ g_pFile = fopen(g_temp_file_name, "wb+x");
+ if (!g_pFile) {
+ MWR_LOGD("[Recorder ERROR] File not found!");
+ }
+ g_count++;
+#endif
+
+#ifdef BUF_LOAD_MODE
+ Ecore_Timer* timer = ecore_timer_add(0.01f, file_read_feed, NULL);
+#endif
return 0;
}
{
MWR_LOGI("[ENTER]");
+#ifdef BUF_SAVE_MODE
+ if (g_pFile) {
+ MWR_LOGE("[Recorder SUCCESS] File Close");
+ fclose(g_pFile);
+ g_pFile = NULL;
+ }
+#endif
+
if (nullptr == g_wakeup_manager) return -1;
try {
{
if (nullptr == g_wakeup_manager) return -1;
+#ifdef BUF_SAVE_MODE
+ static int num = 0;
+ const int MAXIMUM_NUM = 1000;
+ if (g_pFile && num++ < MAXIMUM_NUM)
+ fwrite(buffer, 1, len, g_pFile);
+#endif
+
g_wakeup_manager->feed_audio_data(event, buffer, len);
return 0;
{
char *vconf_str;
vconf_str = vconf_get_str(WAKEUP_SETTINGS_KEY_DEFAULT_ASSISTANT_APPID);
- MWR_LOGD("default_assistant_appid : %s", vconf_str);
+ MWR_LOGD("vconf default_assistant_appid : %s", vconf_str);
if (vconf_str) {
mDefaultAssistantAppid = vconf_str;
- MWR_LOGD("default_assistant_appid : %s", mDefaultAssistantAppid.c_str());
+ MWR_LOGD("member default_assistant_appid : %s", mDefaultAssistantAppid.c_str());
free(vconf_str);
vconf_str = nullptr;
}
void CWakeupSettings::set_default_assistant_appid(std::string appid)
{
+ if (appid.compare(get_default_assistant_appid()) == 0) {
+ MWR_LOGE("Default assistant appid not changed, ignoring...");
+ return;
+ }
int ret = vconf_set_str(WAKEUP_SETTINGS_KEY_DEFAULT_ASSISTANT_APPID, appid.c_str());
MWR_LOGD("default_assistant_appid : %s, %d", appid.c_str(), ret);
mDefaultAssistantAppid = appid;
ma_client_s* CClientManager::find_client_by_appid(std::string appid)
{
- MAS_LOGD("Looking for client with appid : %s", appid.c_str());
ma_client_s *data = NULL;
int count = g_slist_length(mClientList);
if (NULL != data) {
if (0 == appid.compare(data->appid)) {
- MAS_LOGD("Found client : %s %d", data->appid.c_str(), data->pid);
return data;
}
}
}
- MAS_LOGE("[ERROR] client Not found");
+ MAS_LOGE("[ERROR] client Not found : %s", appid.c_str());
return NULL;
}
pid_t CClientManager::find_client_pid_by_appid(std::string appid)
{
- MAS_LOGD("Checking PID of appid : %s", appid.c_str());
pid_t pid = -1;
if (nullptr == mApplicationManager) {
ma_client_s* client = find_client_by_appid(appid);
if (client) {
- MAS_LOGD("Found client : %s %d", client->appid.c_str(), client->pid);
bool running = mApplicationManager->is_application_running(client->pid);
if (false == running) {
MAS_LOGE("The PID for %s was %d, but it seems to be terminated",
int CServiceMain::set_current_client_by_wakeup_word(const char *wakeup_word)
{
+ LOGI("[ENTER] %s", wakeup_word);
+
int loop;
int ret = -1;
int prev_selection = mCurrentClientInfo;
int CServiceMain::set_current_client_by_appid(const char *appid)
{
+ LOGI("[ENTER] %s", appid);
+
int ret = -1;
int prev_selection = mCurrentClientInfo;
int CServiceMain::launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode)
{
+ LOGI("[ENTER] %s", appid);
int result = 0;
if (NULL == appid || 0 == strlen(appid)) {
}
}
}
- MAS_LOGD("mWakeupClientAppId : %s, %d", mWakeupClientAppId.c_str(), found);
+ MAS_LOGE("mWakeupClientAppId : %s, %d", mWakeupClientAppId.c_str(), found);
}
return result;
int CServiceMain::bring_client_to_foreground(const char* appid)
{
+ LOGI("[ENTER]");
int ret = 0;
if (NULL == appid || 0 == strlen(appid)) {
int CServiceMain::prelaunch_default_assistant()
{
+ LOGI("[ENTER]");
/* CHECK NEEDED : should the code segment below and activation logic above be moved to wakeup manger? */
boost::optional<bool> prelaunch_mode =
mPreferenceManager.get_bool(WAKEUP_SETTINGS_KEY_PRELAUNCH_MODE);
int CServiceMain::update_voice_key_support_mode()
{
+ LOGI("[ENTER]");
/* CHECK NEEDED : should the code segment below and activation logic above be moved to wakeup manger? */
bool successful = false;
const char *default_assistant = NULL;
for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
ClientInfoItems *items = mClientInfo.getItems();
if (items[loop].used) {
+ LOGI("APPID : %s", items[loop].appid);
if (default_assistant &&
strncmp(default_assistant, items[loop].appid, MAX_APPID_LEN) == 0) {
float duration = items[loop].voice_key_tap_duration;
}
if (!successful) {
+ LOGE("VOICE KEY SUPPORT MODE update not successful!!!");
mServicePlugin.unset_voice_key_tap_duration();
mServicePlugin.set_voice_key_support_mode(VOICE_KEY_SUPPORT_MODE_NONE);
}