quicktools-atom 0.3.0__tar.gz → 0.7.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 (30) hide show
  1. quicktools_atom-0.7.0/PKG-INFO +211 -0
  2. quicktools_atom-0.7.0/README.md +188 -0
  3. {quicktools_atom-0.3.0 → quicktools_atom-0.7.0}/pyproject.toml +16 -3
  4. {quicktools_atom-0.3.0 → quicktools_atom-0.7.0}/src/quicktools/__init__.py +12 -5
  5. quicktools_atom-0.7.0/src/quicktools/audiotools.py +160 -0
  6. quicktools_atom-0.7.0/src/quicktools/doctools.py +89 -0
  7. quicktools_atom-0.7.0/src/quicktools/filetools.py +103 -0
  8. quicktools_atom-0.7.0/src/quicktools/imagetools.py +128 -0
  9. quicktools_atom-0.7.0/src/quicktools/pdftools.py +161 -0
  10. quicktools_atom-0.7.0/src/quicktools/presentationtools.py +249 -0
  11. quicktools_atom-0.7.0/src/quicktools/spreadsheettools.py +72 -0
  12. quicktools_atom-0.7.0/src/quicktools/unitconverter.py +80 -0
  13. quicktools_atom-0.7.0/src/quicktools/videotools.py +155 -0
  14. quicktools_atom-0.7.0/src/quicktools_atom.egg-info/PKG-INFO +211 -0
  15. {quicktools_atom-0.3.0 → quicktools_atom-0.7.0}/src/quicktools_atom.egg-info/SOURCES.txt +10 -0
  16. quicktools_atom-0.7.0/src/quicktools_atom.egg-info/requires.txt +12 -0
  17. quicktools_atom-0.3.0/PKG-INFO +0 -51
  18. quicktools_atom-0.3.0/README.md +0 -40
  19. quicktools_atom-0.3.0/src/quicktools_atom.egg-info/PKG-INFO +0 -51
  20. {quicktools_atom-0.3.0 → quicktools_atom-0.7.0}/setup.cfg +0 -0
  21. {quicktools_atom-0.3.0 → quicktools_atom-0.7.0}/src/quicktools/calculus.py +0 -0
  22. {quicktools_atom-0.3.0 → quicktools_atom-0.7.0}/src/quicktools/cli.py +0 -0
  23. {quicktools_atom-0.3.0 → quicktools_atom-0.7.0}/src/quicktools/combinatorics.py +0 -0
  24. {quicktools_atom-0.3.0 → quicktools_atom-0.7.0}/src/quicktools/linalg.py +0 -0
  25. {quicktools_atom-0.3.0 → quicktools_atom-0.7.0}/src/quicktools/mathtools.py +0 -0
  26. {quicktools_atom-0.3.0 → quicktools_atom-0.7.0}/src/quicktools/numbertheory.py +0 -0
  27. {quicktools_atom-0.3.0 → quicktools_atom-0.7.0}/src/quicktools/strtools.py +0 -0
  28. {quicktools_atom-0.3.0 → quicktools_atom-0.7.0}/src/quicktools_atom.egg-info/dependency_links.txt +0 -0
  29. {quicktools_atom-0.3.0 → quicktools_atom-0.7.0}/src/quicktools_atom.egg-info/entry_points.txt +0 -0
  30. {quicktools_atom-0.3.0 → quicktools_atom-0.7.0}/src/quicktools_atom.egg-info/top_level.txt +0 -0
