bool get_audio_format(int* rate, int* channel, int* audio_type);
bool get_audio_source_type(char** type);
bool set_language(string language);
- bool get_voice_key_pressed();
+ bool get_recording_by_voice_key();
+ void set_recording_by_voice_key(bool recording);
bool set_voice_key_tap_duration(float duration);
bool unset_voice_key_tap_duration();
bool set_voice_key_support_mode(VOICE_KEY_SUPPORT_MODE mode);
void stop_periodic_monitor_timer();
private:
- bool change_voice_key_status(ma_voice_key_status_e status);
-
class CEngineEventObserver : public IEngineEventObserver
{
public:
thread mEngineDataThread;
atomic_bool mStopEngineDataThread{false};
- bool mVoiceKeyPressed{false};
+ bool mRecordingByVoiceKey{false};
+
string mCurrentLanguage;
string mCurrentDefaultAssistant;
/* Assume Push-to-talk is the default mode */
return false;
mAudioManager.stop_recording(true);
+ mRecordingByVoiceKey = false;
change_manager_state(WAKEUP_MANAGER_STATE_INACTIVE);
stop_streaming_utterance_data();
return valid;
}
-bool CWakeupManager::get_voice_key_pressed()
+bool CWakeupManager::get_recording_by_voice_key()
{
- return mVoiceKeyPressed;
+ return mRecordingByVoiceKey;
+}
+
+void CWakeupManager::set_recording_by_voice_key(bool recording)
+{
+ mRecordingByVoiceKey = recording;
}
STREAMING_MODE CWakeupManager::get_streaming_mode()
return value.count();
}
-bool CWakeupManager::change_voice_key_status(ma_voice_key_status_e status) {
- for (const auto& observer : mWakeupObservers) {
- observer->on_voice_key_status_changed(status);
- }
- if (MA_VOICE_KEY_STATUS_PRESSED == status) {
- mVoiceKeyPressed = true;
- } else if (
- MA_VOICE_KEY_STATUS_RELEASED_AFTER_PUSH == status ||
- MA_VOICE_KEY_STATUS_RELEASED_AFTER_TAP == status) {
- mVoiceKeyPressed = false;
- }
- return true;
-}
-
bool CWakeupManager::process_plugin_event(mas_plugin_event_e event, void* data, int len)
{
MWR_LOGE("[ENTER] : %d", event);
}
if (start_recording) {
+ mRecordingByVoiceKey = true;
+
mAudioManager.stop_recording(true);
stop_streaming_utterance_data();
}
}
if (stop_recording) {
+ mRecordingByVoiceKey = false;
+
stop_streaming_duration_timer();
mAudioManager.finalize_audio_data();
}
if (next_voice_key_status) {
- change_voice_key_status(*next_voice_key_status);
+ for (const auto& observer : mWakeupObservers) {
+ observer->on_voice_key_status_changed(*next_voice_key_status);
+ }
}
MWR_LOGD("[END]");
case STREAMING_MODE::FOLLOW_UP:
audio_manager->stop_streaming_follow_up_data();
audio_manager->stop_recording(true);
+ wakeup_manager->set_recording_by_voice_key(false);
audio_manager->clear_audio_data();
break;
}
if (WAKEUP_MANAGER_STATE_UTTERANCE == wakeup_manager->get_manager_state()) {
audio_manager->stop_recording(true);
+ wakeup_manager->set_recording_by_voice_key(false);
audio_manager->set_recording_session(RECORDING_SESSION_WAKE_WORD);
if (engine_manager->get_audio_data_required()) {
/* Restart recorder thread using appropriate recording device */
if (WAKEUP_MANAGER_STATE_UTTERANCE == mWakeupManagerState) {
change_manager_state(WAKEUP_MANAGER_STATE_PROCESSING);
mAudioManager.stop_recording(true);
+ mRecordingByVoiceKey = false;
mAudioManager.set_recording_session(RECORDING_SESSION_WAKE_WORD);
if (mWakeupEngineManager.get_audio_data_required()) {
/* Restart recorder thread using appropriate recording device */
if (WAKEUP_MANAGER_STATE_UTTERANCE == mWakeupManagerState) {
change_manager_state(WAKEUP_MANAGER_STATE_PROCESSING);
mAudioManager.stop_recording(true);
+ mRecordingByVoiceKey = false;
mAudioManager.set_recording_session(RECORDING_SESSION_WAKE_WORD);
if (mWakeupEngineManager.get_audio_data_required()) {
/* Restart recorder thread using appropriate recording device */
if (audio_manager && engine_manager) {
if (engine_manager->get_audio_data_required()) {
- if (mWakeupManager->get_voice_key_pressed() != true) {
+ if (mWakeupManager->get_recording_by_voice_key() != true) {
audio_manager->set_recording_session(RECORDING_SESSION_WAKE_WORD);
audio_manager->start_recording(true);
}
} else {
- if (mWakeupManager->get_voice_key_pressed() != true) {
+ if (mWakeupManager->get_recording_by_voice_key() != true) {
audio_manager->stop_recording(true);
}
}
if (false == mEngineManager->get_audio_data_required()) return false;
- if (mWakeupManager->get_voice_key_pressed() != true) {
+ if (mWakeupManager->get_recording_by_voice_key() != true) {
/* When follow-up streaming in progress, no need to feed audio data to wakeup engines */
if (STREAMING_MODE::FOLLOW_UP != mWakeupManager->get_streaming_mode()) {
mEngineManager->engine_feed_audio_data(time, data, len);