From d2371b46474479769d5eea529e532c0397247303 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 21 Jul 2025 16:38:14 +0300 Subject: fix(processor): Fetch phonetic info immediately after translation Moves the phonetic information fetching to occur immediately after the word has been translated. This ensures that the phonetic data is available as early as possible in the processing pipeline. Previously, the phonetic information was fetched after image generation, which caused an unnecessary delay. This change improves the logical flow of the word processing sequence. --- internal/processor/processor.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'internal/processor/processor.go') diff --git a/internal/processor/processor.go b/internal/processor/processor.go index f912da3..99ffa47 100644 --- a/internal/processor/processor.go +++ b/internal/processor/processor.go @@ -123,6 +123,16 @@ func (p *Processor) ProcessWordWithTranslation(word, providedTranslation string) } } + // Fetch phonetic information + fmt.Printf(" Fetching phonetic information...\n") + wordDir := p.findOrCreateWordDirectory(word) + if err := p.phoneticFetcher.FetchAndSave(word, wordDir); err != nil { + // Don't fail the whole process if phonetic info fails + fmt.Printf(" Warning: Failed to fetch phonetic info: %v\n", err) + } else { + fmt.Printf(" Saved phonetic information\n") + } + // Generate audio if !p.flags.SkipAudio { fmt.Printf(" Generating audio...\n") @@ -139,18 +149,6 @@ func (p *Processor) ProcessWordWithTranslation(word, providedTranslation string) } } - // Fetch phonetic information - fmt.Printf(" Fetching phonetic information...\n") - wordDir := p.findCardDirectory(word) - if wordDir != "" { - if err := p.phoneticFetcher.FetchAndSave(word, wordDir); err != nil { - // Don't fail the whole process if phonetic info fails - fmt.Printf(" Warning: Failed to fetch phonetic info: %v\n", err) - } else { - fmt.Printf(" Saved phonetic information\n") - } - } - return nil } -- cgit v1.2.3