1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-30 14:43:51 +00:00

[voice_assisant] support start/continue conversation and deallocate buffers (#8610)

This commit is contained in:
Kevin Ahrendt
2025-04-27 18:30:21 -05:00
committed by GitHub
parent ee646d7324
commit c9d1476ae0
2 changed files with 104 additions and 33 deletions

View File

@@ -41,6 +41,7 @@ enum VoiceAssistantFeature : uint32_t {
FEATURE_API_AUDIO = 1 << 2,
FEATURE_TIMERS = 1 << 3,
FEATURE_ANNOUNCE = 1 << 4,
FEATURE_START_CONVERSATION = 1 << 5,
};
enum class State {
@@ -140,6 +141,7 @@ class VoiceAssistant : public Component {
#ifdef USE_MEDIA_PLAYER
if (this->media_player_ != nullptr) {
flags |= VoiceAssistantFeature::FEATURE_ANNOUNCE;
flags |= VoiceAssistantFeature::FEATURE_START_CONVERSATION;
}
#endif
@@ -267,6 +269,8 @@ class VoiceAssistant : public Component {
#endif
#ifdef USE_MEDIA_PLAYER
media_player::MediaPlayer *media_player_{nullptr};
bool media_player_wait_for_announcement_start_{false};
bool media_player_wait_for_announcement_end_{false};
#endif
bool local_output_{false};
@@ -282,7 +286,7 @@ class VoiceAssistant : public Component {
uint8_t vad_threshold_{5};
uint8_t vad_counter_{0};
#endif
std::unique_ptr<RingBuffer> ring_buffer_;
std::shared_ptr<RingBuffer> ring_buffer_;
bool use_wake_word_;
uint8_t noise_suppression_level_;
@@ -296,6 +300,8 @@ class VoiceAssistant : public Component {
bool continuous_{false};
bool silence_detection_;
bool continue_conversation_{false};
State state_{State::IDLE};
State desired_state_{State::IDLE};