[voice_assistant] Bugfix: Properly detect states where mic is running (#8745)

This commit is contained in:
Kevin Ahrendt 2025-05-11 15:50:47 -05:00 committed by GitHub
parent cdce59f7f9
commit 7f59aff157
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -695,12 +695,12 @@ void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) {
}
case api::enums::VOICE_ASSISTANT_RUN_END: {
ESP_LOGD(TAG, "Assist Pipeline ended");
if ((this->state_ == State::STARTING_PIPELINE) || (this->state_ == State::AWAITING_RESPONSE)) {
// Pipeline ended before starting microphone
// Or there wasn't a TTS start event ("nevermind")
this->set_state_(State::IDLE, State::IDLE);
} else if (this->state_ == State::STREAMING_MICROPHONE) {
this->ring_buffer_->reset();
if ((this->state_ == State::START_PIPELINE) || (this->state_ == State::STARTING_PIPELINE) ||
(this->state_ == State::STREAMING_MICROPHONE)) {
// Microphone is running, stop it
this->set_state_(State::STOP_MICROPHONE, State::IDLE);
} else if (this->state_ == State::AWAITING_RESPONSE) {
// No TTS start event ("nevermind")
this->set_state_(State::IDLE, State::IDLE);
}
this->defer([this]() { this->end_trigger_->trigger(); });