Skip to content

Commit 86d703c

Browse files
committed
Refactor README.md to enhance clarity and structure; update feature descriptions and usage instructions for GUI and console modes.
1 parent c8082bb commit 86d703c

File tree

1 file changed

+58
-162
lines changed

1 file changed

+58
-162
lines changed

README.md

Lines changed: 58 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11
# GoSubtitle
22

3-
A PyQt6-based desktop application for converting Movie XML files to SRT subtitle format with speaker identification and timing controls. Also includes a powerful command-line interface for batch processing and automation.
4-
5-
## Features
6-
7-
- **XML to SRT Conversion**: Convert Movie XML files containing TTS data to standard SRT subtitle format
8-
- **Speaker Management**:
9-
- View and edit speaker names for each subtitle
10-
- Mass replace speaker names across all subtitles
11-
- Automatic handling of overlapping speaker dialogue
12-
- **Timing Controls**:
13-
- Adjust subtitle timing with frame-based offset
14-
- Smart subtitle splitting based on word count and sentence boundaries
15-
- Automatic time distribution based on speaking rate
16-
- **Dual Interface**:
17-
- GUI mode with intuitive visual interface
18-
- Console mode for batch processing and automation
19-
- Automatic mode detection (console when available, GUI otherwise)
20-
- **Robust Error Handling**: Comprehensive logging and validation
3+
GoSubtitle is a PyQt6 desktop application for converting **Wrapper: Offline** Movie XML files (containing TTS entries) into standard SRT subtitle files. It supports both an interactive GUI for editing and a powerful command-line interface for batch processing and automation.
4+
5+
## Key Features
6+
7+
- **Wrapper: Offline XML to SRT**: Converts Movie XML files with `<sound tts="1">` entries to SRT, preserving speaker names and timing.
8+
- **Speaker Management**: Edit, mass-replace, and manage speaker names; handles overlapping dialogue.
9+
- **Frame-Based Timing**: All timing is based on 24 FPS frame numbers from the XML, with accurate conversion to SRT timestamps.
10+
- **Smart Subtitle Splitting**: Automatically splits long subtitles by sentence and word count for readability.
11+
- **Dual Interface**: Use the GUI for interactive editing or the CLI for automation—mode is auto-detected.
12+
- **Robust Logging & Validation**: Comprehensive error handling and detailed logs for troubleshooting.
2113

2214
## Requirements
2315

@@ -26,9 +18,6 @@ A PyQt6-based desktop application for converting Movie XML files to SRT subtitle
2618

2719
## Installation
2820

29-
1. Clone or download this repository
30-
2. Install dependencies:
31-
3221
```bash
3322
pip install PyQt6
3423
```
@@ -37,187 +26,94 @@ pip install PyQt6
3726

3827
### GUI Mode
3928

40-
1. Run the application:
41-
4229
```bash
4330
python main.py
4431
```
4532

46-
2. Click "Select" to open a Movie XML file
47-
3. Edit speakers and subtitle text as needed
48-
4. Use the offset spinbox to adjust timing (in frames at 24 fps)
49-
5. Mass replace speaker names if needed
50-
6. Click "Save" to export as an SRT file
33+
- Open a Wrapper: Offline XML file.
34+
- Edit speakers and subtitles.
35+
- Adjust timing offsets (in frames at 24 FPS).
36+
- Mass-replace speaker names.
37+
- Export to SRT.
5138

5239
### Console Mode
5340

54-
The console mode activates automatically when running from a terminal/command prompt. Force GUI mode with the `-g` flag.
55-
56-
**Basic usage:**
57-
5841
```bash
5942
python main.py -f movie.xml
6043
```
6144

