mirror of
https://github.com/esphome/esphome.git
synced 2025-04-15 15:20:27 +01:00
* 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
925 B
C++
33 lines
925 B
C++
#pragma once
|
|
|
|
#include "esphome/core/automation.h"
|
|
#include "microphone.h"
|
|
|
|
#include <vector>
|
|
|
|
namespace esphome {
|
|
namespace microphone {
|
|
|
|
template<typename... Ts> class CaptureAction : public Action<Ts...>, public Parented<Microphone> {
|
|
void play(Ts... x) override { this->parent_->start(); }
|
|
};
|
|
|
|
template<typename... Ts> class StopCaptureAction : public Action<Ts...>, public Parented<Microphone> {
|
|
void play(Ts... x) override { this->parent_->stop(); }
|
|
};
|
|
|
|
class DataTrigger : public Trigger<const std::vector<uint8_t> &> {
|
|
public:
|
|
explicit DataTrigger(Microphone *mic) {
|
|
mic->add_data_callback([this](const std::vector<uint8_t> &data) { this->trigger(data); });
|
|
}
|
|
};
|
|
|
|
template<typename... Ts> class IsCapturingActon : public Condition<Ts...>, public Parented<Microphone> {
|
|
public:
|
|
bool check(Ts... x) override { return this->parent_->is_running(); }
|
|
};
|
|
|
|
} // namespace microphone
|
|
} // namespace esphome
|