Replace WAV with Opus encoding for Whisper API uploads: - Add libopus & libogg via FetchContent (no vcpkg dependency) - Implement AudioBuffer::saveToOpus() with Ogg container - Configure Opus encoder for voice (VOIP mode, 32kbps VBR) - Update WhisperClient to use Opus format (audio/ogg) - Fix Windows temp file path compatibility Benefits: - 46x smaller files (37KB vs 1.7MB for 10s audio) - Reduced API costs and bandwidth - Faster uploads for real-time translation - Whisper API fully supports Opus/Ogg format 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
29 lines
602 B
C++
29 lines
602 B
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
|
|
namespace secondvoice {
|
|
|
|
class AudioBuffer {
|
|
public:
|
|
AudioBuffer(int sample_rate, int channels);
|
|
|
|
void addSamples(const std::vector<float>& samples);
|
|
std::vector<float> getSamples() const;
|
|
void clear();
|
|
|
|
bool saveToWav(const std::string& filename) const;
|
|
bool saveToOpus(const std::string& filename) const;
|
|
|
|
size_t size() const { return samples_.size(); }
|
|
bool empty() const { return samples_.empty(); }
|
|
|
|
private:
|
|
int sample_rate_;
|
|
int channels_;
|
|
std::vector<float> samples_;
|
|
};
|
|
|
|
} // namespace secondvoice
|