Hello, Xiaozhi.

This commit is contained in:
Terrence
2024-08-31 18:00:23 +08:00
parent 142653087f
commit 5da7d1755f
28 changed files with 2259 additions and 0 deletions

25
main/OpusEncoder.h Normal file
View File

@@ -0,0 +1,25 @@
#ifndef _OPUS_ENCODER_H_
#define _OPUS_ENCODER_H_
#include <functional>
#include <string>
#include "opus.h"
class OpusEncoder {
public:
OpusEncoder();
~OpusEncoder();
void Configure(int sample_rate, int channels, int duration_ms = 60);
void Encode(const void* pcm, size_t pcm_len, std::function<void(const void*, size_t)> handler);
bool IsBufferEmpty() const { return in_buffer_.empty(); }
private:
struct OpusEncoder* audio_enc_ = nullptr;
int frame_size_;
int out_size_;
uint8_t* out_buffer_ = nullptr;
std::string in_buffer_;
};
#endif // _OPUS_ENCODER_H_