From 022c58bb8e3a734dfb824472ebc504e7362219b9 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 19 Jul 2025 22:56:57 +0300 Subject: fix: use default voice for initial generation, random for regeneration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Initial audio generation uses "alloy" voice with 0.98 speed - Regeneration uses random voice selection for variety - This ensures consistent initial experience while allowing variety on regeneration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- internal/gui/generator.go | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/internal/gui/generator.go b/internal/gui/generator.go index 7704fb3..3f2f252 100644 --- a/internal/gui/generator.go +++ b/internal/gui/generator.go @@ -85,15 +85,35 @@ func (a *Application) translateEnglishToBulgarian(word string) (string, error) { // generateAudio generates audio for a word func (a *Application) generateAudio(ctx context.Context, word string) (string, error) { - // Always use random voice and speed for variety - allVoices := []string{"alloy", "ash", "ballad", "coral", "echo", "fable", "onyx", "nova", "sage", "shimmer", "verse"} + // Check if this is a regeneration by looking for existing audio file + wordDir := a.findCardDirectory(word) + isRegeneration := false + if wordDir != "" { + audioFile := filepath.Join(wordDir, fmt.Sprintf("audio.%s", a.config.AudioFormat)) + if _, err := os.Stat(audioFile); err == nil { + isRegeneration = true + } + } + + // For regeneration, use random voice and speed; otherwise use defaults + var voice string + var speed float64 - // Select a random voice - rand.Seed(time.Now().UnixNano()) - voice := allVoices[rand.Intn(len(allVoices))] + if isRegeneration { + // Get available voices + allVoices := []string{"alloy", "ash", "ballad", "coral", "echo", "fable", "onyx", "nova", "sage", "shimmer", "verse"} - // Generate random speed between 0.90 and 1.00 - speed := 0.90 + rand.Float64()*0.10 + // Select a random voice + rand.Seed(time.Now().UnixNano()) + voice = allVoices[rand.Intn(len(allVoices))] + + // Generate random speed between 0.90 and 1.00 + speed = 0.90 + rand.Float64()*0.10 + } else { + // Use defaults for first generation + voice = "alloy" + speed = 0.98 + } // Update audio config with selected voice and speed a.audioConfig.OpenAIVoice = voice @@ -106,7 +126,7 @@ func (a *Application) generateAudio(ctx context.Context, word string) (string, e } // Find existing card directory or create new one again after provider creation - wordDir := a.findCardDirectory(word) + wordDir = a.findCardDirectory(word) if wordDir == "" { // No existing directory, create new one with card ID cardID := internal.GenerateCardID(word) -- cgit v1.2.3