subtitle-generator 2.0.0__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.
Files changed (36) hide show
  1. subtitle_generator-2.0.0/CONTRIBUTING.md +130 -0
  2. subtitle_generator-2.0.0/LICENSE +21 -0
  3. subtitle_generator-2.0.0/MANIFEST.in +39 -0
  4. subtitle_generator-2.0.0/PKG-INFO +161 -0
  5. subtitle_generator-2.0.0/README.md +116 -0
  6. subtitle_generator-2.0.0/config/default.yaml +57 -0
  7. subtitle_generator-2.0.0/docs/API.md +197 -0
  8. subtitle_generator-2.0.0/docs/PACKAGING.md +64 -0
  9. subtitle_generator-2.0.0/docs/TROUBLESHOOTING.md +162 -0
  10. subtitle_generator-2.0.0/docs/example.md +191 -0
  11. subtitle_generator-2.0.0/environment.yml +24 -0
  12. subtitle_generator-2.0.0/pyproject.toml +137 -0
  13. subtitle_generator-2.0.0/requirements.txt +18 -0
  14. subtitle_generator-2.0.0/setup.cfg +4 -0
  15. subtitle_generator-2.0.0/setup.py +15 -0
  16. subtitle_generator-2.0.0/src/__init__.py +8 -0
  17. subtitle_generator-2.0.0/src/cli/__init__.py +5 -0
  18. subtitle_generator-2.0.0/src/cli/commands.py +556 -0
  19. subtitle_generator-2.0.0/src/config/__init__.py +6 -0
  20. subtitle_generator-2.0.0/src/config/config_loader.py +140 -0
  21. subtitle_generator-2.0.0/src/config/settings.py +144 -0
  22. subtitle_generator-2.0.0/src/core/__init__.py +20 -0
  23. subtitle_generator-2.0.0/src/core/async_processor.py +290 -0
  24. subtitle_generator-2.0.0/src/core/batch_processor.py +384 -0
  25. subtitle_generator-2.0.0/src/core/subtitle_gen.py +142 -0
  26. subtitle_generator-2.0.0/src/core/transcriber.py +176 -0
  27. subtitle_generator-2.0.0/src/core/video_processor.py +240 -0
  28. subtitle_generator-2.0.0/src/models/__init__.py +5 -0
  29. subtitle_generator-2.0.0/src/models/model_manager.py +302 -0
  30. subtitle_generator-2.0.0/src/utils/__init__.py +41 -0
  31. subtitle_generator-2.0.0/src/utils/downloader.py +190 -0
  32. subtitle_generator-2.0.0/src/utils/exceptions.py +197 -0
  33. subtitle_generator-2.0.0/src/utils/file_handler.py +185 -0
  34. subtitle_generator-2.0.0/src/utils/formatters.py +305 -0
  35. subtitle_generator-2.0.0/src/utils/validators.py +219 -0
  36. subtitle_generator-2.0.0/subtitle_generator.egg-info/SOURCES.txt +33 -0
