mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 11:44:13 +01:00
b60c08dd28
* Add push to talk voice assistant * Refactor most code into voice_assistant * Make voice_assistant the component and remove push_to_talk (can be done in yaml) * Fix component setup * Always AF_INET to match serverside * Fix microphone and media player co-existence * Format * Update codeowners * Update test file * Fix endifs * nullptr not NULL * clang-tidy * Format * fixup: Add VA event data * Generate proto * Parse and log events * Add default to switch * Fix * Add mic/va to test5
33 lines
712 B
C++
33 lines
712 B
C++
#pragma once
|
|
|
|
#include "esphome/core/entity_base.h"
|
|
#include "esphome/core/helpers.h"
|
|
|
|
namespace esphome {
|
|
namespace microphone {
|
|
|
|
enum State : uint8_t {
|
|
STATE_STOPPED = 0,
|
|
STATE_STARTING,
|
|
STATE_RUNNING,
|
|
STATE_STOPPING,
|
|
};
|
|
|
|
class Microphone {
|
|
public:
|
|
virtual void start() = 0;
|
|
virtual void stop() = 0;
|
|
void add_data_callback(std::function<void(const std::vector<uint8_t> &)> &&data_callback) {
|
|
this->data_callbacks_.add(std::move(data_callback));
|
|
}
|
|
|
|
bool is_running() const { return this->state_ == STATE_RUNNING; }
|
|
|
|
protected:
|
|
State state_{STATE_STOPPED};
|
|
|
|
CallbackManager<void(const std::vector<uint8_t> &)> data_callbacks_{};
|
|
};
|
|
|
|
} // namespace microphone
|
|
} // namespace esphome
|