videopython 0.25.6__tar.gz → 0.25.7__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.
- {videopython-0.25.6 → videopython-0.25.7}/PKG-INFO +1 -1
- {videopython-0.25.6 → videopython-0.25.7}/pyproject.toml +1 -1
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/text/transcription.py +39 -44
- {videopython-0.25.6 → videopython-0.25.7}/.gitignore +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/LICENSE +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/README.md +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/__init__.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/__init__.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/_device.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/dubbing/__init__.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/dubbing/dubber.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/dubbing/models.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/dubbing/pipeline.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/dubbing/timing.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/generation/__init__.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/generation/audio.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/generation/image.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/generation/translation.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/generation/video.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/registry.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/swapping/__init__.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/swapping/inpainter.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/swapping/models.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/swapping/segmenter.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/swapping/swapper.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/transforms.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/understanding/__init__.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/understanding/audio.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/understanding/image.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/understanding/separation.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/understanding/temporal.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/video_analysis.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/__init__.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/audio/__init__.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/audio/analysis.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/audio/audio.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/combine.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/description.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/effects.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/exceptions.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/progress.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/registry.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/scene.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/text/__init__.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/text/overlay.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/transforms.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/transitions.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/utils.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/video.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/editing/__init__.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/editing/multicam.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/editing/premiere_xml.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/editing/video_edit.py +0 -0
- {videopython-0.25.6 → videopython-0.25.7}/src/videopython/py.typed +0 -0
|
@@ -195,9 +195,12 @@ class Transcription:
|
|
|
195
195
|
def standardize_segments(self, *, time: float | None = None, num_words: int | None = None) -> Transcription:
|
|
196
196
|
"""Return a new Transcription with standardized segments.
|
|
197
197
|
|
|
198
|
+
Segments are also split on speaker changes so that each segment contains
|
|
199
|
+
words from a single speaker.
|
|
200
|
+
|
|
198
201
|
Args:
|
|
199
202
|
time: Maximum duration in seconds for each segment
|
|
200
|
-
num_words:
|
|
203
|
+
num_words: Maximum number of words per segment
|
|
201
204
|
|
|
202
205
|
Raises:
|
|
203
206
|
ValueError: If both time and num_words are provided or if neither is provided
|
|
@@ -212,64 +215,56 @@ class Transcription:
|
|
|
212
215
|
raise ValueError("Number of words must be positive")
|
|
213
216
|
|
|
214
217
|
# Collect all words from all segments
|
|
215
|
-
all_words = []
|
|
218
|
+
all_words: list[TranscriptionWord] = []
|
|
216
219
|
for segment in self.segments:
|
|
217
220
|
all_words.extend(segment.words)
|
|
218
221
|
|
|
219
222
|
if not all_words:
|
|
220
223
|
return Transcription(segments=[], language=self.language)
|
|
221
224
|
|
|
222
|
-
standardized_segments = []
|
|
225
|
+
standardized_segments: list[TranscriptionSegment] = []
|
|
226
|
+
|
|
227
|
+
def _flush(words: list[TranscriptionWord]) -> None:
|
|
228
|
+
if not words:
|
|
229
|
+
return
|
|
230
|
+
segment_text = " ".join(w.word for w in words)
|
|
231
|
+
standardized_segments.append(
|
|
232
|
+
TranscriptionSegment(
|
|
233
|
+
start=words[0].start,
|
|
234
|
+
end=words[-1].end,
|
|
235
|
+
text=segment_text,
|
|
236
|
+
words=words.copy(),
|
|
237
|
+
speaker=words[0].speaker,
|
|
238
|
+
)
|
|
239
|
+
)
|
|
223
240
|
|
|
224
241
|
if time is not None:
|
|
225
|
-
|
|
226
|
-
current_words = []
|
|
227
|
-
current_start = None
|
|
242
|
+
current_words: list[TranscriptionWord] = []
|
|
228
243
|
|
|
229
244
|
for word in all_words:
|
|
230
|
-
if
|
|
231
|
-
|
|
245
|
+
if not current_words:
|
|
246
|
+
current_words = [word]
|
|
247
|
+
elif word.speaker != current_words[0].speaker or word.end - current_words[0].start > time:
|
|
248
|
+
_flush(current_words)
|
|
232
249
|
current_words = [word]
|
|
233
|
-
elif word.end - current_start <= time:
|
|
234
|
-
current_words.append(word)
|
|
235
250
|
else:
|
|
236
|
-
|
|
237
|
-
if current_words:
|
|
238
|
-
segment_text = " ".join(w.word for w in current_words)
|
|
239
|
-
standardized_segments.append(
|
|
240
|
-
TranscriptionSegment(
|
|
241
|
-
start=current_start,
|
|
242
|
-
end=current_words[-1].end,
|
|
243
|
-
text=segment_text,
|
|
244
|
-
words=current_words.copy(),
|
|
245
|
-
)
|
|
246
|
-
)
|
|
251
|
+
current_words.append(word)
|
|
247
252
|
|
|
248
|
-
|
|
249
|
-
current_start = word.start
|
|
250
|
-
current_words = [word]
|
|
253
|
+
_flush(current_words)
|
|
251
254
|
|
|
252
|
-
# Add final segment
|
|
253
|
-
if current_words:
|
|
254
|
-
segment_text = " ".join(w.word for w in current_words)
|
|
255
|
-
standardized_segments.append(
|
|
256
|
-
TranscriptionSegment(
|
|
257
|
-
start=current_start, # type: ignore
|
|
258
|
-
end=current_words[-1].end,
|
|
259
|
-
text=segment_text,
|
|
260
|
-
words=current_words.copy(),
|
|
261
|
-
)
|
|
262
|
-
)
|
|
263
255
|
elif num_words is not None:
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
256
|
+
current_words = []
|
|
257
|
+
|
|
258
|
+
for word in all_words:
|
|
259
|
+
if not current_words:
|
|
260
|
+
current_words = [word]
|
|
261
|
+
elif word.speaker != current_words[0].speaker or len(current_words) >= num_words:
|
|
262
|
+
_flush(current_words)
|
|
263
|
+
current_words = [word]
|
|
264
|
+
else:
|
|
265
|
+
current_words.append(word)
|
|
266
|
+
|
|
267
|
+
_flush(current_words)
|
|
273
268
|
|
|
274
269
|
return Transcription(segments=standardized_segments, language=self.language)
|
|
275
270
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|