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 # CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16) 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 this line to disable the specific warning
add_compile_options(-Wno-missing-field-initializers) add_compile_options(-Wno-missing-field-initializers)

View File

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