Merge pull request #6122 from esphome/bump-2023.12.8

2023.12.8
This commit is contained in:
Jesse Hills 2024-01-20 04:22:36 +13:00 committed by GitHub
commit 1821ddd996
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 16 additions and 13 deletions

View file

@ -145,7 +145,7 @@ async def display_page_show_to_code(config, action_id, template_arg, args):
DisplayPageShowNextAction, DisplayPageShowNextAction,
maybe_simple_id( maybe_simple_id(
{ {
cv.Required(CONF_ID): cv.templatable(cv.use_id(DisplayBuffer)), cv.Required(CONF_ID): cv.templatable(cv.use_id(Display)),
} }
), ),
) )
@ -159,7 +159,7 @@ async def display_page_show_next_to_code(config, action_id, template_arg, args):
DisplayPageShowPrevAction, DisplayPageShowPrevAction,
maybe_simple_id( maybe_simple_id(
{ {
cv.Required(CONF_ID): cv.templatable(cv.use_id(DisplayBuffer)), cv.Required(CONF_ID): cv.templatable(cv.use_id(Display)),
} }
), ),
) )
@ -173,7 +173,7 @@ async def display_page_show_previous_to_code(config, action_id, template_arg, ar
DisplayIsDisplayingPageCondition, DisplayIsDisplayingPageCondition,
cv.maybe_simple_value( cv.maybe_simple_value(
{ {
cv.GenerateID(CONF_ID): cv.use_id(DisplayBuffer), cv.GenerateID(CONF_ID): cv.use_id(Display),
cv.Required(CONF_PAGE_ID): cv.use_id(DisplayPage), cv.Required(CONF_PAGE_ID): cv.use_id(DisplayPage),
}, },
key=CONF_PAGE_ID, key=CONF_PAGE_ID,

View file

@ -17,7 +17,7 @@ static const char *const TAG = "voice_assistant";
static const size_t SAMPLE_RATE_HZ = 16000; static const size_t SAMPLE_RATE_HZ = 16000;
static const size_t INPUT_BUFFER_SIZE = 32 * SAMPLE_RATE_HZ / 1000; // 32ms * 16kHz / 1000ms static const size_t INPUT_BUFFER_SIZE = 32 * SAMPLE_RATE_HZ / 1000; // 32ms * 16kHz / 1000ms
static const size_t BUFFER_SIZE = 1000 * SAMPLE_RATE_HZ / 1000; // 1s static const size_t BUFFER_SIZE = 1024 * SAMPLE_RATE_HZ / 1000;
static const size_t SEND_BUFFER_SIZE = INPUT_BUFFER_SIZE * sizeof(int16_t); static const size_t SEND_BUFFER_SIZE = INPUT_BUFFER_SIZE * sizeof(int16_t);
static const size_t RECEIVE_SIZE = 1024; static const size_t RECEIVE_SIZE = 1024;
static const size_t SPEAKER_BUFFER_SIZE = 16 * RECEIVE_SIZE; static const size_t SPEAKER_BUFFER_SIZE = 16 * RECEIVE_SIZE;
@ -231,10 +231,12 @@ void VoiceAssistant::loop() {
} }
case State::STREAMING_MICROPHONE: { case State::STREAMING_MICROPHONE: {
this->read_microphone_(); this->read_microphone_();
if (this->ring_buffer_->available() >= SEND_BUFFER_SIZE) { size_t available = this->ring_buffer_->available();
this->ring_buffer_->read((void *) this->send_buffer_, SEND_BUFFER_SIZE, 0); while (available >= SEND_BUFFER_SIZE) {
this->socket_->sendto(this->send_buffer_, SEND_BUFFER_SIZE, 0, (struct sockaddr *) &this->dest_addr_, size_t read_bytes = this->ring_buffer_->read((void *) this->send_buffer_, SEND_BUFFER_SIZE, 0);
this->socket_->sendto(this->send_buffer_, read_bytes, 0, (struct sockaddr *) &this->dest_addr_,
sizeof(this->dest_addr_)); sizeof(this->dest_addr_));
available = this->ring_buffer_->available();
} }
break; break;

View file

@ -1,6 +1,6 @@
"""Constants used by esphome.""" """Constants used by esphome."""
__version__ = "2023.12.7" __version__ = "2023.12.8"
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
VALID_SUBSTITUTIONS_CHARACTERS = ( VALID_SUBSTITUTIONS_CHARACTERS = (

View file

@ -15,17 +15,18 @@ std::unique_ptr<RingBuffer> RingBuffer::create(size_t len) {
std::unique_ptr<RingBuffer> rb = make_unique<RingBuffer>(); std::unique_ptr<RingBuffer> rb = make_unique<RingBuffer>();
ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE); ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE);
rb->storage_ = allocator.allocate(len); rb->storage_ = allocator.allocate(len + 1);
if (rb->storage_ == nullptr) { if (rb->storage_ == nullptr) {
return nullptr; return nullptr;
} }
rb->handle_ = xStreamBufferCreateStatic(len, 0, rb->storage_, &rb->structure_); rb->handle_ = xStreamBufferCreateStatic(len + 1, 0, rb->storage_, &rb->structure_);
ESP_LOGD(TAG, "Created ring buffer with size %u", len);
return rb; return rb;
} }
size_t RingBuffer::read(void *data, size_t size, TickType_t ticks_to_wait) { size_t RingBuffer::read(void *data, size_t len, TickType_t ticks_to_wait) {
return xStreamBufferReceive(this->handle_, data, size, ticks_to_wait); return xStreamBufferReceive(this->handle_, data, len, ticks_to_wait);
} }
size_t RingBuffer::write(void *data, size_t len) { size_t RingBuffer::write(void *data, size_t len) {

View file

@ -12,7 +12,7 @@ namespace esphome {
class RingBuffer { class RingBuffer {
public: public:
size_t read(void *data, size_t size, TickType_t ticks_to_wait = 0); size_t read(void *data, size_t len, TickType_t ticks_to_wait = 0);
size_t write(void *data, size_t len); size_t write(void *data, size_t len);