@@ -0,0 +1,130 @@
1
+ # Contributing to Subtitle
2
+
3
+ Thank you for your interest in contributing to the Subtitle project! This guide will help you get started.
4
+
5
+ ## Development Setup
6
+
7
+ 1. **Clone the repository**
8
+ ```bash
9
+ git clone https://github.com/innovatorved/subtitle.git
10
+ cd subtitle
11
+ ```
12
+
13
+ 2. **Set up Whisper.cpp**
14
+ ```bash
15
+ ./setup_whisper.sh
16
+ ```
17
+
18
+ 3. **Create conda environment**
19
+ ```bash
20
+ conda env create -f environment.yml
21
+ conda activate subtitle
22
+ ```
23
+
24
+ 4. **Install development dependencies**
25
+ ```bash
26
+ pip install -r requirements.txt
27
+ pip install pytest black flake8 mypy
28
+ ```
29
+
30
+ ## Code Style
31
+
32
+ We follow these conventions:
33
+
34
+ - **Formatter**: [Black](https://github.com/psf/black) with default settings
35
+ - **Linter**: [Flake8](https://flake8.pycqa.org/) for style checking
36
+ - **Type hints**: Use type annotations for function signatures
37
+ - **Docstrings**: Google-style docstrings for public functions and classes
38
+
39
+ ### Running Code Quality Checks
40
+
41
+ ```bash
42
+ # Format code
43
+ black src/ tests/
44
+
45
+ # Check style
46
+ flake8 src/ tests/
47
+
48
+ # Type checking
49
+ mypy src/
50
+ ```
51
+
52
+ ## Testing
53
+
54
+ All changes must include tests. We use [pytest](https://pytest.org/) for testing.
55
+
56
+ ```bash
57
+ # Run all tests
58
+ pytest
59
+
60
+ # Run with coverage
61
+ pytest --cov=src --cov-report=html
62
+
63
+ # Run specific test file
64
+ pytest tests/unit/test_batch_processor.py -v
65
+ ```
66
+
67
+ ### Test Structure
68
+
69
+ ```
70
+ tests/
71
+ ├── unit/ # Unit tests for individual components
72
+ ├── integration/ # Integration tests
73
+ ├── e2e/ # End-to-end tests
74
+ └── fixtures/ # Shared test fixtures
75
+ ```
76
+
77
+ ## Pull Request Process
78
+
79
+ 1. **Fork** the repository
80
+ 2. **Create a branch** from `main`:
81
+ ```bash
82
+ git checkout -b feature/your-feature-name
83
+ ```
84
+ 3. **Make your changes** with tests
85
+ 4. **Run tests and linting** to ensure quality
86
+ 5. **Commit** with a descriptive message (see below)
87
+ 6. **Push** and open a Pull Request
88
+
89
+ ### Commit Message Format
90
+
91
+ Use clear, descriptive commit messages:
92
+
93
+ ```
94
+ <type>: <short description>
95
+
96
+ [optional body with more details]
97
+ ```
98
+
99
+ **Types:**
100
+ - `feat`: New feature
101
+ - `fix`: Bug fix
102
+ - `docs`: Documentation changes
103
+ - `test`: Adding or updating tests
104
+ - `refactor`: Code refactoring
105
+ - `chore`: Maintenance tasks
106
+
107
+ **Examples:**
108
+ ```
109
+ feat: add ASS subtitle format support
110
+ fix: handle missing ffmpeg gracefully
111
+ docs: add troubleshooting guide
112
+ test: add tests for batch processor
113
+ ```
114
+
115
+ ## Reporting Issues
116
+
117
+ When reporting bugs, please include:
118
+
119
+ 1. Python version and OS
120
+ 2. Steps to reproduce
121
+ 3. Expected vs actual behavior
122
+ 4. Error messages or logs
123
+
124
+ ## Questions?
125
+
126
+ Feel free to open an issue for questions or reach out at vedgupta@protonmail.com.
127
+
128
+ ---
129
+
130
+ Thank you for contributing! 🎉
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Ved Prakash Gupta
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # Include essential files
2
+ include LICENSE
3
+ include README.md
4
+ include CONTRIBUTING.md
5
+ include requirements.txt
6
+ include environment.yml
7
+
8
+ # Include config files
9
+ recursive-include config *.yaml *.yml
10
+ recursive-include src *.yaml *.yml
11
+
12
+ # Include documentation
13
+ recursive-include docs *.md
14
+
15
+ # Exclude development and build artifacts
16
+ exclude .env
17
+ exclude .env.example
18
+ prune .git
19
+ prune .github
20
+ prune .vscode
21
+ prune .pytest_cache
22
+ prune __pycache__
23
+ prune *.egg-info
24
+ prune build
25
+ prune dist
26
+ prune whisper.cpp
27
+ prune binary
28
+ prune models
29
+ prune models1
30
+ prune data
31
+ prune tests
32
+ prune example
33
+
34
+ # Exclude compiled files
35
+ global-exclude *.py[cod]
36
+ global-exclude *.so
37
+ global-exclude *.dylib
38
+ global-exclude *.bin
39
+ global-exclude .DS_Store
@@ -0,0 +1,161 @@
1
+ Metadata-Version: 2.4
2
+ Name: subtitle-generator
3
+ Version: 2.0.0
4
+ Summary: Open-source subtitle generation for seamless content translation.
5
+ Author-email: Ved Gupta <vedgupta@protonmail.com>
6
+ Maintainer-email: Ved Gupta <vedgupta@protonmail.com>
7
+ License: MIT
8
+ Project-URL: Homepage, https://github.com/innovatorved/subtitle
9
+ Project-URL: Documentation, https://github.com/innovatorved/subtitle#readme
10
+ Project-URL: Repository, https://github.com/innovatorved/subtitle.git
11
+ Project-URL: Issues, https://github.com/innovatorved/subtitle/issues
12
+ Project-URL: Changelog, https://github.com/innovatorved/subtitle/releases
13
+ Keywords: subtitle,transcription,whisper,ai,speech-to-text,video,audio,srt,vtt,innovatorved
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: End Users/Desktop
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
25
+ Classifier: Topic :: Multimedia :: Video
26
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: ffmpeg-python>=0.2.0
31
+ Requires-Dist: tqdm>=4.66.0
32
+ Requires-Dist: pyyaml>=6.0.0
33
+ Requires-Dist: gdown>=4.7.0
34
+ Provides-Extra: dev
35
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
36
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
37
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
38
+ Requires-Dist: black>=23.0.0; extra == "dev"
39
+ Requires-Dist: isort>=5.0.0; extra == "dev"
40
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
41
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
42
+ Requires-Dist: build>=1.0.0; extra == "dev"
43
+ Requires-Dist: twine>=4.0.0; extra == "dev"
44
+ Dynamic: license-file
45
+
46
+ # Subtitle
47
+
48
+ Open-source subtitle generation for seamless content translation.
49
+
50
+ **Key Features:**
51
+
52
+ - **Open-source** - Freely available for use, modification, and distribution
53
+ - **Self-hosted** - Run on your own servers for enhanced control and privacy
54
+ - **AI-powered** - Leverage Whisper for accurate, natural-sounding subtitles
55
+ - **Multilingual** - Generate subtitles in a wide range of languages
56
+ - **Fast** - Uses whisper.cpp for high-performance inference
57
+
58
+ ## Installation
59
+
60
+ ### Prerequisites
61
+
62
+ Ensure you have the following installed:
63
+ - `git`, `make`, `cmake`
64
+ - `ffmpeg` (Required for video processing)
65
+ - `conda` (Anaconda or Miniconda)
66
+
67
+ ### Setup
68
+
69
+ 1. **Clone and setup Whisper.cpp:**
70
+ ```bash
71
+ ./setup_whisper.sh
72
+ ```
73
+
74
+ 2. **Create and activate conda environment:**
75
+ ```bash
76
+ conda env create -f environment.yml
77
+ conda activate subtitle
78
+ ```
79
+
80
+ ## Usage
81
+
82
+ ### Generate Subtitles
83
+
84
+ ```bash
85
+ # Basic usage (generates VTT subtitle file)
86
+ python subtitle.py video.mp4
87
+
88
+ # Generate and embed subtitles into video
89
+ python subtitle.py video.mp4 --merge
90
+
91
+ # Use a specific model
92
+ python subtitle.py video.mp4 --model base
93
+
94
+ # Generate SRT format
95
+ python subtitle.py video.mp4 --format srt
96
+
97
+ # From URL
98
+ python subtitle.py "https://example.com/video.mp4"
99
+ ```
100
+
101
+ ### Model Management
102
+
103
+ ```bash
104
+ # List all available models
105
+ python subtitle.py models --list
106
+
107
+ # Download a specific model
108
+ python subtitle.py models --download large
109
+ ```
110
+
111
+ ### View Supported Formats
112
+
113
+ ```bash
114
+ python subtitle.py formats
115
+ ```
116
+
117
+ ### Options
118
+
119
+ | Option | Description |
120
+ |--------|-------------|
121
+ | `--model`, `-m` | Model to use (default: base) |
122
+ | `--format`, `-f` | Output format: vtt, srt, txt, json, lrc (default: vtt) |
123
+ | `--merge` | Embed subtitles into video |
124
+ | `--threads`, `-t` | Number of threads (default: 4) |
125
+ | `--verbose`, `-v` | Verbose output |
126
+
127
+ ### Available Models
128
+
129
+ | Model | Size | Speed | Best For |
130
+ |-------|------|-------|----------|
131
+ | `tiny` | ~75MB | Fastest | Quick previews |
132
+ | `base` | ~140MB | Fast | General use (default) |
133
+ | `small` | ~460MB | Medium | Quality output |
134
+ | `medium` | ~1.5GB | Slow | Professional work |
135
+ | `large` | ~3GB | Slowest | Maximum accuracy |
136
+
137
+ > **Tip:** Use `.en` models (e.g., `base.en`) for English-only content.
138
+
139
+ ## Documentation
140
+
141
+ - [Usage Examples](docs/example.md) - CLI and Python API examples
142
+ - [API Reference](docs/API.md) - Programmatic API documentation
143
+ - [Troubleshooting](docs/TROUBLESHOOTING.md) - Common issues and solutions
144
+ - [Contributing](CONTRIBUTING.md) - Contribution guidelines
145
+
146
+ ## License
147
+
148
+ [MIT](https://choosealicense.com/licenses/mit/)
149
+
150
+ ## Reference & Credits
151
+
152
+ - [OpenAI Whisper](https://github.com/openai/whisper)
153
+ - [whisper.cpp](https://github.com/ggerganov/whisper.cpp)
154
+
155
+ ## Author
156
+
157
+ - [Ved Gupta](https://www.github.com/innovatorved)
158
+
159
+ ## Support
160
+
161
+ For support, email vedgupta@protonmail.com
@@ -0,0 +1,116 @@
1
+ # Subtitle
2
+
3
+ Open-source subtitle generation for seamless content translation.
4
+
5
+ **Key Features:**
6
+
7
+ - **Open-source** - Freely available for use, modification, and distribution
8
+ - **Self-hosted** - Run on your own servers for enhanced control and privacy
9
+ - **AI-powered** - Leverage Whisper for accurate, natural-sounding subtitles
10
+ - **Multilingual** - Generate subtitles in a wide range of languages
11
+ - **Fast** - Uses whisper.cpp for high-performance inference
12
+
13
+ ## Installation
14
+
15
+ ### Prerequisites
16
+
17
+ Ensure you have the following installed:
18
+ - `git`, `make`, `cmake`
19
+ - `ffmpeg` (Required for video processing)
20
+ - `conda` (Anaconda or Miniconda)
21
+
22
+ ### Setup
23
+
24
+ 1. **Clone and setup Whisper.cpp:**
25
+ ```bash
26
+ ./setup_whisper.sh
27
+ ```
28
+
29
+ 2. **Create and activate conda environment:**
30
+ ```bash
31
+ conda env create -f environment.yml
32
+ conda activate subtitle
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ### Generate Subtitles
38
+
39
+ ```bash
40
+ # Basic usage (generates VTT subtitle file)
41
+ python subtitle.py video.mp4
42
+
43
+ # Generate and embed subtitles into video
44
+ python subtitle.py video.mp4 --merge
45
+
46
+ # Use a specific model
47
+ python subtitle.py video.mp4 --model base
48
+
49
+ # Generate SRT format
50
+ python subtitle.py video.mp4 --format srt
51
+
52
+ # From URL
53
+ python subtitle.py "https://example.com/video.mp4"
54
+ ```
55
+
56
+ ### Model Management
57
+
58
+ ```bash
59
+ # List all available models
60
+ python subtitle.py models --list
61
+
62
+ # Download a specific model
63
+ python subtitle.py models --download large
64
+ ```
65
+
66
+ ### View Supported Formats
67
+
68
+ ```bash
69
+ python subtitle.py formats
70
+ ```
71
+
72
+ ### Options
73
+
74
+ | Option | Description |
75
+ |--------|-------------|
76
+ | `--model`, `-m` | Model to use (default: base) |
77
+ | `--format`, `-f` | Output format: vtt, srt, txt, json, lrc (default: vtt) |
78
+ | `--merge` | Embed subtitles into video |
79
+ | `--threads`, `-t` | Number of threads (default: 4) |
80
+ | `--verbose`, `-v` | Verbose output |
81
+
82
+ ### Available Models
83
+
84
+ | Model | Size | Speed | Best For |
85
+ |-------|------|-------|----------|
86
+ | `tiny` | ~75MB | Fastest | Quick previews |
87
+ | `base` | ~140MB | Fast | General use (default) |
88
+ | `small` | ~460MB | Medium | Quality output |
89
+ | `medium` | ~1.5GB | Slow | Professional work |
90
+ | `large` | ~3GB | Slowest | Maximum accuracy |
91
+
92
+ > **Tip:** Use `.en` models (e.g., `base.en`) for English-only content.
93
+
94
+ ## Documentation
95
+
96
+ - [Usage Examples](docs/example.md) - CLI and Python API examples
97
+ - [API Reference](docs/API.md) - Programmatic API documentation
98
+ - [Troubleshooting](docs/TROUBLESHOOTING.md) - Common issues and solutions
99
+ - [Contributing](CONTRIBUTING.md) - Contribution guidelines
100
+
101
+ ## License
102
+
103
+ [MIT](https://choosealicense.com/licenses/mit/)
104
+
105
+ ## Reference & Credits
106
+
107
+ - [OpenAI Whisper](https://github.com/openai/whisper)
108
+ - [whisper.cpp](https://github.com/ggerganov/whisper.cpp)
109
+
110
+ ## Author
111
+
112
+ - [Ved Gupta](https://www.github.com/innovatorved)
113
+
114
+ ## Support
115
+
116
+ For support, email vedgupta@protonmail.com
@@ -0,0 +1,57 @@
1
+ # Subtitle Generator Configuration
2
+ # Default configuration values for the subtitle generator
3
+
4
+ whisper:
5
+ # Default model to use (options: tiny, base, small, medium, large, etc.)
6
+ default_model: base
7
+
8
+ # Number of threads for transcription
9
+ threads: 4
10
+
11
+ # Number of processors for transcription
12
+ processors: 1
13
+
14
+ # Path to whisper-cli binary
15
+ binary_path: ./binary/whisper-cli
16
+
17
+ paths:
18
+ # Directory for storing downloaded models
19
+ models_dir: ./models
20
+
21
+ # Directory for temporary data files
22
+ data_dir: ./data
23
+
24
+ # Default output directory
25
+ output_dir: ./output
26
+
27
+ formats:
28
+ # Default subtitle format
29
+ default: vtt
30
+
31
+ # Supported subtitle formats
32
+ supported:
33
+ - vtt
34
+ - srt
35
+ - txt
36
+ - json
37
+ - lrc
38
+
39
+ video:
40
+ # Default video codec for output
41
+ video_codec: copy
42
+
43
+ # Default audio codec for output
44
+ audio_codec: copy
45
+
46
+ # Default subtitle codec for embedded subtitles
47
+ subtitle_codec: mov_text
48
+
49
+ # Overwrite existing output files
50
+ overwrite_output: true
51
+
52
+ logging:
53
+ # Log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
54
+ level: INFO
55
+
56
+ # Log format
57
+ format: "%(asctime)s - %(levelname)s - %(message)s"