@@ -0,0 +1,211 @@
1
+ Metadata-Version: 2.4
2
+ Name: quicktools-atom
3
+ Version: 0.7.0
4
+ Summary: Math, text, presentation, audio, video, and file utilities by AtomDev Studios
5
+ Author-email: Samuel Peprah <windscribe.samuel@gmail.com>
6
+ Project-URL: Homepage, https://github.com/Samuel-Peprah-cmd/quicktools
7
+ Project-URL: Repository, https://github.com/Samuel-Peprah-cmd/quicktools
8
+ Project-URL: Documentation, https://samuel-peprah-cmd.github.io/quicktools/
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: Pillow
12
+ Requires-Dist: python-docx
13
+ Requires-Dist: pypdf
14
+ Requires-Dist: openpyxl
15
+ Requires-Dist: reportlab
16
+ Requires-Dist: PyYAML
17
+ Requires-Dist: pdf2docx
18
+ Requires-Dist: docx2pdf
19
+ Requires-Dist: python-pptx
20
+ Requires-Dist: faster-whisper
21
+ Requires-Dist: av
22
+ Requires-Dist: pyannote.audio
23
+
24
+ """
25
+
26
+ <p align="center">
27
+
28
+ &#x20; <img src="https://raw.githubusercontent.com/Samuel-Peprah-cmd/quicktools/main/assets/AtomDev/\_Studios.png" alt="AtomDev Studios" width="320" style="border-radius: 8px;">
29
+
30
+ </p>
31
+
32
+
33
+
34
+ \# quicktools
35
+
36
+
37
+
38
+ A math, text, media, and document automation toolkit— built by \*\*Samuel Peprah\*\*
39
+
40
+ under \*\*AtomDev Studios\*\*.
41
+
42
+
43
+
44
+ \---
45
+
46
+
47
+
48
+ \## About Samuel Peprah
49
+
50
+
51
+
52
+ <p align="center">
53
+
54
+ &#x20; <img src="assets/sam.png" alt="Samuel Peprah" width="160" style="border-radius: 50%; object-fit: cover;">
55
+
56
+ </p>
57
+
58
+
59
+
60
+ Samuel Peprah is a software developer, web application developer, and
61
+
62
+ Occupational Therapy student at the University of Ghana. Alongside his
63
+
64
+ healthcare education, he is also studying Computer Science at the University
65
+
66
+ of the People, combining knowledge from both fields to develop practical
67
+
68
+ technology solutions.
69
+
70
+
71
+
72
+ His interests span full-stack web development, software engineering,
73
+
74
+ automation, artificial intelligence, cybersecurity, and health technology.
75
+
76
+ He enjoys building scalable applications that solve real-world problems and
77
+
78
+ continuously explores new technologies to improve his skills.
79
+
80
+
81
+
82
+ Samuel has developed educational platforms, business management systems,
83
+
84
+ attendance systems, healthcare applications, and AI-powered solutions. He is
85
+
86
+ passionate about creating software that is modern, efficient, secure, and
87
+
88
+ user-friendly.
89
+
90
+
91
+
92
+ \## About AtomDev Studios
93
+
94
+
95
+
96
+ AtomDev Studios is the personal software development brand founded by Samuel
97
+
98
+ Peprah. The studio specializes in designing and developing modern websites,
99
+
100
+ web applications, business management systems, educational platforms, and
101
+
102
+ custom software solutions for individuals, startups, schools, and
103
+
104
+ organizations.
105
+
106
+
107
+
108
+ The mission of AtomDev Studios is to transform ideas into reliable, scalable,
109
+
110
+ and innovative digital products that solve real-world problems while
111
+
112
+ delivering exceptional user experiences.
113
+
114
+
115
+
116
+ \### Areas of Expertise
117
+
118
+
119
+
120
+ \- Full-Stack Web Development
121
+
122
+ \- Custom Web Applications
123
+
124
+ \- REST API Development
125
+
126
+ \- Database Design \& Management
127
+
128
+ \- Educational Technology Platforms
129
+
130
+ \- Healthcare Technology Solutions
131
+
132
+ \- AI Integration \& Automation
133
+
134
+ \- UI/UX Design
135
+
136
+ \- Cloud Deployment \& Hosting
137
+
138
+ \- Website Maintenance \& Support
139
+
140
+
141
+
142
+ \### Technologies
143
+
144
+
145
+
146
+ Python • Flask • JavaScript • HTML • CSS • Tailwind CSS • Bootstrap •
147
+
148
+ PostgreSQL • SQLite • Git • GitHub • Cloudflare • Docker
149
+
150
+
151
+
152
+ \### Connect
153
+
154
+
155
+
156
+ \- LinkedIn: \[samuel-peprah-a63598347](https://www.linkedin.com/in/samuel-peprah-a63598347)
157
+
158
+ \- X (Twitter): \[@legend\_consult](https://x.com/legend\_consult)
159
+
160
+ \- TikTok: \[@legendinlearning](https://www.tiktok.com/@legendinlearning)
161
+
162
+ \- Instagram: \[@ksapeprah](https://www.instagram.com/ksapeprah)
163
+
164
+ \- GitHub: \[Samuel-Peprah-cmd](https://github.com/Samuel-Peprah-cmd)
165
+
166
+
167
+
168
+ > "Building innovative software solutions that bridge technology with real-world impact."
169
+
170
+
171
+
172
+ \---
173
+
174
+
175
+
176
+ \## Modules
177
+
178
+
179
+
180
+ \- `mathtools` — primes, GCD/LCM, mean, median, standard deviation
181
+
182
+ \- `strtools` — palindromes, slugify, edit distance, anagrams, ciphers
183
+
184
+ \- `linalg` — matrix operations, determinants, inverses, linear systems
185
+
186
+ \- `calculus` — derivatives, integrals, Taylor series, Newton's method
187
+
188
+ \- `numbertheory` — extended GCD, modular inverse, sieve, prime factorization
189
+
190
+ \- `combinatorics` — permutations, combinations, Catalan numbers, Fibonacci
191
+
192
+ \- `filetools` — read/write any file, JSON, YAML, hashing, zip/unzip
193
+
194
+ \- `imagetools` — convert PNG/JPEG/BMP/GIF/WEBP/TIFF, resize, rotate, watermark, images-to-PDF
195
+
196
+ \- `pdftools` — extract text, merge, split, rotate, encrypt, create PDFs, PDF-to-images
197
+
198
+ \- `doctools` — read/write/edit Word docs, docx-to-PDF, PDF-to-docx
199
+
200
+ \- `spreadsheettools` — CSV, Excel, and JSON conversions
201
+ \- `unitconverter` — temperature, distance, weight, volume, speed, storage conversions
202
+ \- `presentationtools` — read/create PowerPoint decks, cloud themes, docx/pdf-to-pptx
203
+ \- `audiotools` — speech-to-text transcription, word timestamps, speaker diarization, SRT export
204
+ \- `videotools` — video transcription, frame extraction, speaker diarization to Word scripts
205
+
206
+ """
207
+
208
+
209
+
210
+ \_\_version\_\_ = "0.7.0"
211
+
@@ -0,0 +1,188 @@
1
+ """
2
+
3
+ <p align="center">
4
+
5
+ &#x20; <img src="https://raw.githubusercontent.com/Samuel-Peprah-cmd/quicktools/main/assets/AtomDev/\_Studios.png" alt="AtomDev Studios" width="320" style="border-radius: 8px;">
6
+
7
+ </p>
8
+
9
+
10
+
11
+ \# quicktools
12
+
13
+
14
+
15
+ A math, text, media, and document automation toolkit— built by \*\*Samuel Peprah\*\*
16
+
17
+ under \*\*AtomDev Studios\*\*.
18
+
19
+
20
+
21
+ \---
22
+
23
+
24
+
25
+ \## About Samuel Peprah
26
+
27
+
28
+
29
+ <p align="center">
30
+
31
+ &#x20; <img src="assets/sam.png" alt="Samuel Peprah" width="160" style="border-radius: 50%; object-fit: cover;">
32
+
33
+ </p>
34
+
35
+
36
+
37
+ Samuel Peprah is a software developer, web application developer, and
38
+
39
+ Occupational Therapy student at the University of Ghana. Alongside his
40
+
41
+ healthcare education, he is also studying Computer Science at the University
42
+
43
+ of the People, combining knowledge from both fields to develop practical
44
+
45
+ technology solutions.
46
+
47
+
48
+
49
+ His interests span full-stack web development, software engineering,
50
+
51
+ automation, artificial intelligence, cybersecurity, and health technology.
52
+
53
+ He enjoys building scalable applications that solve real-world problems and
54
+
55
+ continuously explores new technologies to improve his skills.
56
+
57
+
58
+
59
+ Samuel has developed educational platforms, business management systems,
60
+
61
+ attendance systems, healthcare applications, and AI-powered solutions. He is
62
+
63
+ passionate about creating software that is modern, efficient, secure, and
64
+
65
+ user-friendly.
66
+
67
+
68
+
69
+ \## About AtomDev Studios
70
+
71
+
72
+
73
+ AtomDev Studios is the personal software development brand founded by Samuel
74
+
75
+ Peprah. The studio specializes in designing and developing modern websites,
76
+
77
+ web applications, business management systems, educational platforms, and
78
+
79
+ custom software solutions for individuals, startups, schools, and
80
+
81
+ organizations.
82
+
83
+
84
+
85
+ The mission of AtomDev Studios is to transform ideas into reliable, scalable,
86
+
87
+ and innovative digital products that solve real-world problems while
88
+
89
+ delivering exceptional user experiences.
90
+
91
+
92
+
93
+ \### Areas of Expertise
94
+
95
+
96
+
97
+ \- Full-Stack Web Development
98
+
99
+ \- Custom Web Applications
100
+
101
+ \- REST API Development
102
+
103
+ \- Database Design \& Management
104
+
105
+ \- Educational Technology Platforms
106
+
107
+ \- Healthcare Technology Solutions
108
+
109
+ \- AI Integration \& Automation
110
+
111
+ \- UI/UX Design
112
+
113
+ \- Cloud Deployment \& Hosting
114
+
115
+ \- Website Maintenance \& Support
116
+
117
+
118
+
119
+ \### Technologies
120
+
121
+
122
+
123
+ Python • Flask • JavaScript • HTML • CSS • Tailwind CSS • Bootstrap •
124
+
125
+ PostgreSQL • SQLite • Git • GitHub • Cloudflare • Docker
126
+
127
+
128
+
129
+ \### Connect
130
+
131
+
132
+
133
+ \- LinkedIn: \[samuel-peprah-a63598347](https://www.linkedin.com/in/samuel-peprah-a63598347)
134
+
135
+ \- X (Twitter): \[@legend\_consult](https://x.com/legend\_consult)
136
+
137
+ \- TikTok: \[@legendinlearning](https://www.tiktok.com/@legendinlearning)
138
+
139
+ \- Instagram: \[@ksapeprah](https://www.instagram.com/ksapeprah)
140
+
141
+ \- GitHub: \[Samuel-Peprah-cmd](https://github.com/Samuel-Peprah-cmd)
142
+
143
+
144
+
145
+ > "Building innovative software solutions that bridge technology with real-world impact."
146
+
147
+
148
+
149
+ \---
150
+
151
+
152
+
153
+ \## Modules
154
+
155
+
156
+
157
+ \- `mathtools` — primes, GCD/LCM, mean, median, standard deviation
158
+
159
+ \- `strtools` — palindromes, slugify, edit distance, anagrams, ciphers
160
+
161
+ \- `linalg` — matrix operations, determinants, inverses, linear systems
162
+
163
+ \- `calculus` — derivatives, integrals, Taylor series, Newton's method
164
+
165
+ \- `numbertheory` — extended GCD, modular inverse, sieve, prime factorization
166
+
167
+ \- `combinatorics` — permutations, combinations, Catalan numbers, Fibonacci
168
+
169
+ \- `filetools` — read/write any file, JSON, YAML, hashing, zip/unzip
170
+
171
+ \- `imagetools` — convert PNG/JPEG/BMP/GIF/WEBP/TIFF, resize, rotate, watermark, images-to-PDF
172
+
173
+ \- `pdftools` — extract text, merge, split, rotate, encrypt, create PDFs, PDF-to-images
174
+
175
+ \- `doctools` — read/write/edit Word docs, docx-to-PDF, PDF-to-docx
176
+
177
+ \- `spreadsheettools` — CSV, Excel, and JSON conversions
178
+ \- `unitconverter` — temperature, distance, weight, volume, speed, storage conversions
179
+ \- `presentationtools` — read/create PowerPoint decks, cloud themes, docx/pdf-to-pptx
180
+ \- `audiotools` — speech-to-text transcription, word timestamps, speaker diarization, SRT export
181
+ \- `videotools` — video transcription, frame extraction, speaker diarization to Word scripts
182
+
183
+ """
184
+
185
+
186
+
187
+ \_\_version\_\_ = "0.7.0"
188
+
@@ -4,14 +4,27 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "quicktools-atom"
7
- version = "0.3.0"
8
- description = "Math and string utilities with a bundled CLI, by AtomDev Studios"
7
+ version = "0.7.0"
8
+ description = "Math, text, presentation, audio, video, and file utilities by AtomDev Studios"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
11
11
  authors = [
12
12
  { name = "Samuel Peprah", email = "windscribe.samuel@gmail.com" }
13
13
  ]
