summaryrefslogtreecommitdiff
path: root/internal/gui
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-07-19 22:56:57 +0300
committerPaul Buetow <paul@buetow.org>2025-07-19 22:56:57 +0300
commit022c58bb8e3a734dfb824472ebc504e7362219b9 (patch)
tree965cb106c7b0ddbd909adcbaa171a083c0626e0a /internal/gui
parent15f376c8aa3c170d1a505bec49bab60471bf148d (diff)
fix: use default voice for initial generation, random for regeneration
- 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 <noreply@anthropic.com>
Diffstat (limited to 'internal/gui')
-rw-r--r--internal/gui/generator.go36
1 files 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)