diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-02 17:46:07 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-02 17:46:07 +0300 |
| commit | f3d057fec20aeef584cb6340c6a002280a019f15 (patch) | |
| tree | 018be28f954243414969e8b8970fb3f3be8da112 /internal/processor/processor.go | |
| parent | 1fc2ade33b72dd299fc987943ddd09dee7c609ad (diff) | |
task 002: restore Gemini warning output
Diffstat (limited to 'internal/processor/processor.go')
| -rw-r--r-- | internal/processor/processor.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/processor/processor.go b/internal/processor/processor.go index f6eb706..2343120 100644 --- a/internal/processor/processor.go +++ b/internal/processor/processor.go @@ -28,6 +28,7 @@ type Processor struct { translator *translation.Translator translationCache *translation.TranslationCache phoneticFetcher *phonetic.Fetcher + randomIntn func(n int) int } var newOpenAIImageClient = func(config *image.OpenAIConfig) image.ImageSearcher { @@ -51,6 +52,7 @@ func NewProcessor(flags *cli.Flags) *Processor { translator: translation.NewTranslator(&translation.Config{Provider: translationProvider, OpenAIKey: openAIKey, GoogleAPIKey: googleAPIKey}), translationCache: translation.NewTranslationCache(), phoneticFetcher: phonetic.NewFetcher(&phonetic.Config{Provider: phoneticProvider, OpenAIKey: openAIKey, GoogleAPIKey: googleAPIKey}), + randomIntn: rand.Intn, } } @@ -317,12 +319,18 @@ func (p *Processor) audioVoiceForProvider() string { return voice } voices := p.audioVoicesForProvider() + if p.randomIntn != nil { + return voices[p.randomIntn(len(voices))] + } return voices[rand.Intn(len(voices))] default: if voice := p.openAIVoice(); voice != "" { return voice } voices := p.audioVoicesForProvider() + if p.randomIntn != nil { + return voices[p.randomIntn(len(voices))] + } return voices[rand.Intn(len(voices))] } } @@ -361,6 +369,8 @@ func (p *Processor) generateAudio(word string) error { fmt.Printf(" Retrying Gemini audio with voice: %s\n", candidate) } return p.generateAudioWithVoice(word, candidate) + }, func(candidate string) { + fmt.Printf(" Warning: Gemini returned no audio for voice %s\n", candidate) }) return err } @@ -411,6 +421,8 @@ func (p *Processor) generateAudioBgBg(front, back string) error { fmt.Printf(" Retrying Gemini audio with voice: %s\n", candidate) } return generatePair(candidate) + }, func(candidate string) { + fmt.Printf(" Warning: Gemini returned no audio for voice %s\n", candidate) }) return err } |
