summaryrefslogtreecommitdiff
path: root/internal/processor/processor.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-02 22:03:06 +0300
committerPaul Buetow <paul@buetow.org>2026-04-02 22:03:06 +0300
commit730152379886f1a7dd7c36d68918706c82ad718d (patch)
treeb815da0bab529f1304d9f225cbd5a145535a7f06 /internal/processor/processor.go
parent74383d0e31fee5aebec002971ebd2cbddad32ac7 (diff)
task 00e: inject phonetic.Fetcher and translation.Translator into gui.New()
Add PhoneticFetcher and Translator fields to gui.Config so callers can inject ready-to-use instances. gui.New() uses the injected values when non-nil and falls back to constructing from provider/key fields otherwise. The processor composition root now builds both dependencies and sets them on gui.Config, keeping construction logic out of gui.New(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/processor/processor.go')
-rw-r--r--internal/processor/processor.go28
1 files changed, 24 insertions, 4 deletions
diff --git a/internal/processor/processor.go b/internal/processor/processor.go
index 54c99c3..c79e892 100644
--- a/internal/processor/processor.go
+++ b/internal/processor/processor.go
@@ -714,19 +714,39 @@ func (p *Processor) guiConfigForRunMode() *gui.Config {
imageProvider = gui.DefaultConfig().ImageProvider
}
+ openAIKey := cli.GetOpenAIKey()
+ googleAPIKey := cli.GetGoogleAPIKey()
+ translationProvider := translation.Provider(viper.GetString("translation.provider"))
+ phoneticProvider := phonetic.Provider(viper.GetString("phonetic.provider"))
+
+ // Construct and inject phonetic/translation dependencies at the composition root
+ // so gui.New() receives ready-to-use instances rather than raw config strings.
+ phoneticFetcher := phonetic.NewFetcher(&phonetic.Config{
+ Provider: phoneticProvider,
+ OpenAIKey: openAIKey,
+ GoogleAPIKey: googleAPIKey,
+ })
+ translator := translation.NewTranslator(&translation.Config{
+ Provider: translationProvider,
+ OpenAIKey: openAIKey,
+ GeminiModel: viper.GetString("translation.gemini_model"),
+ })
+
return &gui.Config{
AudioFormat: p.effectiveAudioFormat(),
AudioProvider: p.audioProviderName(),
ImageProvider: imageProvider,
- OpenAIKey: cli.GetOpenAIKey(),
- GoogleAPIKey: cli.GetGoogleAPIKey(),
+ OpenAIKey: openAIKey,
+ GoogleAPIKey: googleAPIKey,
NanoBananaModel: p.nanoBananaModelForRunMode(),
NanoBananaTextModel: p.nanoBananaTextModelForRunMode(),
GeminiTTSModel: p.geminiTTSModel(),
GeminiVoice: p.geminiVoice(),
- TranslationProvider: translation.Provider(viper.GetString("translation.provider")),
- PhoneticProvider: phonetic.Provider(viper.GetString("phonetic.provider")),
+ TranslationProvider: translationProvider,
+ PhoneticProvider: phoneticProvider,
AutoPlay: !p.flags.NoAutoPlay, // Invert the flag (--no-auto-play disables auto-play)
+ PhoneticFetcher: phoneticFetcher,
+ Translator: translator,
}
}