summaryrefslogtreecommitdiff
path: root/internal/processor/processor.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-02 08:27:06 +0300
committerPaul Buetow <paul@buetow.org>2026-04-02 08:27:06 +0300
commitfdee8dfa21f32b8981bd048b5620cb4772322990 (patch)
tree2865ea22257e0d25dd585eff360ce3c20b192579 /internal/processor/processor.go
parente905d0d7435a827825017c5612b6e61d1f1f5da7 (diff)
Fix Gemini voice selection in processor
Diffstat (limited to 'internal/processor/processor.go')
-rw-r--r--internal/processor/processor.go84
1 files changed, 51 insertions, 33 deletions
diff --git a/internal/processor/processor.go b/internal/processor/processor.go
index 92e7b29..ecd4c1a 100644
--- a/internal/processor/processor.go
+++ b/internal/processor/processor.go
@@ -291,36 +291,56 @@ func (p *Processor) geminiVoice() string {
return ""
}
+func (p *Processor) audioVoicesForProvider() []string {
+ switch p.audioProviderName() {
+ case "gemini":
+ return audio.GeminiVoices
+ default:
+ return audio.OpenAIVoices
+ }
+}
+
+func (p *Processor) audioVoiceForProvider() string {
+ switch p.audioProviderName() {
+ case "gemini":
+ if voice := p.geminiVoice(); voice != "" {
+ return voice
+ }
+ default:
+ if p.flags.OpenAIVoice != "" {
+ return p.flags.OpenAIVoice
+ }
+ }
+
+ voices := p.audioVoicesForProvider()
+ return voices[rand.Intn(len(voices))]
+}
+
// generateAudio generates audio files for a word
func (p *Processor) generateAudio(word string) error {
provider := p.audioProviderName()
- // Get list of voices to use.
+ // Get the provider-specific voice list.
var voices []string
- switch provider {
- case "gemini":
- if p.flags.AllVoices {
- voices = audio.GeminiVoices
- } else if voice := p.geminiVoice(); voice != "" {
- voices = []string{voice}
- fmt.Printf(" Using specified Gemini voice: %s\n", voice)
- } else {
- voices = []string{""}
- fmt.Printf(" Using Gemini model default voice\n")
- }
- default:
- if p.flags.AllVoices {
- voices = audio.OpenAIVoices
- } else if p.flags.OpenAIVoice != "" {
- // Use explicitly specified voice
- voices = []string{p.flags.OpenAIVoice}
- fmt.Printf(" Using specified voice: %s\n", p.flags.OpenAIVoice)
- } else {
- // Select a random voice
- randomVoice := audio.OpenAIVoices[rand.Intn(len(audio.OpenAIVoices))]
- voices = []string{randomVoice}
- fmt.Printf(" Using random voice: %s\n", randomVoice)
+ if p.flags.AllVoices {
+ voices = p.audioVoicesForProvider()
+ } else {
+ voice := p.audioVoiceForProvider()
+ switch provider {
+ case "gemini":
+ if p.geminiVoice() != "" {
+ fmt.Printf(" Using specified Gemini voice: %s\n", voice)
+ } else {
+ fmt.Printf(" Using random Gemini voice: %s\n", voice)
+ }
+ default:
+ if p.flags.OpenAIVoice != "" {
+ fmt.Printf(" Using specified voice: %s\n", voice)
+ } else {
+ fmt.Printf(" Using random voice: %s\n", voice)
+ }
}
+ voices = []string{voice}
}
// Generate audio for each voice
@@ -340,22 +360,20 @@ func (p *Processor) generateAudio(word string) error {
func (p *Processor) generateAudioBgBg(front, back string) error {
provider := p.audioProviderName()
- voice := ""
+ voice := p.audioVoiceForProvider()
switch provider {
case "gemini":
- voice = p.geminiVoice()
- if voice != "" {
- fmt.Printf(" Using Gemini voice: %s\n", voice)
+ if p.geminiVoice() != "" {
+ fmt.Printf(" Using specified Gemini voice: %s\n", voice)
} else {
- fmt.Printf(" Using Gemini model default voice\n")
+ fmt.Printf(" Using random Gemini voice: %s\n", voice)
}
default:
- // Select a random voice (same voice for both sides for consistency)
- voice = audio.OpenAIVoices[rand.Intn(len(audio.OpenAIVoices))]
if p.flags.OpenAIVoice != "" {
- voice = p.flags.OpenAIVoice
+ fmt.Printf(" Using specified voice: %s\n", voice)
+ } else {
+ fmt.Printf(" Using random voice: %s\n", voice)
}
- fmt.Printf(" Using voice: %s\n", voice)
}
// Find or create the word directory ONCE (for the front word)