summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-07-19 22:53:22 +0300
committerPaul Buetow <paul@buetow.org>2025-07-19 22:53:22 +0300
commit15f376c8aa3c170d1a505bec49bab60471bf148d (patch)
treeb7c4344b8dbdb853bc95e2da95481f6b563c0139 /internal
parent06a11a3aabec600a3388b7e818434052474ea341 (diff)
fix: always use random voice selection for audio generation
Previously, random voice was only used for regeneration. Now all audio generation uses a random voice from the available OpenAI voices for more variety in pronunciation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'internal')
-rw-r--r--internal/gui/generator.go39
1 files changed, 9 insertions, 30 deletions
diff --git a/internal/gui/generator.go b/internal/gui/generator.go
index f7bed2f..7704fb3 100644
--- a/internal/gui/generator.go
+++ b/internal/gui/generator.go
@@ -85,36 +85,15 @@ 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) {
- // 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
- }
- }
+ // Always use random voice and speed for variety
+ allVoices := []string{"alloy", "ash", "ballad", "coral", "echo", "fable", "onyx", "nova", "sage", "shimmer", "verse"}
- // For regeneration, use random voice and speed; otherwise use defaults
- var voice string
- var speed float64
-
- if isRegeneration {
- // Get available voices
- allVoices := []string{"alloy", "ash", "ballad", "coral", "echo", "fable", "onyx", "nova", "sage", "shimmer", "verse"}
-
- // 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 = 1.0
- // speed = 0.98
- }
+ // 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
// Update audio config with selected voice and speed
a.audioConfig.OpenAIVoice = voice
@@ -127,7 +106,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)