62-
**Specify output file:**
63-
64-
```bash
65-
python main.py -f movie.xml -s subtitles.srt
66-
```
67-
68-
**Apply time offset (in frames):**
69-
70-
```bash
71-
python main.py -f movie.xml -o 24
72-
```
73-
74-
**Replace speaker names:**
75-
76-
```bash
77-
python main.py -f movie.xml -r "John:Jane" -r "Bob:Robert"
78-
```
45+
- Use `-g` to force GUI mode.
46+
- Use `-o` for frame offsets, `-r` for speaker replacements, `--max-words` for line splitting, and `--verbose` for stats.
7947

80-
**Set maximum words per line:**
48+
### Example
8149

8250
```bash
83-
python main.py -f movie.xml --max-words 15
51+
python main.py -f movie.xml -s output.srt -o 24 -r "Old:New" --max-words 12 --verbose
8452
```
8553

86-
**Display detailed statistics:**
54+
## Command-Line Options
8755

88-
```bash
89-
python main.py -f movie.xml --verbose
9056
```
91-
92-
**Combined example:**
93-
94-
```bash
95-
python main.py -f movie.xml -s output.srt -o -12 -r "Unknown:Narrator" --max-words 12 --verbose
96-
```
97-
98-
### Command-Line Options
99-
100-
```
101-
-g, --gui Force GUI mode even when console is available
102-
-f, --file PATH Input Movie XML file path (required)
103-
-s, --srt PATH Output SRT file path (default: input filename with .srt)
104-
-o, --offset FRAMES Offset all subtitles by frames (can be negative)
105-
-w, --max-words COUNT Maximum words per subtitle line (default: 10)
106-
-r, --replace OLD:NEW Replace speaker names (can be used multiple times)
107-
-v, --verbose Display detailed statistics about subtitles
108-
--version Show program version and exit
57+
-g, --gui Force GUI mode
58+
-f, --file PATH Input Wrapper: Offline XML file (required)
59+
-s, --srt PATH Output SRT file (default: input with .srt)
60+
-o, --offset FRAMES Offset subtitles by frames (can be negative)
61+
-w, --max-words COUNT Max words per subtitle line (default: 10)
62+
-r, --replace OLD:NEW Replace speaker names (multiple allowed)
63+
-v, --verbose Show detailed statistics
64+
--version Show version and exit
10965
```
11066

11167
## Project Structure
11268

11369
```
11470
GoSubtitle/
115-
├── main.py # Application entry point
116-
├── helpers.py # Utility functions
71+
├── main.py
72+
├── helpers.py
11773
├── modules/
118-
│ ├── __init__.py # Module exports
119-
│ ├── window.py # Main window GUI logic
120-
│ └── subtitle_processor.py # Subtitle processing business logic
74+
│ ├── __init__.py
75+
│ ├── window.py
76+
│ ├── console.py
77+
│ └── subtitle_processor.py
12178
└── ui/
122-
├── main_window.ui # Main window UI design
123-
└── timeline_object.ui # Subtitle timeline widget UI
79+
├── main_window.ui
80+
└── timeline_object.ui
12481
```
12582

126-
## Architecture
127-
128-
The application follows a clean architecture pattern:
129-
130-
- **Presentation Layer** (`window.py`): Handles all GUI interactions and user events
131-
- **Business Logic Layer** (`subtitle_processor.py`): Manages subtitle parsing, merging, and splitting
132-
- **Utility Layer** (`helpers.py`): Provides common utility functions
133-
134-
### Key Features of the Code
135-
136-
- **Type Hints**: Full type annotations for better IDE support and code clarity
137-
- **Comprehensive Logging**: Detailed logging for debugging and monitoring
138-
- **Docstrings**: Every class and method is documented
139-
- **Error Handling**: Robust exception handling with user-friendly error messages
140-
- **Path Handling**: Platform-independent path handling using `pathlib`
141-
- **Proper Closures**: Fixed lambda closure bugs for correct event handling
142-
- **Tab Order Management**: Intuitive keyboard navigation through timeline objects
143-
144-
## Configuration
145-
146-
Constants in `SubtitleProcessor`:
147-
148-
- `FPS = 24`: Fixed to 24 frames per second
149-
- `DEFAULT_MAX_WORDS_PER_LINE = 10`: Maximum words per subtitle line
150-
- `DEFAULT_WORDS_PER_SECOND = 2.5`: Average speaking rate for timing
151-
- `MIN_SUBTITLE_DURATION = 0.5`: Minimum subtitle duration in seconds
152-
153-
## XML Format
154-
155-
Expected Movie XML format:
83+
## XML Format (Wrapper: Offline)
15684

