subgapfix 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,97 @@
1
+ Metadata-Version: 2.4
2
+ Name: subgapfix
3
+ Version: 0.0.1
4
+ Summary: A small CLI tool to extend subtitle durations in SRT files by redefining gaps between subtitles.
5
+ Author-email: Reinder Sinnema <reinder@w3bunker.com>
6
+ License: MIT
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: srt>=3.5.3
10
+
11
+ # SubGapFix
12
+
13
+ A small Python CLI tool to **extend subtitle durations** in `.srt` files so they stay on screen longer and feel more natural to read.
14
+ Designed especially for subtitles generated by [WhisperX](https://github.com/m-bain/whisperX), which often have very tight timings.
15
+
16
+ ## ✨ Features
17
+
18
+ - Automatically extends subtitles when there’s a gap before the next subtitle.
19
+ - Prevents overlaps by adjusting start/end times safely.
20
+ - Configurable via CLI arguments.
21
+
22
+ ## 📦 Installation
23
+
24
+ Clone the repository and install dependencies:
25
+
26
+ ```bash
27
+ git clone https://github.com/yourusername/subgapfix.git
28
+ cd subgapfix
29
+ pip install -r requirements.txt
30
+ ````
31
+
32
+ Dependencies:
33
+
34
+ * [`srt`](https://pypi.org/project/srt/)
35
+
36
+ ## 🔧 Usage
37
+
38
+ Basic usage:
39
+
40
+ ```bash
41
+ python subgapfix.py input.srt -o easyreading.srt
42
+ ```
43
+
44
+ ### Options
45
+
46
+ | Option | Default | Description |
47
+ |----------------------------|-----------------|---------------------------------------------------------------------------|
48
+ | `-o, --output` | `subgapfix.srt` | Output SRT file |
49
+ | `--extend-sub-start, -ess` | `0.5` | Seconds to add to start of subtitle. Default is `0.5` |
50
+ | `--extend-sub-end, -ese` | `2.0` | Maximum seconds to add to end of subtitle. Default is `2.0` |
51
+ | `--min-gap, -mg` | `1.0` | Minimum gap (in seconds) required to apply extension. Default is `1.0` |
52
+
53
+
54
+ ### How It Works
55
+
56
+ The script reads your `.srt` file, loops through each pair of consecutive subtitles, and adjusts their timings to make them easier to read.
57
+
58
+ ### Example
59
+
60
+ Input:
61
+
62
+ ```
63
+ 1
64
+ 00:00:01,000 --> 00:00:03,000
65
+ Hello there.
66
+
67
+ 2
68
+ 00:00:06,000 --> 00:00:08,000
69
+ How are you?
70
+ ```
71
+
72
+ Run:
73
+
74
+ ```bash
75
+ python subgapfix.py input.srt -o fixed.srt
76
+ ```
77
+
78
+ Output:
79
+
80
+ ```
81
+ 1
82
+ 00:00:01,000 --> 00:00:05,000
83
+ Hello there.
84
+
85
+ 2
86
+ 00:00:05,500 --> 00:00:08,000
87
+ How are you?
88
+ ```
89
+
90
+ ## 💡 Why?
91
+
92
+ Tools like WhisperX produce accurate subtitles, but their timings are often too **tight** for comfortable reading.
93
+ `SubGapFix` helps subtitles stay visible longer while keeping synchronization intact.
94
+
95
+ ## 🛠 Roadmap
96
+
97
+ * Package for PyPI (`pip install subgapfix`)
@@ -0,0 +1,87 @@
1
+ # SubGapFix
2
+
3
+ A small Python CLI tool to **extend subtitle durations** in `.srt` files so they stay on screen longer and feel more natural to read.
4
+ Designed especially for subtitles generated by [WhisperX](https://github.com/m-bain/whisperX), which often have very tight timings.
5
+
6
+ ## ✨ Features
7
+
8
+ - Automatically extends subtitles when there’s a gap before the next subtitle.
9
+ - Prevents overlaps by adjusting start/end times safely.
10
+ - Configurable via CLI arguments.
11
+
12
+ ## 📦 Installation
13
+
14
+ Clone the repository and install dependencies:
15
+
16
+ ```bash
17
+ git clone https://github.com/yourusername/subgapfix.git
18
+ cd subgapfix
19
+ pip install -r requirements.txt
20
+ ````
21
+
22
+ Dependencies:
23
+
24
+ * [`srt`](https://pypi.org/project/srt/)
25
+
26
+ ## 🔧 Usage
27
+
28
+ Basic usage:
29
+
30
+ ```bash
31
+ python subgapfix.py input.srt -o easyreading.srt
32
+ ```
33
+
34
+ ### Options
35
+
36
+ | Option | Default | Description |
37
+ |----------------------------|-----------------|---------------------------------------------------------------------------|
38
+ | `-o, --output` | `subgapfix.srt` | Output SRT file |
39
+ | `--extend-sub-start, -ess` | `0.5` | Seconds to add to start of subtitle. Default is `0.5` |
40
+ | `--extend-sub-end, -ese` | `2.0` | Maximum seconds to add to end of subtitle. Default is `2.0` |
41
+ | `--min-gap, -mg` | `1.0` | Minimum gap (in seconds) required to apply extension. Default is `1.0` |
42
+
43
+
44
+ ### How It Works
45
+
46
+ The script reads your `.srt` file, loops through each pair of consecutive subtitles, and adjusts their timings to make them easier to read.
47
+
48
+ ### Example
49
+
50
+ Input:
51
+
52
+ ```
53
+ 1
54
+ 00:00:01,000 --> 00:00:03,000
55
+ Hello there.
56
+
57
+ 2
58
+ 00:00:06,000 --> 00:00:08,000
59
+ How are you?
60
+ ```
61
+
62
+ Run:
63
+
64
+ ```bash
65
+ python subgapfix.py input.srt -o fixed.srt
66
+ ```
67
+
68
+ Output:
69
+
70
+ ```
71
+ 1
72
+ 00:00:01,000 --> 00:00:05,000
73
+ Hello there.
74
+
75
+ 2
76
+ 00:00:05,500 --> 00:00:08,000
77
+ How are you?
78
+ ```
79
+
80
+ ## 💡 Why?
81
+
82
+ Tools like WhisperX produce accurate subtitles, but their timings are often too **tight** for comfortable reading.
83
+ `SubGapFix` helps subtitles stay visible longer while keeping synchronization intact.
84
+
85
+ ## 🛠 Roadmap
86
+
87
+ * Package for PyPI (`pip install subgapfix`)
@@ -0,0 +1,20 @@
1
+ [build-system]
2
+ requires = ["setuptools>=80.9.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "subgapfix"
7
+ version = "0.0.1"
8
+ description = "A small CLI tool to extend subtitle durations in SRT files by redefining gaps between subtitles."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "Reinder Sinnema", email = "reinder@w3bunker.com" }
14
+ ]
15
+ dependencies = [
16
+ "srt>=3.5.3"
17
+ ]
18
+
19
+ [project.scripts]
20
+ subgapfix = "subgapfix.subgapfix:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,51 @@
1
+ import argparse
2
+ import srt
3
+ from datetime import timedelta
4
+
5
+ def extend_subs(input_file, output_file, extend_sub_start=0.5, extend_sub_end=2.0, min_gap=1.0):
6
+
7
+ if min_gap > extend_sub_start:
8
+
9
+ with open(input_file, "r", encoding="utf-8") as f:
10
+ subs = list(srt.parse(f.read()))
11
+
12
+ for i in range(len(subs) - 1):
13
+ first, second = subs[i], subs[i + 1]
14
+ gap = (second.start - first.end).total_seconds()
15
+
16
+ if gap < min_gap:
17
+ first.end += timedelta(seconds=gap/2)
18
+ second.start -= timedelta(seconds=gap/2)
19
+
20
+ if gap >= min_gap:
21
+ extendable = gap - extend_sub_start
22
+ if extendable > 0:
23
+ extension = min(extendable, extend_sub_end)
24
+ first.end += timedelta(seconds=extension)
25
+ second.start -= timedelta(seconds=extend_sub_start)
26
+
27
+ # Make sure subs don't overlap each other
28
+ if second.start <= first.end:
29
+ second.start = first.end + timedelta(milliseconds=10)
30
+
31
+ with open(output_file, "w", encoding="utf-8") as f:
32
+ f.write(srt.compose(subs))
33
+
34
+ else:
35
+ print("Hold up! The value of min_gap should be greater than that of extended_sub_start.")
36
+
37
+ def main():
38
+ parser = argparse.ArgumentParser(
39
+ description="Extend subtitle durations when there is a gap before the next subtitle."
40
+ )
41
+ parser.add_argument("input", help="Input SRT file")
42
+ parser.add_argument("-o", "--output", default="subgapfix.srt", help="Output SRT file")
43
+ parser.add_argument("--extend-sub-start", "-ess", type=float, default=0.5, help="Seconds to add to start of subtitle. Default is: -ess 0.5")
44
+ parser.add_argument("--extend-sub-end", "-ese", type=float, default=2.0, help="Seconds to add to end of subtitle. Default is: -ese 2.0")
45
+ parser.add_argument("--min-gap", "-mg", type=float, default=1.0, help="Minimum gap (in seconds) required to apply extension. Default is: -mg 1.0")
46
+ args = parser.parse_args()
47
+
48
+ extend_subs(args.input, args.output, args.extend_sub_start, args.extend_sub_end, args.min_gap)
49
+
50
+ if __name__ == "__main__":
51
+ main()
@@ -0,0 +1,97 @@
1
+ Metadata-Version: 2.4
2
+ Name: subgapfix
3
+ Version: 0.0.1
4
+ Summary: A small CLI tool to extend subtitle durations in SRT files by redefining gaps between subtitles.
5
+ Author-email: Reinder Sinnema <reinder@w3bunker.com>
6
+ License: MIT
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: srt>=3.5.3
10
+
11
+ # SubGapFix
12
+
13
+ A small Python CLI tool to **extend subtitle durations** in `.srt` files so they stay on screen longer and feel more natural to read.
14
+ Designed especially for subtitles generated by [WhisperX](https://github.com/m-bain/whisperX), which often have very tight timings.
15
+
16
+ ## ✨ Features
17
+
18
+ - Automatically extends subtitles when there’s a gap before the next subtitle.
19
+ - Prevents overlaps by adjusting start/end times safely.
20
+ - Configurable via CLI arguments.
21
+
22
+ ## 📦 Installation
23
+
24
+ Clone the repository and install dependencies:
25
+
26
+ ```bash
27
+ git clone https://github.com/yourusername/subgapfix.git
28
+ cd subgapfix
29
+ pip install -r requirements.txt
30
+ ````
31
+
32
+ Dependencies:
33
+
34
+ * [`srt`](https://pypi.org/project/srt/)
35
+
36
+ ## 🔧 Usage
37
+
38
+ Basic usage:
39
+
40
+ ```bash
41
+ python subgapfix.py input.srt -o easyreading.srt
42
+ ```
43
+
44
+ ### Options
45
+
46
+ | Option | Default | Description |
47
+ |----------------------------|-----------------|---------------------------------------------------------------------------|
48
+ | `-o, --output` | `subgapfix.srt` | Output SRT file |
49
+ | `--extend-sub-start, -ess` | `0.5` | Seconds to add to start of subtitle. Default is `0.5` |
50
+ | `--extend-sub-end, -ese` | `2.0` | Maximum seconds to add to end of subtitle. Default is `2.0` |
51
+ | `--min-gap, -mg` | `1.0` | Minimum gap (in seconds) required to apply extension. Default is `1.0` |
52
+
53
+
54
+ ### How It Works
55
+
56
+ The script reads your `.srt` file, loops through each pair of consecutive subtitles, and adjusts their timings to make them easier to read.
57
+
58
+ ### Example
59
+
60
+ Input:
61
+
62
+ ```
63
+ 1
64
+ 00:00:01,000 --> 00:00:03,000
65
+ Hello there.
66
+
67
+ 2
68
+ 00:00:06,000 --> 00:00:08,000
69
+ How are you?
70
+ ```
71
+
72
+ Run:
73
+
74
+ ```bash
75
+ python subgapfix.py input.srt -o fixed.srt
76
+ ```
77
+
78
+ Output:
79
+
80
+ ```
81
+ 1
82
+ 00:00:01,000 --> 00:00:05,000
83
+ Hello there.
84
+
85
+ 2
86
+ 00:00:05,500 --> 00:00:08,000
87
+ How are you?
88
+ ```
89
+
90
+ ## 💡 Why?
91
+
92
+ Tools like WhisperX produce accurate subtitles, but their timings are often too **tight** for comfortable reading.
93
+ `SubGapFix` helps subtitles stay visible longer while keeping synchronization intact.
94
+
95
+ ## 🛠 Roadmap
96
+
97
+ * Package for PyPI (`pip install subgapfix`)
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/subgapfix/__init__.py
4
+ src/subgapfix/subgapfix.py
5
+ src/subgapfix.egg-info/PKG-INFO
6
+ src/subgapfix.egg-info/SOURCES.txt
7
+ src/subgapfix.egg-info/dependency_links.txt
8
+ src/subgapfix.egg-info/entry_points.txt
9
+ src/subgapfix.egg-info/requires.txt
10
+ src/subgapfix.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ subgapfix = subgapfix.subgapfix:main
@@ -0,0 +1 @@
1
+ srt>=3.5.3
@@ -0,0 +1 @@
1
+ subgapfix