mirror of
https://github.com/78/xiaozhi-esp32.git
synced 2026-02-19 18:38:09 +00:00
* add: Moji 2 has built-in ESP32-C5 dual band Wi-Fi * feat: PowerSaveTimer 160 >> 240 * fix(audio): add frame buffering to NoAudioProcessor On chips where CONFIG_USE_AUDIO_PROCESSOR is unavailable (e.g., ESP32-C5, which is excluded by Kconfig despite having PSRAM), NoAudioProcessor is used. The original implementation passed through 160-sample chunks directly, but the Opus encoder expects 960 samples (60ms @ 16kHz), resulting in frame size mismatch errors, high CPU usage, and watchdog resets. Added output_buffer_ to accumulate audio samples until reaching frame_samples_ (960) before outputting, matching AfeAudioProcessor behavior. other: Turn off sleep mode (PowerSaveTimer)
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
#ifndef DUMMY_AUDIO_PROCESSOR_H
|
|
#define DUMMY_AUDIO_PROCESSOR_H
|
|
|
|
#include <vector>
|
|
#include <functional>
|
|
#include <atomic>
|
|
|
|
#include "audio_processor.h"
|
|
#include "audio_codec.h"
|
|
|
|
class NoAudioProcessor : public AudioProcessor {
|
|
public:
|
|
NoAudioProcessor() = default;
|
|
~NoAudioProcessor() = default;
|
|
|
|
void Initialize(AudioCodec* codec, int frame_duration_ms, srmodel_list_t* models_list) override;
|
|
void Feed(std::vector<int16_t>&& data) override;
|
|
void Start() override;
|
|
void Stop() override;
|
|
bool IsRunning() override;
|
|
void OnOutput(std::function<void(std::vector<int16_t>&& data)> callback) override;
|
|
void OnVadStateChange(std::function<void(bool speaking)> callback) override;
|
|
size_t GetFeedSize() override;
|
|
void EnableDeviceAec(bool enable) override;
|
|
|
|
private:
|
|
AudioCodec* codec_ = nullptr;
|
|
int frame_samples_ = 0;
|
|
std::vector<int16_t> output_buffer_;
|
|
std::function<void(std::vector<int16_t>&& data)> output_callback_;
|
|
std::function<void(bool speaking)> vad_state_change_callback_;
|
|
std::atomic<bool> is_running_ = false;
|
|
};
|
|
|
|
#endif |