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.
Files changed (54) hide show
  1. {videopython-0.25.6 → videopython-0.25.7}/PKG-INFO +1 -1
  2. {videopython-0.25.6 → videopython-0.25.7}/pyproject.toml +1 -1
  3. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/text/transcription.py +39 -44
  4. {videopython-0.25.6 → videopython-0.25.7}/.gitignore +0 -0
  5. {videopython-0.25.6 → videopython-0.25.7}/LICENSE +0 -0
  6. {videopython-0.25.6 → videopython-0.25.7}/README.md +0 -0
  7. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/__init__.py +0 -0
  8. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/__init__.py +0 -0
  9. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/_device.py +0 -0
  10. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/dubbing/__init__.py +0 -0
  11. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/dubbing/dubber.py +0 -0
  12. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/dubbing/models.py +0 -0
  13. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/dubbing/pipeline.py +0 -0
  14. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/dubbing/timing.py +0 -0
  15. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/generation/__init__.py +0 -0
  16. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/generation/audio.py +0 -0
  17. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/generation/image.py +0 -0
  18. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/generation/translation.py +0 -0
  19. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/generation/video.py +0 -0
  20. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/registry.py +0 -0
  21. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/swapping/__init__.py +0 -0
  22. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/swapping/inpainter.py +0 -0
  23. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/swapping/models.py +0 -0
  24. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/swapping/segmenter.py +0 -0
  25. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/swapping/swapper.py +0 -0
  26. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/transforms.py +0 -0
  27. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/understanding/__init__.py +0 -0
  28. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/understanding/audio.py +0 -0
  29. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/understanding/image.py +0 -0
  30. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/understanding/separation.py +0 -0
  31. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/understanding/temporal.py +0 -0
  32. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/ai/video_analysis.py +0 -0
  33. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/__init__.py +0 -0
  34. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/audio/__init__.py +0 -0
  35. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/audio/analysis.py +0 -0
  36. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/audio/audio.py +0 -0
  37. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/combine.py +0 -0
  38. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/description.py +0 -0
  39. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/effects.py +0 -0
  40. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/exceptions.py +0 -0
  41. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/progress.py +0 -0
  42. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/registry.py +0 -0
  43. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/scene.py +0 -0
  44. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/text/__init__.py +0 -0
  45. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/text/overlay.py +0 -0
  46. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/transforms.py +0 -0
  47. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/transitions.py +0 -0
  48. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/utils.py +0 -0
  49. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/base/video.py +0 -0
  50. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/editing/__init__.py +0 -0
  51. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/editing/multicam.py +0 -0
  52. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/editing/premiere_xml.py +0 -0
  53. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/editing/video_edit.py +0 -0
  54. {videopython-0.25.6 → videopython-0.25.7}/src/videopython/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: videopython
3
- Version: 0.25.6
3
+ Version: 0.25.7
4
4
  Summary: Minimal video generation and processing library.
5
5
  Project-URL: Homepage, https://videopython.com
6
6
  Project-URL: Repository, https://github.com/bartwojtowicz/videopython/
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "videopython"
3
- version = "0.25.6"
3
+ version = "0.25.7"
4
4
  description = "Minimal video generation and processing library."
5
5
  authors = [
6
6
  { name = "Bartosz Wójtowicz", email = "bartoszwojtowicz@outlook.com" },
@@ -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: Exact number of words per segment
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
- # Group words by time constraint
226
- current_words = []
227
- current_start = None
242
+ current_words: list[TranscriptionWord] = []
228
243
 
229
244
  for word in all_words:
230
- if current_start is None:
231
- current_start = word.start
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
- # Create segment from current words
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
- # Start new segment
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
- # Group words by word count constraint
265
- for i in range(0, len(all_words), num_words):
266
- segment_words = all_words[i : i + num_words]
267
- segment_text = " ".join(w.word for w in segment_words)
268
- standardized_segments.append(
269
- TranscriptionSegment(
270
- start=segment_words[0].start, end=segment_words[-1].end, text=segment_text, words=segment_words
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