forked from xiaozhi/xiaozhi-esp32
fix: resolve some audio issues on esp-hi (#1027)
* fix: resolve crash when closing codec dev on esp-hi * fix: fix incorrect status display in non-zh-CN languages * fix: reduce noise when not in Speaking state
This commit is contained in:
@@ -540,6 +540,12 @@ void AudioService::SetCallbacks(AudioServiceCallbacks& callbacks) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AudioService::PlaySound(const std::string_view& ogg) {
|
void AudioService::PlaySound(const std::string_view& ogg) {
|
||||||
|
if (!codec_->output_enabled()) {
|
||||||
|
esp_timer_stop(audio_power_timer_);
|
||||||
|
esp_timer_start_periodic(audio_power_timer_, AUDIO_POWER_CHECK_INTERVAL_MS * 1000);
|
||||||
|
codec_->EnableOutput(true);
|
||||||
|
}
|
||||||
|
|
||||||
const uint8_t* buf = reinterpret_cast<const uint8_t*>(ogg.data());
|
const uint8_t* buf = reinterpret_cast<const uint8_t*>(ogg.data());
|
||||||
size_t size = ogg.size();
|
size_t size = ogg.size();
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
|
|||||||
@@ -141,8 +141,7 @@ void AdcPdmAudioCodec::EnableInput(bool enable) {
|
|||||||
};
|
};
|
||||||
ESP_ERROR_CHECK(esp_codec_dev_open(input_dev_, &fs));
|
ESP_ERROR_CHECK(esp_codec_dev_open(input_dev_, &fs));
|
||||||
} else {
|
} else {
|
||||||
// ESP_ERROR_CHECK(esp_codec_dev_close(input_dev_));
|
ESP_ERROR_CHECK(esp_codec_dev_close(input_dev_));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
AudioCodec::EnableInput(enable);
|
AudioCodec::EnableInput(enable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
#include "mmap_generate_emoji.h"
|
#include "mmap_generate_emoji.h"
|
||||||
#include "emoji_display.h"
|
#include "emoji_display.h"
|
||||||
|
#include "assets/lang_config.h"
|
||||||
|
|
||||||
#include <esp_lcd_panel_io.h>
|
#include <esp_lcd_panel_io.h>
|
||||||
#include <freertos/FreeRTOS.h>
|
#include <freertos/FreeRTOS.h>
|
||||||
@@ -146,9 +147,9 @@ void EmojiWidget::SetEmotion(const char* emotion)
|
|||||||
void EmojiWidget::SetStatus(const char* status)
|
void EmojiWidget::SetStatus(const char* status)
|
||||||
{
|
{
|
||||||
if (player_) {
|
if (player_) {
|
||||||
if (strcmp(status, "聆听中...") == 0) {
|
if (strcmp(status, Lang::Strings::LISTENING) == 0) {
|
||||||
player_->StartPlayer(MMAP_EMOJI_ASKING_AAF, true, 15);
|
player_->StartPlayer(MMAP_EMOJI_ASKING_AAF, true, 15);
|
||||||
} else if (strcmp(status, "待命") == 0) {
|
} else if (strcmp(status, Lang::Strings::STANDBY) == 0) {
|
||||||
player_->StartPlayer(MMAP_EMOJI_WAKE_AAF, true, 15);
|
player_->StartPlayer(MMAP_EMOJI_WAKE_AAF, true, 15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "servo_dog_ctrl.h"
|
#include "servo_dog_ctrl.h"
|
||||||
#include "led_strip.h"
|
#include "led_strip.h"
|
||||||
#include "driver/rmt_tx.h"
|
#include "driver/rmt_tx.h"
|
||||||
|
#include "device_state_event.h"
|
||||||
|
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
@@ -284,13 +285,14 @@ private:
|
|||||||
ESP_LOGI(TAG, "Create emoji widget, panel: %p, panel_io: %p", panel, panel_io);
|
ESP_LOGI(TAG, "Create emoji widget, panel: %p, panel_io: %p", panel, panel_io);
|
||||||
display_ = new anim::EmojiWidget(panel, panel_io);
|
display_ = new anim::EmojiWidget(panel, panel_io);
|
||||||
|
|
||||||
|
#if CONFIG_ESP_CONSOLE_NONE
|
||||||
servo_dog_ctrl_config_t config = {
|
servo_dog_ctrl_config_t config = {
|
||||||
.fl_gpio_num = FL_GPIO_NUM,
|
.fl_gpio_num = FL_GPIO_NUM,
|
||||||
.fr_gpio_num = FR_GPIO_NUM,
|
.fr_gpio_num = FR_GPIO_NUM,
|
||||||
.bl_gpio_num = BL_GPIO_NUM,
|
.bl_gpio_num = BL_GPIO_NUM,
|
||||||
.br_gpio_num = BR_GPIO_NUM,
|
.br_gpio_num = BR_GPIO_NUM,
|
||||||
};
|
};
|
||||||
#if CONFIG_ESP_CONSOLE_NONE
|
|
||||||
servo_dog_ctrl_init(&config);
|
servo_dog_ctrl_init(&config);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -378,7 +380,7 @@ private:
|
|||||||
int r = properties["r"].value<int>();
|
int r = properties["r"].value<int>();
|
||||||
int g = properties["g"].value<int>();
|
int g = properties["g"].value<int>();
|
||||||
int b = properties["b"].value<int>();
|
int b = properties["b"].value<int>();
|
||||||
|
|
||||||
led_on_ = true;
|
led_on_ = true;
|
||||||
SetLedColor(r, g, b);
|
SetLedColor(r, g, b);
|
||||||
return true;
|
return true;
|
||||||
@@ -395,6 +397,11 @@ public:
|
|||||||
InitializeSpi();
|
InitializeSpi();
|
||||||
InitializeLcdDisplay();
|
InitializeLcdDisplay();
|
||||||
InitializeTools();
|
InitializeTools();
|
||||||
|
|
||||||
|
DeviceStateEventManager::GetInstance().RegisterStateChangeCallback([this](DeviceState previous_state, DeviceState current_state) {
|
||||||
|
ESP_LOGD(TAG, "Device state changed from %d to %d", previous_state, current_state);
|
||||||
|
this->GetAudioCodec()->EnableOutput(current_state == kDeviceStateSpeaking);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual AudioCodec* GetAudioCodec() override
|
virtual AudioCodec* GetAudioCodec() override
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ dependencies:
|
|||||||
espressif/esp_io_expander_tca95xx_16bit: ^2.0.0
|
espressif/esp_io_expander_tca95xx_16bit: ^2.0.0
|
||||||
espressif2022/image_player: ==1.1.0~1
|
espressif2022/image_player: ==1.1.0~1
|
||||||
espressif2022/esp_emote_gfx: ^1.0.0
|
espressif2022/esp_emote_gfx: ^1.0.0
|
||||||
espressif/adc_mic: ^0.2.0
|
espressif/adc_mic: ^0.2.1
|
||||||
espressif/esp_mmap_assets: '>=1.2'
|
espressif/esp_mmap_assets: '>=1.2'
|
||||||
txp666/otto-emoji-gif-component: ~1.0.2
|
txp666/otto-emoji-gif-component: ~1.0.2
|
||||||
espressif/adc_battery_estimation: ^0.2.0
|
espressif/adc_battery_estimation: ^0.2.0
|
||||||
|
|||||||
Reference in New Issue
Block a user