forked from xiaozhi/xiaozhi-esp32
* read frame duration from server * fit wechat style emoji size * Make Wechat UI look better * Add Realtime Chat to ESP-BOX-3/LichuangDev * disable debug log * Fix Sh1106 Compile Error Bug. IDF 5.3.2 Not supporting sh1106-esp-idf. (#424) * Fix ESP32 Board Led No Light Bug (#427) * add board esp32-s3-touch-lcd-3.5 (#415) * add board esp32-s3-touch-lcd-3.5 * add axp2101 --------- Co-authored-by: flyingtjy <flyingtjy@gmail.com> --------- Co-authored-by: ooxxU <71391474@qq.com> Co-authored-by: flying1425 <79792003+flying1425@users.noreply.github.com> Co-authored-by: flyingtjy <flyingtjy@gmail.com>
42 lines
1.0 KiB
C++
42 lines
1.0 KiB
C++
#ifndef AUDIO_PROCESSOR_H
|
|
#define AUDIO_PROCESSOR_H
|
|
|
|
#include <esp_afe_sr_models.h>
|
|
#include <freertos/FreeRTOS.h>
|
|
#include <freertos/task.h>
|
|
#include <freertos/event_groups.h>
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <functional>
|
|
|
|
#include "audio_codec.h"
|
|
|
|
class AudioProcessor {
|
|
public:
|
|
AudioProcessor();
|
|
~AudioProcessor();
|
|
|
|
void Initialize(AudioCodec* codec, bool realtime_chat);
|
|
void Feed(const std::vector<int16_t>& data);
|
|
void Start();
|
|
void Stop();
|
|
bool IsRunning();
|
|
void OnOutput(std::function<void(std::vector<int16_t>&& data)> callback);
|
|
void OnVadStateChange(std::function<void(bool speaking)> callback);
|
|
size_t GetFeedSize();
|
|
|
|
private:
|
|
EventGroupHandle_t event_group_ = nullptr;
|
|
esp_afe_sr_iface_t* afe_iface_ = nullptr;
|
|
esp_afe_sr_data_t* afe_data_ = nullptr;
|
|
std::function<void(std::vector<int16_t>&& data)> output_callback_;
|
|
std::function<void(bool speaking)> vad_state_change_callback_;
|
|
AudioCodec* codec_ = nullptr;
|
|
bool is_speaking_ = false;
|
|
|
|
void AudioProcessorTask();
|
|
};
|
|
|
|
#endif
|