forked from xiaozhi/xiaozhi-esp32
Bump to 1.4.0
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user