diff options
| author | Paul Buetow <paul@buetow.org> | 2025-07-21 16:38:14 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-07-21 16:38:14 +0300 |
| commit | d2371b46474479769d5eea529e532c0397247303 (patch) | |
| tree | 5043df0bdcdd7ac24da1202fbbf4d7e94afbfcea | |
| parent | 18390dc18f397207e6eb8e67991dc7078b5e7515 (diff) | |
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.
| -rw-r--r-- | internal/processor/processor.go | 22 |
1 files changed, 10 insertions, 12 deletions
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 } |
