Skip to content

Commit

Permalink
Move setting global voice assistant to constructor (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
synesthesiam authored Oct 19, 2024
1 parent 5015b8d commit c3beb48
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions esphome/components/voice_assistant/voice_assistant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ static const size_t SEND_BUFFER_SIZE = INPUT_BUFFER_SIZE * sizeof(int16_t);
static const size_t RECEIVE_SIZE = 1024;
static const size_t SPEAKER_BUFFER_SIZE = 16 * RECEIVE_SIZE;

VoiceAssistant::VoiceAssistant() {
global_voice_assistant = this;
}

float VoiceAssistant::get_setup_priority() const { return setup_priority::AFTER_CONNECTION; }

bool VoiceAssistant::start_udp_socket_() {
Expand Down Expand Up @@ -70,12 +74,6 @@ bool VoiceAssistant::start_udp_socket_() {
return true;
}

void VoiceAssistant::setup() {
ESP_LOGCONFIG(TAG, "Setting up Voice Assistant...");

global_voice_assistant = this;
}

bool VoiceAssistant::allocate_buffers_() {
if (this->send_buffer_ != nullptr) {
return true; // Already allocated
Expand Down

0 comments on commit c3beb48

Please sign in to comment.