Bump to 1.4.0

This commit is contained in:
Terrence
2025-03-03 21:41:41 +08:00
parent 01aab961ca
commit 0f95444d62
2 changed files with 48 additions and 38 deletions

View File

@@ -4,7 +4,7 @@
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)
set(PROJECT_VER "1.3.1")
set(PROJECT_VER "1.4.0")
# Add this line to disable the specific warning
add_compile_options(-Wno-missing-field-initializers)

View File

@@ -236,18 +236,18 @@ void Application::PlaySound(const std::string_view& sound) {
}
void Application::ToggleChatState() {
Schedule([this]() {
if (device_state_ == kDeviceStateActivating) {
SetDeviceState(kDeviceStateIdle);
return;
}
if (device_state_ == kDeviceStateActivating) {
SetDeviceState(kDeviceStateIdle);
return;
}
if (!protocol_) {
ESP_LOGE(TAG, "Protocol not initialized");
return;
}
if (!protocol_) {
ESP_LOGE(TAG, "Protocol not initialized");
return;
}
if (device_state_ == kDeviceStateIdle) {
if (device_state_ == kDeviceStateIdle) {
Schedule([this]() {
SetDeviceState(kDeviceStateConnecting);
if (!protocol_->OpenAudioChannel()) {
return;
@@ -256,28 +256,32 @@ void Application::ToggleChatState() {
keep_listening_ = true;
protocol_->SendStartListening(kListeningModeAutoStop);
SetDeviceState(kDeviceStateListening);
} else if (device_state_ == kDeviceStateSpeaking) {
});
} else if (device_state_ == kDeviceStateSpeaking) {
Schedule([this]() {
AbortSpeaking(kAbortReasonNone);
} else if (device_state_ == kDeviceStateListening) {
});
} else if (device_state_ == kDeviceStateListening) {
Schedule([this]() {
protocol_->CloseAudioChannel();
}
});
});
}
}
void Application::StartListening() {
Schedule([this]() {
if (device_state_ == kDeviceStateActivating) {
SetDeviceState(kDeviceStateIdle);
return;
}
if (device_state_ == kDeviceStateActivating) {
SetDeviceState(kDeviceStateIdle);
return;
}
if (!protocol_) {
ESP_LOGE(TAG, "Protocol not initialized");
return;
}
keep_listening_ = false;
if (device_state_ == kDeviceStateIdle) {
if (!protocol_) {
ESP_LOGE(TAG, "Protocol not initialized");
return;
}
keep_listening_ = false;
if (device_state_ == kDeviceStateIdle) {
Schedule([this]() {
if (!protocol_->IsAudioChannelOpened()) {
SetDeviceState(kDeviceStateConnecting);
if (!protocol_->OpenAudioChannel()) {
@@ -286,23 +290,25 @@ void Application::StartListening() {
}
protocol_->SendStartListening(kListeningModeManualStop);
SetDeviceState(kDeviceStateListening);
} else if (device_state_ == kDeviceStateSpeaking) {
});
} else if (device_state_ == kDeviceStateSpeaking) {
Schedule([this]() {
AbortSpeaking(kAbortReasonNone);
protocol_->SendStartListening(kListeningModeManualStop);
// FIXME: Wait for the speaker to empty the buffer
vTaskDelay(pdMS_TO_TICKS(120));
SetDeviceState(kDeviceStateListening);
}
});
});
}
}
void Application::StopListening() {
Schedule([this]() {
if (device_state_ == kDeviceStateListening) {
if (device_state_ == kDeviceStateListening) {
Schedule([this]() {
protocol_->SendStopListening();
SetDeviceState(kDeviceStateIdle);
}
});
});
}
}
void Application::Start() {
@@ -794,10 +800,14 @@ void Application::WakeWordInvoke(const std::string& wake_word) {
}
});
} else if (device_state_ == kDeviceStateSpeaking) {
AbortSpeaking(kAbortReasonNone);
Schedule([this]() {
AbortSpeaking(kAbortReasonNone);
});
} else if (device_state_ == kDeviceStateListening) {
if (protocol_) {
protocol_->CloseAudioChannel();
}
Schedule([this]() {
if (protocol_) {
protocol_->CloseAudioChannel();
}
});
}
}