Complete implementation of the real-time Chinese-to-French translation system: Architecture: - 3-threaded pipeline: Audio capture → AI processing → UI rendering - Thread-safe queues for inter-thread communication - Configurable audio chunk sizes for latency tuning Core Features: - Audio capture with PortAudio (configurable sample rate/channels) - Whisper API integration for Chinese speech-to-text - Claude API integration for Chinese-to-French translation - ImGui real-time display with stop button - Full recording saved to WAV on stop Modules Implemented: - audio/: AudioCapture (PortAudio wrapper) + AudioBuffer (WAV export) - api/: WhisperClient + ClaudeClient (HTTP API wrappers) - ui/: TranslationUI (ImGui interface) - core/: Pipeline (orchestrates all threads) - utils/: Config (JSON/.env loader) + ThreadSafeQueue (template) Build System: - CMake with vcpkg for dependency management - vcpkg.json manifest for reproducible builds - build.sh helper script Configuration: - config.json: Audio settings, API parameters, UI config - .env: API keys (OpenAI + Anthropic) Documentation: - README.md: Setup instructions, usage, architecture - docs/implementation_plan.md: Technical design document - docs/SecondVoice.md: Project vision and motivation Next Steps: - Test build with vcpkg dependencies - Test audio capture on real hardware - Validate API integrations - Tune chunk size for optimal latency 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
70 lines
1.6 KiB
C++
70 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
|
|
namespace secondvoice {
|
|
|
|
struct AudioConfig {
|
|
int sample_rate;
|
|
int channels;
|
|
int chunk_duration_seconds;
|
|
std::string format;
|
|
};
|
|
|
|
struct WhisperConfig {
|
|
std::string model;
|
|
std::string language;
|
|
float temperature;
|
|
};
|
|
|
|
struct ClaudeConfig {
|
|
std::string model;
|
|
int max_tokens;
|
|
float temperature;
|
|
std::string system_prompt;
|
|
};
|
|
|
|
struct UIConfig {
|
|
int window_width;
|
|
int window_height;
|
|
int font_size;
|
|
int max_display_lines;
|
|
};
|
|
|
|
struct RecordingConfig {
|
|
bool save_audio;
|
|
std::string output_directory;
|
|
};
|
|
|
|
class Config {
|
|
public:
|
|
static Config& getInstance();
|
|
|
|
bool load(const std::string& config_path, const std::string& env_path);
|
|
|
|
const AudioConfig& getAudioConfig() const { return audio_config_; }
|
|
const WhisperConfig& getWhisperConfig() const { return whisper_config_; }
|
|
const ClaudeConfig& getClaudeConfig() const { return claude_config_; }
|
|
const UIConfig& getUIConfig() const { return ui_config_; }
|
|
const RecordingConfig& getRecordingConfig() const { return recording_config_; }
|
|
|
|
const std::string& getOpenAIKey() const { return openai_key_; }
|
|
const std::string& getAnthropicKey() const { return anthropic_key_; }
|
|
|
|
private:
|
|
Config() = default;
|
|
Config(const Config&) = delete;
|
|
Config& operator=(const Config&) = delete;
|
|
|
|
AudioConfig audio_config_;
|
|
WhisperConfig whisper_config_;
|
|
ClaudeConfig claude_config_;
|
|
UIConfig ui_config_;
|
|
RecordingConfig recording_config_;
|
|
|
|
std::string openai_key_;
|
|
std::string anthropic_key_;
|
|
};
|
|
|
|
} // namespace secondvoice
|