diff options
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/gui/app.go | 66 | ||||
| -rw-r--r-- | internal/gui/audio_player.go | 23 | ||||
| -rw-r--r-- | internal/gui/generator.go | 12 | ||||
| -rw-r--r-- | internal/gui/navigation.go | 26 | ||||
| -rw-r--r-- | internal/processor/processor.go | 31 |
5 files changed, 0 insertions, 158 deletions
diff --git a/internal/gui/app.go b/internal/gui/app.go index 96096f2..60bc2e1 100644 --- a/internal/gui/app.go +++ b/internal/gui/app.go @@ -1147,23 +1147,14 @@ func (a *Application) onRegenerateRandomImage() { // onRegenerateAudio regenerates front audio (or single audio for en-bg cards) func (a *Application) onRegenerateAudio() { - fmt.Printf("DEBUG: ████████████████████████████████████████████████████████████████\n") - fmt.Printf("DEBUG: ████ ENTERED onRegenerateAudio() - REGENERATING FRONT AUDIO\n") - fmt.Printf("DEBUG: ████████████████████████████████████████████████████████████████\n") - fmt.Printf("DEBUG (onRegenerateAudio): Starting front audio regeneration\n") - fmt.Printf(" - currentWord: %s\n", a.currentWord) - fmt.Printf(" - currentCardType: %s\n", a.currentCardType) - // Only disable the audio-related buttons a.regenerateAudioBtn.Disable() a.regenerateAllBtn.Disable() isBgBg := a.currentCardType == "bg-bg" if isBgBg { - fmt.Printf("DEBUG (onRegenerateAudio): Card type is bg-bg, regenerating FRONT audio only\n") a.showProgress("Regenerating front audio...") } else { - fmt.Printf("DEBUG (onRegenerateAudio): Card type is en-bg, regenerating single audio\n") a.showProgress("Regenerating audio...") } @@ -1176,7 +1167,6 @@ func (a *Application) onRegenerateAudio() { // Store the word we're generating for wordForGeneration := a.currentWord - fmt.Printf("DEBUG (onRegenerateAudio): In goroutine - wordForGeneration: %s\n", wordForGeneration) a.startOperation(wordForGeneration) defer a.endOperation(wordForGeneration) @@ -1254,17 +1244,7 @@ func (a *Application) onRegenerateAudio() { // onRegenerateBackAudio regenerates back audio for bg-bg cards func (a *Application) onRegenerateBackAudio() { - fmt.Printf("DEBUG: ████████████████████████████████████████████████████████████████\n") - fmt.Printf("DEBUG: ████ ENTERED onRegenerateBackAudio() - REGENERATING BACK AUDIO\n") - fmt.Printf("DEBUG: ████████████████████████████████████████████████████████████████\n") - fmt.Printf("DEBUG (onRegenerateBackAudio): Starting back audio regeneration\n") - fmt.Printf(" - currentWord: %s\n", a.currentWord) - fmt.Printf(" - currentCardType: %s\n", a.currentCardType) - fmt.Printf(" - currentTranslation (state var): %s\n", a.currentTranslation) - fmt.Printf(" - translationEntry.Text (UI field): %s\n", a.translationEntry.Text) - if a.currentCardType != "bg-bg" { - fmt.Printf("DEBUG (onRegenerateBackAudio): Not a bg-bg card, returning\n") return } @@ -1281,24 +1261,16 @@ func (a *Application) onRegenerateBackAudio() { // CRITICAL: Get translation from state variable first translation := a.currentTranslation - fmt.Printf("DEBUG (onRegenerateBackAudio): In goroutine - translation from a.currentTranslation: %s\n", translation) - fmt.Printf("DEBUG (onRegenerateBackAudio): In goroutine - translation UI field: %s\n", a.translationEntry.Text) if translation == "" { - fmt.Printf("DEBUG (onRegenerateBackAudio): WARNING - translation state was empty, falling back to UI field\n") translation = strings.TrimSpace(a.translationEntry.Text) - fmt.Printf("DEBUG (onRegenerateBackAudio): Using UI field translation: %s\n", translation) } wordForGeneration := a.currentWord - fmt.Printf("DEBUG (onRegenerateBackAudio): Final decision - will generate back audio for: %s\n", translation) - fmt.Printf("DEBUG (onRegenerateBackAudio): (NOT for word: %s)\n", wordForGeneration) // For back audio, we need to use the main context, not create a new card context // because the front audio regeneration already has an active context for this word. // Creating a new context would cancel the front audio operation. - fmt.Printf("DEBUG (onRegenerateBackAudio): Using main context (not creating new card context)\n") - fmt.Printf("DEBUG (onRegenerateBackAudio): This prevents cancelling ongoing front audio operation\n") a.startOperation(wordForGeneration) defer a.endOperation(wordForGeneration) @@ -1311,17 +1283,8 @@ func (a *Application) onRegenerateBackAudio() { return } - fmt.Printf("DEBUG (onRegenerateBackAudio): Calling generateAudioBack with:\n") - fmt.Printf(" - ctx: a.ctx (main app context)\n") - fmt.Printf(" - translation: %s\n", translation) - fmt.Printf(" - cardDir: %s\n", cardDir) - audioFile, err := a.generateAudioBack(a.ctx, translation, cardDir) - fmt.Printf("DEBUG (onRegenerateBackAudio): generateAudioBack returned:\n") - fmt.Printf(" - err: %v\n", err) - fmt.Printf(" - audioFile: %s\n", audioFile) - if err != nil { fyne.Do(func() { a.showError(fmt.Errorf("back audio regeneration failed: %w", err)) @@ -2603,30 +2566,13 @@ func (a *Application) setupKeyboardShortcuts() { a.onRegenerateRandomImage() } case 'a', 'а': // a = regenerate front audio - fmt.Printf("DEBUG: ╔════════════════════════════════════════════════════════════════\n") - fmt.Printf("DEBUG: ║ KEY PRESSED: 'a' (lowercase, regenerate FRONT audio)\n") - fmt.Printf("DEBUG: ╚════════════════════════════════════════════════════════════════\n") - fmt.Printf(" - currentWord: %s\n", a.currentWord) - fmt.Printf(" - currentCardType: %s\n", a.currentCardType) - fmt.Printf(" - regenerateAudioBtn.Disabled(): %v\n", a.regenerateAudioBtn.Disabled()) - fmt.Printf(" - CALLING: onRegenerateAudio() for FRONT audio\n") if !a.regenerateAudioBtn.Disabled() { a.onRegenerateAudio() } case 'A', 'А': // A = regenerate back audio (for bg-bg cards) - fmt.Printf("DEBUG: ╔════════════════════════════════════════════════════════════════\n") - fmt.Printf("DEBUG: ║ KEY PRESSED: 'A' (uppercase, regenerate BACK audio)\n") - fmt.Printf("DEBUG: ╚════════════════════════════════════════════════════════════════\n") - fmt.Printf(" - currentWord: %s\n", a.currentWord) - fmt.Printf(" - currentCardType: %s\n", a.currentCardType) - fmt.Printf(" - currentTranslation: %s\n", a.currentTranslation) - fmt.Printf(" - translationEntry.Text: %s\n", a.translationEntry.Text) - fmt.Printf(" - regenerateAudioBtn.Disabled(): %v\n", a.regenerateAudioBtn.Disabled()) if a.currentCardType == "bg-bg" { - fmt.Printf(" - CALLING: onRegenerateBackAudio() for BACK audio\n") a.onRegenerateBackAudio() } else { - fmt.Printf("DEBUG: Skipping back audio regen - not a bg-bg card\n") } case 'р', 'Р': // р = r if !a.regenerateAllBtn.Disabled() { @@ -2637,24 +2583,12 @@ func (a *Application) setupKeyboardShortcuts() { a.onDelete() } case 'p', 'п': // p = play front audio - fmt.Printf("DEBUG: Key pressed 'p' (play front audio)\n") - fmt.Printf(" - currentWord: %s\n", a.currentWord) - fmt.Printf(" - currentCardType: %s\n", a.currentCardType) - fmt.Printf(" - currentAudioFile: %s\n", a.currentAudioFile) if a.currentAudioFile != "" { a.audioPlayer.Play() - } else { - fmt.Printf("DEBUG: No front audio file to play\n") } case 'P', 'П': // P = play back audio (for bg-bg cards) - fmt.Printf("DEBUG: Key pressed 'P' (play back audio)\n") - fmt.Printf(" - currentWord: %s\n", a.currentWord) - fmt.Printf(" - currentCardType: %s\n", a.currentCardType) - fmt.Printf(" - currentAudioFileBack: %s\n", a.currentAudioFileBack) if a.currentAudioFileBack != "" { a.audioPlayer.PlayBack() - } else { - fmt.Printf("DEBUG: No back audio file to play\n") } case 'ж', 'Ж': // ж = x a.onExportToAnki() diff --git a/internal/gui/audio_player.go b/internal/gui/audio_player.go index ac8d819..eb96430 100644 --- a/internal/gui/audio_player.go +++ b/internal/gui/audio_player.go @@ -241,28 +241,18 @@ func (p *AudioPlayer) SetAutoPlayEnabled(autoPlayEnabled *bool) { // onPlay handles play button click func (p *AudioPlayer) onPlay() { - fmt.Printf("DEBUG (onPlay): Starting playback\n") - fmt.Printf(" - audioFile: %s\n", p.audioFile) - fmt.Printf(" - audioFileBack: %s\n", p.audioFileBack) - fmt.Printf(" - isBgBg: %v\n", p.isBgBg) - fmt.Printf(" - isPlaying: %v\n", p.isPlaying) - if p.audioFile == "" { - fmt.Printf("DEBUG (onPlay): No audioFile set, returning\n") return } if p.isPlaying { // Pause functionality - just stop for now - fmt.Printf("DEBUG (onPlay): Already playing, stopping\n") p.onStop() return } // Start playing - fmt.Printf("DEBUG (onPlay): About to start playback for: %s\n", filepath.Base(p.audioFile)) if err := p.startPlayback(); err != nil { - fmt.Printf("DEBUG (onPlay): Error starting playback: %v\n", err) p.statusLabel.SetText(fmt.Sprintf("Error: %v", err)) return } @@ -271,31 +261,20 @@ func (p *AudioPlayer) onPlay() { p.playButton.SetIcon(theme.MediaPauseIcon()) p.stopButton.Enable() p.statusLabel.SetText(fmt.Sprintf("Playing: %s%s", filepath.Base(p.audioFile), p.voiceInfo)) - fmt.Printf("DEBUG (onPlay): Playback started successfully\n") } // onPlayBack handles back audio button click (for bg-bg cards) func (p *AudioPlayer) onPlayBack() { - fmt.Printf("DEBUG (onPlayBack): Starting back audio playback\n") - fmt.Printf(" - audioFile: %s\n", p.audioFile) - fmt.Printf(" - audioFileBack: %s\n", p.audioFileBack) - fmt.Printf(" - isBgBg: %v\n", p.isBgBg) - fmt.Printf(" - isPlaying: %v\n", p.isPlaying) - if p.audioFileBack == "" { - fmt.Printf("DEBUG (onPlayBack): No audioFileBack set, returning\n") return } if p.isPlaying { - fmt.Printf("DEBUG (onPlayBack): Already playing, stopping first\n") p.onStop() } // Start playback using back audio file directly - fmt.Printf("DEBUG (onPlayBack): About to start playback for back audio: %s\n", filepath.Base(p.audioFileBack)) if err := p.startPlaybackForFile(p.audioFileBack); err != nil { - fmt.Printf("DEBUG (onPlayBack): Error starting playback: %v\n", err) p.statusLabel.SetText(fmt.Sprintf("Error: %v", err)) return } @@ -304,14 +283,12 @@ func (p *AudioPlayer) onPlayBack() { p.playBackButton.SetIcon(theme.MediaPauseIcon()) // Back button, not front p.stopButton.Enable() p.statusLabel.SetText(fmt.Sprintf("Playing back audio: %s", filepath.Base(p.audioFileBack))) - fmt.Printf("DEBUG (onPlayBack): Back audio playback started successfully\n") } // onStop handles stop button click func (p *AudioPlayer) onStop() { if p.playCmd != nil && p.playCmd.Process != nil { if err := p.playCmd.Process.Kill(); err != nil { - fmt.Printf("DEBUG (onStop): Failed to kill playback process: %v\n", err) p.statusLabel.SetText(fmt.Sprintf("failed to stop playback: %v", err)) } p.playCmd = nil diff --git a/internal/gui/generator.go b/internal/gui/generator.go index afd0dd0..a1ab22c 100644 --- a/internal/gui/generator.go +++ b/internal/gui/generator.go @@ -235,18 +235,13 @@ func (a *Application) generateAudio(ctx context.Context, word string, cardDir st // generateAudioFront generates front audio for a bg-bg card func (a *Application) generateAudioFront(ctx context.Context, word string, cardDir string) (string, error) { - fmt.Printf("DEBUG (generateAudioFront): Called with word: %s, cardDir: %s\n", word, cardDir) - if cardDir == "" { - fmt.Printf("DEBUG (generateAudioFront): Card directory not provided, returning error\n") return "", fmt.Errorf("card directory not provided") } voice, speed := a.audioVoiceAndSpeed() - fmt.Printf("DEBUG (generateAudioFront): Generating front audio for '%s' with voice: %s, speed: %.2f\n", word, voice, speed) fmt.Printf("Generating front audio for '%s' with voice: %s, speed: %.2f\n", word, voice, speed) frontFile := filepath.Join(cardDir, fmt.Sprintf("audio_front.%s", a.audioOutputFormat())) - fmt.Printf("DEBUG (generateAudioFront): Will write to: %s\n", frontFile) finalVoice := voice var err error @@ -260,7 +255,6 @@ func (a *Application) generateAudioFront(ctx context.Context, word string, cardD if err != nil { return "", fmt.Errorf("failed to generate front audio: %w", err) } - fmt.Printf("DEBUG (generateAudioFront): Successfully wrote front audio to: %s\n", frontFile) audioConfig := a.audioConfigForGeneration(finalVoice, speed) @@ -278,18 +272,13 @@ func (a *Application) generateAudioFront(ctx context.Context, word string, cardD // generateAudioBack generates back audio for a bg-bg card func (a *Application) generateAudioBack(ctx context.Context, text string, cardDir string) (string, error) { - fmt.Printf("DEBUG (generateAudioBack): Called with text: %s, cardDir: %s\n", text, cardDir) - if cardDir == "" { - fmt.Printf("DEBUG (generateAudioBack): Card directory not provided, returning error\n") return "", fmt.Errorf("card directory not provided") } voice, speed := a.audioVoiceAndSpeed() - fmt.Printf("DEBUG (generateAudioBack): Generating back audio for '%s' with voice: %s, speed: %.2f\n", text, voice, speed) fmt.Printf("Generating back audio for '%s' with voice: %s, speed: %.2f\n", text, voice, speed) backFile := filepath.Join(cardDir, fmt.Sprintf("audio_back.%s", a.audioOutputFormat())) - fmt.Printf("DEBUG (generateAudioBack): Will write to: %s\n", backFile) finalVoice := voice var err error @@ -303,7 +292,6 @@ func (a *Application) generateAudioBack(ctx context.Context, text string, cardDi if err != nil { return "", fmt.Errorf("failed to generate back audio: %w", err) } - fmt.Printf("DEBUG (generateAudioBack): Successfully wrote back audio to: %s\n", backFile) audioConfig := a.audioConfigForGeneration(finalVoice, speed) diff --git a/internal/gui/navigation.go b/internal/gui/navigation.go index c58251c..1cd6089 100644 --- a/internal/gui/navigation.go +++ b/internal/gui/navigation.go @@ -371,29 +371,17 @@ func (a *Application) loadExistingFiles(word string) { if data, err := os.ReadFile(translationFile); err == nil { // Parse translation from "word = translation" format content := string(data) - fmt.Printf("DEBUG (loadExistingFiles): Read translation.txt: %s\n", content) parts := strings.Split(content, "=") - fmt.Printf("DEBUG (loadExistingFiles): Split into %d parts\n", len(parts)) if len(parts) >= 2 { translation := strings.TrimSpace(parts[1]) - fmt.Printf("DEBUG (loadExistingFiles): Extracted translation (part 1, after '='): %s\n", translation) // CRITICAL: Set the state BEFORE SetText so it's available when needed a.currentTranslation = translation - fmt.Printf("DEBUG (loadExistingFiles): Set a.currentTranslation state variable to: %s\n", a.currentTranslation) fyne.Do(func() { a.translationEntry.SetText(translation) - fmt.Printf("DEBUG (loadExistingFiles): Set translationEntry UI field to: %s\n", translation) - - // CRITICAL: After SetText, verify the state is correct - fmt.Printf("DEBUG (loadExistingFiles): After SetText, a.currentTranslation is: %s\n", a.currentTranslation) }) - } else { - fmt.Printf("DEBUG (loadExistingFiles): Translation file did not have '=' separator\n") } - } else { - fmt.Printf("DEBUG (loadExistingFiles): Could not read translation.txt: %v\n", err) } // Load image prompt file @@ -423,21 +411,17 @@ func (a *Application) loadExistingFiles(word string) { // Load card type and audio files cardType := internal.LoadCardType(wordDir) a.currentCardType = string(cardType) - fmt.Printf("DEBUG (loadExistingFiles): Loaded card type: %s (isBgBg: %v)\n", cardType, cardType.IsBgBg()) // Update UI card type selector - fmt.Printf("DEBUG (loadExistingFiles): Syncing UI card type selector to %s\n", cardType) a.syncCardTypeSelection(cardType) // Load audio file(s) if cardType.IsBgBg() { - fmt.Printf("DEBUG (loadExistingFiles): Loading audio files for bg-bg card\n") // For bg-bg cards, load both front and back audio frontAudio, backAudio := a.resolveBgBgAudioFiles(wordDir) if frontAudio != "" { a.currentAudioFile = frontAudio - fmt.Printf("DEBUG (loadExistingFiles): Found front audio: %s\n", frontAudio) if a.window == nil { a.audioPlayer.SetAudioFile(frontAudio) } else { @@ -445,13 +429,10 @@ func (a *Application) loadExistingFiles(word string) { a.audioPlayer.SetAudioFile(frontAudio) }) } - } else { - fmt.Printf("DEBUG (loadExistingFiles): Front audio not found: %s\n", frontAudio) } if backAudio != "" { a.currentAudioFileBack = backAudio - fmt.Printf("DEBUG (loadExistingFiles): Found back audio: %s\n", backAudio) if a.window == nil { a.audioPlayer.SetBackAudioFile(backAudio) } else { @@ -459,16 +440,12 @@ func (a *Application) loadExistingFiles(word string) { a.audioPlayer.SetBackAudioFile(backAudio) }) } - } else { - fmt.Printf("DEBUG (loadExistingFiles): Back audio not found: %s\n", backAudio) } } else { - fmt.Printf("DEBUG (loadExistingFiles): Loading audio files for en-bg card\n") // For en-bg cards, load standard audio file audioFile := a.resolveSingleAudioFile(wordDir) if audioFile != "" { a.currentAudioFile = audioFile - fmt.Printf("DEBUG (loadExistingFiles): Found audio: %s\n", audioFile) if a.window == nil { a.audioPlayer.SetAudioFile(audioFile) } else { @@ -476,12 +453,9 @@ func (a *Application) loadExistingFiles(word string) { a.audioPlayer.SetAudioFile(audioFile) }) } - } else { - fmt.Printf("DEBUG (loadExistingFiles): Audio not found: %s\n", audioFile) } // Hide back audio button for en-bg cards a.currentAudioFileBack = "" - fmt.Printf("DEBUG (loadExistingFiles): Clearing back audio for en-bg card\n") if a.window == nil { a.audioPlayer.SetBackAudioFile("") } else { diff --git a/internal/processor/processor.go b/internal/processor/processor.go index 9b8fe8a..38c2413 100644 --- a/internal/processor/processor.go +++ b/internal/processor/processor.go @@ -103,18 +103,12 @@ func (p *Processor) ProcessBatch() error { fmt.Printf("\nProcessing %d/%d: %s\n", i+1, len(entries), entry.Bulgarian) // Check if word already exists and has all required files - if os.Getenv("DEBUG_BATCH") != "" { - fmt.Printf(" [DEBUG] Checking if word is fully processed...\n") - } if p.isWordFullyProcessed(entry.Bulgarian) { wordDir := p.findCardDirectory(entry.Bulgarian) fmt.Printf(" ✓ Skipping '%s' - already fully processed in %s\n", entry.Bulgarian, filepath.Base(wordDir)) skippedCount++ continue } - if os.Getenv("DEBUG_BATCH") != "" { - fmt.Printf(" [DEBUG] Word is not fully processed, will process it\n") - } if err := p.ProcessWordWithTranslationAndType(entry.Bulgarian, entry.Translation, entry.CardType); err != nil { fmt.Fprintf(os.Stderr, "Error processing '%s': %v\n", entry.Bulgarian, err) @@ -922,10 +916,6 @@ func (p *Processor) isWordFullyProcessed(word string) bool { } // Debug logging - if os.Getenv("DEBUG_BATCH") != "" { - fmt.Printf(" [DEBUG] Checking word directory: %s\n", wordDir) - } - // Check for required files requiredFiles := []string{ "word.txt", // Word metadata @@ -943,16 +933,10 @@ func (p *Processor) isWordFullyProcessed(word string) bool { frontAudioFiles := anki.ResolveAudioPaths(wordDir, "audio_front", audioFormat) backAudioFiles := anki.ResolveAudioPaths(wordDir, "audio_back", audioFormat) if len(frontAudioFiles) == 0 || len(backAudioFiles) == 0 { - if os.Getenv("DEBUG_BATCH") != "" { - fmt.Printf(" [DEBUG] No bg-bg audio files found in %s\n", wordDir) - } return false } for _, audioFile := range append(frontAudioFiles, backAudioFiles...) { if _, err := os.Stat(audio.AttributionPath(audioFile)); os.IsNotExist(err) { - if os.Getenv("DEBUG_BATCH") != "" { - fmt.Printf(" [DEBUG] Missing attribution for audio file: %s\n", audioFile) - } return false } } @@ -962,16 +946,10 @@ func (p *Processor) isWordFullyProcessed(word string) bool { audioFiles := anki.ResolveAudioPaths(wordDir, "audio", audioFormat) if len(audioFiles) == 0 { - if os.Getenv("DEBUG_BATCH") != "" { - fmt.Printf(" [DEBUG] No audio files found in %s\n", wordDir) - } return false } for _, audioFile := range audioFiles { if _, err := os.Stat(audio.AttributionPath(audioFile)); os.IsNotExist(err) { - if os.Getenv("DEBUG_BATCH") != "" { - fmt.Printf(" [DEBUG] Missing attribution for audio file: %s\n", audioFile) - } return false } } @@ -1005,9 +983,6 @@ func (p *Processor) isWordFullyProcessed(word string) bool { } } if !hasImage { - if os.Getenv("DEBUG_BATCH") != "" { - fmt.Printf(" [DEBUG] No image files found in %s\n", wordDir) - } return false // No image files found } } @@ -1016,16 +991,10 @@ func (p *Processor) isWordFullyProcessed(word string) bool { for _, file := range requiredFiles { filePath := filepath.Join(wordDir, file) if _, err := os.Stat(filePath); os.IsNotExist(err) { - if os.Getenv("DEBUG_BATCH") != "" { - fmt.Printf(" [DEBUG] Required file missing: %s\n", filePath) - } return false // Required file missing } } - if os.Getenv("DEBUG_BATCH") != "" { - fmt.Printf(" [DEBUG] All required files exist, word is fully processed\n") - } return true // All required files exist } func (p *Processor) saveAudioAttribution(word, audioFile string, config *audio.Config) error { |
