Conversation
… Subtitle - needsRetranslation tracks source-text edits made after translation existed - isTranslated computed property checks for non-empty translatedText - sourceText.didSet automatically sets needsRetranslation when isTranslated
- Add transcribeOnly() for ASR without translation - transcribe() now skips translation when targetLanguage == .None - Both methods preserve subtitle index mapping
TranslationService:
- Use strict JSON format in prompts (quoted keys) instead of JSON5
- Throw on parse failure instead of silent empty-dict return
- Support both {'data': {...}} and flat {...} response shapes
- Process all batches concurrently via withThrowingTaskGroup
- Eliminate per-subtitle doTranslateOne retry, retry missing items as batch instead
LLMService:
- extractJSONs falls back to full-text parsing when no code blocks found
- Adds tryParseJSON with 3 strategies: standard, JSON5, brace-region extraction
- Add translationBatchSize property to LLMService settings (default 60) - Add INI serialize/deserialize for persistence - Add slider in Settings UI (10-200, step 10)
Core flow: - generateSubtitles() now does ASR-only, no translation - add translateCurrentSubtitles() for post-ASR translation - add reTranslateEditedSubtitles() for editing re-translation - add canTranslate, hasNeedsRetranslation, hasUntranslatedSubtitles helpers Auto toggles (persisted via UserDefaults): - autoTranslateAfterAsr: when on, Generate does ASR+translate in one go - autoReTranslate: when on, edits trigger automatic re-translation - Auto-save SRT after translate/re-translate
- Add Translate button after ASR completes - Button label switches to Re-translate Edited when needed - Add Auto Translate toggle (one-step vs two-step mode) - Tooltip guidance for disabled states
…ranslate - Add Translate and Re-translate (N) buttons in bottom toolbar - Add Auto Re-translate toggle with label - Auto-scroll subtitle list to match video playback position - Blue retranslation indicator on subtitle items needing re-translate - Auto-trigger reTranslateEditedSubtitles on focus loss when enabled
The editor was showing stale persisted data when editingSubtitles was out of sync with subtitles. Now showSubtitleEditor() always syncs editingSubtitles = subtitles before opening the window.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Summary
This PR implements the feature requested in issue #27: allow users to edit source subtitles before translation, instead of having translation happen immediately after ASR. It also fixes JSON parsing failures and optimizes translation throughput.
New Workflow
Before (old):
After (new):
An Auto Translate toggle (default OFF) is provided next to the Generate button for users who prefer the original one‑step behavior.
What Changed
1. ASR/Translation Separation (fixes #27)
Generate Subtitlesnow does ASR only — translation is no longer automatic2. Editor Enhancements
3. Translation Reliability
data:without quotes) to strictly valid JSON ("data"with quotes), eliminating LLM response format confusionextractJSONsnow falls back through 3 strategies: markdown code blocks → full‑text parsing → brace‑region extractiondoTranslatethrows on parse failure instead of silently returning an empty dictionary, allowing proper retry4. Translation Speed
withThrowingTaskGroupdoTranslateOneretry — failed items are collected into a single retry batch instead of making N individual API calls5. Misc
transcribe()now correctly skips translation whentargetLanguage == .None(also addresses issue Target Language of "None" makes Chinese. #21)autoTranslateAfterAsr,autoReTranslate,translationBatchSize) are persisted via UserDefaults / INI fileFiles Changed
Models/Subtitle.swiftModels/Settings.swiftServices/WhisperService.swiftServices/TranslationService.swiftServices/LLMService.swiftViewModels/SubtitleViewModel.swiftViews/ContentView.swiftViews/SubtitleEditView.swiftViews/SettingsView.swiftTesting Notes
carthage bootstrap