15785
```xml
15886
<root duration="[total_frames]">
159-
<sound tts="1">
160-
<start>[start_frame]</start>
161-
<stop>[stop_frame]</stop>
162-
<ttsdata>
163-
<text>[subtitle_text]</text>
164-
<voice>[speaker_name]</voice>
165-
</ttsdata>
166-
</sound>
167-
...
87+
<sound tts="1">
88+
<start>[start_frame]</start>
89+
<stop>[stop_frame]</stop>
90+
<ttsdata>
91+
<text>[subtitle_text]</text>
92+
<voice>[speaker_name]</voice>
93+
</ttsdata>
94+
</sound>
95+
...
16896
</root>
16997
```
17098

171-
## Development
172-
173-
### Recent Improvements (Code Review Implementation)
174-
175-
**Separation of Concerns**: Extracted business logic into `SubtitleProcessor` class
176-
**Type Hints**: Added throughout codebase for better type safety
177-
**Docstrings**: Comprehensive documentation for all classes and methods
178-
**Logging System**: Proper logging instead of silent exception catching
179-
**Input Validation**: Robust validation for XML structure and edge cases
180-
**Path Handling**: Using `pathlib` for cross-platform compatibility
181-
**Fixed Lambda Bug**: Proper closure handling in event callbacks
182-
**Tab Order**: Intuitive keyboard navigation through timeline objects
183-
**Editable Content**: Subtitle text is now editable in the UI
184-
**Constants**: Properly defined configuration constants
185-
**Helper Functions**: Useful utilities in `helpers.py`
186-
**Clean Imports**: Module-level exports in `__init__.py`
99+
## Configuration
187100

188-
### Testing
101+
- `FPS = 24` (fixed)
102+
- `DEFAULT_MAX_WORDS_PER_LINE = 10`
103+
- `DEFAULT_WORDS_PER_SECOND = 2.5`
104+
- `MIN_SUBTITLE_DURATION = 0.5`
189105

190-
Currently no automated tests. Recommended additions:
106+
## Troubleshooting
191107

192-
- Unit tests for `SubtitleProcessor` methods
193-
- Integration tests for XML parsing
194-
- UI tests for user interactions
108+
- **UI not loading**: Ensure the `ui/` directory is accessible.
109+
- **XML errors**: Validate your Wrapper: Offline XML structure.
110+
- **Timing issues**: All offsets and durations are in frames at 24 FPS.
111+
- **Speaker replacements**: Use exact, case-sensitive names.
195112

196113
## License
197114

198-
This is a personal project. Feel free to use and modify as needed.
115+
Personal projectuse and modify as needed.
199116

200117
## Contributing
201118

202-
This is a learning project, but suggestions and improvements are welcome!
203-
204-
## Troubleshooting
205-
206-
**UI files not found**: Make sure you run the application from the project root directory, or the path resolution will work from any directory thanks to `pathlib`.
207-
208-
**XML parsing errors**: Ensure your XML file follows the expected format with proper `duration`, `start`, `stop`, `text`, and `voice` elements.
209-
210-
**Import errors**: Make sure PyQt6 is installed: `pip install PyQt6`
211-
212-
## Future Enhancements
213-
214-
Potential improvements:
215-
216-
- Undo/redo functionality
217-
- Subtitle preview with video sync
218-
- Configurable FPS support
219-
- Import/export multiple formats
220-
- Search and filter subtitles
221-
- Keyboard shortcuts
222-
- Auto-save feature
223-
- Dark mode theme
119+
Suggestions and improvements are welcome!

0 commit comments

Comments
 (0)