From 8779de2c97e445acf82e8422c899fdefa4649bda Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 18 Jul 2025 23:18:45 +0300 Subject: feat: multiple improvements to GUI and codebase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add random voice speed between 0.90-1.00 for more natural audio - Display voice and speed info in GUI audio player - Implement automatic retry loading for missing files (checks every 2 seconds) - Fix voice/speed info persistence during audio playback - Remove image caching functionality for cleaner codebase - Rename prompt.txt to image_prompt.txt for clarity - Fix GUI to recognize newly added cards during runtime (rescan on navigation) - Update README to reflect removed image cache These changes improve the user experience by making the audio more natural, providing better feedback about audio generation parameters, and ensuring the GUI stays synchronized with externally added cards. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- cmd/totalrecall/main.go | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) (limited to 'cmd') diff --git a/cmd/totalrecall/main.go b/cmd/totalrecall/main.go index dbcacf2..db1a94e 100644 --- a/cmd/totalrecall/main.go +++ b/cmd/totalrecall/main.go @@ -334,6 +334,13 @@ func generateAudio(word string) error { } func generateAudioWithVoice(word, voice string) error { + // Generate random speed between 0.90 and 1.00 if not explicitly set + speed := openAISpeed + if openAISpeed == 0.9 && !viper.IsSet("audio.openai_speed") { + // Default was used, generate random speed + speed = 0.90 + rand.Float64()*0.10 + } + // Create audio provider configuration providerConfig := &audio.Config{ Provider: "openai", @@ -344,7 +351,7 @@ func generateAudioWithVoice(word, voice string) error { OpenAIKey: getOpenAIKey(), OpenAIModel: openAIModel, OpenAIVoice: voice, - OpenAISpeed: openAISpeed, + OpenAISpeed: speed, OpenAIInstruction: openAIInstruction, // Caching @@ -437,8 +444,6 @@ func downloadImagesWithTranslation(word, translation string) error { Size: openAIImageSize, Quality: openAIImageQuality, Style: openAIImageStyle, - CacheDir: viper.GetString("image.cache_dir"), - EnableCache: viper.GetBool("image.enable_cache"), } // Use config file values if not overridden by flags @@ -455,13 +460,6 @@ func downloadImagesWithTranslation(word, translation string) error { openaiConfig.Style = viper.GetString("image.openai_style") } - // Set defaults - if openaiConfig.CacheDir == "" { - openaiConfig.CacheDir = "./.image_cache" - } - if !viper.IsSet("image.enable_cache") { - openaiConfig.EnableCache = true - } searcher = image.NewOpenAIClient(openaiConfig) if openaiConfig.APIKey == "" { @@ -514,6 +512,19 @@ func downloadImagesWithTranslation(word, translation string) error { } fmt.Printf(" Downloaded: %s\n", path) + // If using OpenAI, save the prompt + if imageAPI == "openai" { + if openaiClient, ok := searcher.(*image.OpenAIClient); ok { + usedPrompt := openaiClient.GetLastPrompt() + if usedPrompt != "" { + promptFile := filepath.Join(wordDir, "image_prompt.txt") + if err := os.WriteFile(promptFile, []byte(usedPrompt), 0644); err != nil { + fmt.Printf(" Warning: Failed to save image prompt: %v\n", err) + } + } + } + } + return nil } @@ -825,6 +836,15 @@ func saveAudioAttribution(word, audioFile string, config *audio.Config) error { return fmt.Errorf("failed to write audio attribution file: %w", err) } + // Also save metadata for GUI display + wordDir := filepath.Dir(audioFile) + metadataFile := filepath.Join(wordDir, "audio_metadata.txt") + metadata := fmt.Sprintf("voice=%s\nspeed=%.2f\n", config.OpenAIVoice, config.OpenAISpeed) + if err := os.WriteFile(metadataFile, []byte(metadata), 0644); err != nil { + // Non-fatal error, just log it + fmt.Printf("Warning: Failed to save audio metadata: %v\n", err) + } + return nil } @@ -834,7 +854,6 @@ func runGUIMode() error { OutputDir: outputDir, AudioFormat: audioFormat, ImageProvider: imageAPI, - EnableCache: viper.GetBool("cache.enable"), OpenAIKey: getOpenAIKey(), } -- cgit v1.2.3