14
- dependencies = []
14
+ dependencies = [
15
+ "Pillow",
16
+ "python-docx",
17
+ "pypdf",
18
+ "openpyxl",
19
+ "reportlab",
20
+ "PyYAML",
21
+ "pdf2docx",
22
+ "docx2pdf",
23
+ "python-pptx",
24
+ "faster-whisper",
25
+ "av",
26
+ "pyannote.audio",
27
+ ]
15
28
 
16
29
  [project.urls]
17
30
  Homepage = "https://github.com/Samuel-Peprah-cmd/quicktools"
@@ -5,8 +5,7 @@
5
5
 
6
6
  # quicktools
7
7
 
8
- A math and string-manipulation toolkit covering linear algebra, calculus,
9
- number theory, combinatorics, and text processing — built by **Samuel Peprah**
8
+ A math, text, media, and document automation toolkit built by **Samuel Peprah**
10
9
  under **AtomDev Studios**.
11
10
 
12
11
  ---
@@ -75,14 +74,22 @@ PostgreSQL • SQLite • Git • GitHub • Cloudflare • Docker
75
74
 
76
75
  ---
77
76
 
78
- ## Modules
79
-
77
+ ### Modules:
80
78
  - `mathtools` — primes, GCD/LCM, mean, median, standard deviation
81
79
  - `strtools` — palindromes, slugify, edit distance, anagrams, ciphers
82
80
  - `linalg` — matrix operations, determinants, inverses, linear systems
83
81
  - `calculus` — derivatives, integrals, Taylor series, Newton's method
84
82
  - `numbertheory` — extended GCD, modular inverse, sieve, prime factorization
85
83
  - `combinatorics` — permutations, combinations, Catalan numbers, Fibonacci
84
+ - `filetools` — read/write any file, JSON, YAML, hashing, zip/unzip
85
+ - `imagetools` — convert formats, resize, rotate, watermark, images-to-PDF
86
+ - `pdftools` — extract text, merge, split, rotate, encrypt, create PDFs, PDF-to-images
87
+ - `doctools` — read/write/edit Word docs, docx-to-PDF, PDF-to-docx
88
+ - `spreadsheettools` — CSV, Excel, and JSON conversions
89
+ - `unitconverter` — temperature, distance, weight, volume, speed, storage conversions
90
+ - `presentationtools` — read/create PowerPoint decks, cloud themes, docx/pdf-to-pptx
91
+ - `audiotools` — speech-to-text transcription, word timestamps, speaker diarization, SRT export
92
+ - `videotools` — video transcription, frame extraction, speaker diarization to Word scripts
86
93
  """
87
94
 
88
- __version__ = "0.2.0"
95
+ __version__ = "0.7.0"
@@ -0,0 +1,160 @@
1
+ """Audio transcription utilities, powered by faster-whisper (an optimized implementation
2
+ of OpenAI's Whisper speech recognition model) and Pyannote for Speaker Diarization.
3
+
4
+ Requires the optional 'faster-whisper' package: pip install faster-whisper
5
+ Diarization requires 'pyannote.audio': pip install pyannote.audio
6
+ The first call for a given model_size downloads that model (requires internet, one-time).
7
+ No separate ffmpeg installation is required — audio decoding is bundled in.
8
+ """
9
+
10
+ def _load_model(model_size: str = "base"):
11
+ try:
12
+ from faster_whisper import WhisperModel
13
+ except ImportError:
14
+ raise ImportError(
15
+ "Audio transcription requires faster-whisper. Install it with: pip install faster-whisper"
16
+ )
17
+ return WhisperModel(model_size, device="cpu", compute_type="int8")
18
+
19
+
20
+ def transcribe_audio(path: str, model_size: str = "base", language: str | None = None) -> str:
21
+ """Transcribe an audio file to plain text. model_size options (accuracy vs speed):
22
+ 'tiny', 'base', 'small', 'medium', 'large-v3'. language is an optional ISO code
23
+ (e.g. 'en') to skip auto-detection and speed things up."""
24
+ model = _load_model(model_size)
25
+ segments, _ = model.transcribe(path, language=language)
26
+ return " ".join(segment.text.strip() for segment in segments)
27
+
28
+
29
+ def transcribe_audio_with_timestamps(path: str, model_size: str = "base") -> list[dict]:
30
+ """Transcribe audio into a list of segments, each with 'start', 'end' (seconds), and 'text'."""
31
+ model = _load_model(model_size)
32
+ segments, _ = model.transcribe(path)
33
+ return [{"start": s.start, "end": s.end, "text": s.text.strip()} for s in segments]
34
+
35
+
36
+ def transcribe_audio_word_level(path: str, model_size: str = "base") -> list[dict]:
37
+ """Transcribe audio into a word-by-word list, each with 'word', 'start', and 'end' (seconds).
38
+ This gives true word-for-word timing, useful for captions or karaoke-style highlighting."""
39
+ model = _load_model(model_size)
40
+ segments, _ = model.transcribe(path, word_timestamps=True)
41
+ words = []
42
+ for segment in segments:
43
+ for word in segment.words:
44
+ words.append({"word": word.word.strip(), "start": word.start, "end": word.end})
45
+ return words
46
+
47
+
48
+ def detect_audio_language(path: str, model_size: str = "base") -> str:
49
+ """Detect the spoken language of an audio file, returning its ISO language code (e.g. 'en')."""
50
+ model = _load_model(model_size)
51
+ _, info = model.transcribe(path)
52
+ return info.language
53
+
54
+
55
+ def save_transcript_as_srt(segments: list[dict], output_path: str) -> None:
56
+ """Save a list of transcript segments (from transcribe_audio_with_timestamps) as an .srt
57
+ subtitle file, ready to use with any video player or editor."""
58
+ def format_timestamp(seconds: float) -> str:
59
+ hours = int(seconds // 3600)
60
+ minutes = int((seconds % 3600) // 60)
61
+ secs = int(seconds % 60)
62
+ millis = int((seconds - int(seconds)) * 1000)
63
+ return f"{hours:02d}:{minutes:02d}:{secs:02d},{millis:03d}"
64
+
65
+ lines = []
66
+ for i, seg in enumerate(segments, start=1):
67
+ lines.append(str(i))
68
+ lines.append(f"{format_timestamp(seg['start'])} --> {format_timestamp(seg['end'])}")
69
+ lines.append(seg["text"])
70
+ lines.append("")
71
+
72
+ with open(output_path, "w", encoding="utf-8") as f:
73
+ f.write("\n".join(lines))
74
+
75
+
76
+ # --- NEW DIARIZATION AND STYLING FEATURES ---
77
+
78
+ def transcribe_with_speakers(path: str, hf_token: str, model_size: str = "base") -> list[dict]:
79
+ """
80
+ Transcribes audio and aligns the text with Speaker IDs using Pyannote.
81
+ Returns a list of dicts: [{"start": 0.0, "end": 5.0, "speaker": "Speaker 00", "text": "Hello"}]
82
+ Requires a Hugging Face token with access to pyannote/speaker-diarization-3.1.
83
+ """
84
+ try:
85
+ from pyannote.audio import Pipeline
86
+ except ImportError:
87
+ raise ImportError(
88
+ "Speaker diarization requires pyannote.audio. Install it with: pip install pyannote.audio"
89
+ )
90
+
91
+ print("1/3: Analyzing voice biometrics (Diarization)...")
92
+ pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1", use_auth_token=hf_token)
93
+ diarization = pipeline(path)
94
+
95
+ print("2/3: Transcribing audio text...")
96
+ model = _load_model(model_size)
97
+ segments, _ = model.transcribe(path)
98
+
99
+ print("3/3: Aligning text to speakers...")
100
+ transcript_data = []
101
+
102
+ for segment in segments:
103
+ # Find the midpoint of the spoken phrase
104
+ segment_midpoint = (segment.start + segment.end) / 2
105
+
106
+ # Check which speaker was talking at that exact millisecond
107
+ current_speaker = "Unknown"
108
+ for turn, _, speaker in diarization.itertracks(yield_label=True):
109
+ if turn.start <= segment_midpoint <= turn.end:
110
+ current_speaker = speaker
111
+ break
112
+
113
+ transcript_data.append({
114
+ "start": segment.start,
115
+ "end": segment.end,
116
+ "speaker": current_speaker.replace("SPEAKER_", "Speaker "),
117
+ "text": segment.text.strip()
118
+ })
119
+
120
+ return transcript_data
121
+
122
+
123
+ def save_transcript_to_docx(transcript_data: list[dict], output_path: str) -> None:
124
+ """
125
+ Takes speaker-mapped transcript data and generates a beautifully styled Word document.
126
+ Requires the 'python-docx' package.
127
+ """
128
+ try:
129
+ from docx import Document
130
+ from docx.shared import Pt, RGBColor
131
+ except ImportError:
132
+ raise ImportError("Saving to Word requires python-docx. Run: pip install python-docx")
133
+
134
+ doc = Document()
135
+ title = doc.add_heading("Audio Meeting Transcript", level=1)
136
+ title.alignment = 1 # Center align
137
+
138
+ # Track the last speaker so we don't print the name over and over for continuous talking
139
+ last_speaker = None
140
+
141
+ for entry in transcript_data:
142
+ p = doc.add_paragraph()
143
+
144
+ # Convert raw seconds into [MM:SS] format
145
+ start_m, start_s = divmod(int(entry['start']), 60)
146
+ time_str = f"[{start_m:02d}:{start_s:02d}]"
147
+
148
+ # Only print the Speaker ID if the speaker changed
149
+ if entry['speaker'] != last_speaker:
150
+ speaker_run = p.add_run(f"{time_str} {entry['speaker']}:\n")
151
+ speaker_run.bold = True
152
+ # Give the speaker tag a nice professional blue color
153
+ speaker_run.font.color.rgb = RGBColor(0, 102, 204)
154
+ last_speaker = entry['speaker']
155
+
156
+ # Add the actual spoken text
157
+ p.add_run(entry['text'])
158
+ p.paragraph_format.space_after = Pt(8)
159
+
160
+ doc.save(output_path)