videopython 0.26.0__tar.gz → 0.26.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.
- {videopython-0.26.0 → videopython-0.26.1}/PKG-INFO +1 -1
- {videopython-0.26.0 → videopython-0.26.1}/pyproject.toml +1 -1
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/dubbing/dubber.py +12 -1
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/dubbing/pipeline.py +19 -7
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/generation/translation.py +12 -0
- {videopython-0.26.0 → videopython-0.26.1}/.gitignore +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/LICENSE +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/README.md +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/__init__.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/__init__.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/_device.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/dubbing/__init__.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/dubbing/models.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/dubbing/timing.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/generation/__init__.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/generation/audio.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/generation/image.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/generation/video.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/registry.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/swapping/__init__.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/swapping/inpainter.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/swapping/models.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/swapping/segmenter.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/swapping/swapper.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/transforms.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/understanding/__init__.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/understanding/audio.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/understanding/image.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/understanding/separation.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/understanding/temporal.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/ai/video_analysis.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/__init__.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/audio/__init__.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/audio/analysis.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/audio/audio.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/combine.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/description.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/effects.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/exceptions.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/progress.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/registry.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/scene.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/streaming.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/text/__init__.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/text/overlay.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/text/transcription.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/transforms.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/transitions.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/utils.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/base/video.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/editing/__init__.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/editing/multicam.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/editing/premiere_xml.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/editing/video_edit.py +0 -0
- {videopython-0.26.0 → videopython-0.26.1}/src/videopython/py.typed +0 -0
|
@@ -36,12 +36,15 @@ class VideoDubber:
|
|
|
36
36
|
voice_clone: bool = True,
|
|
37
37
|
enable_diarization: bool = False,
|
|
38
38
|
progress_callback: Callable[[str, float], None] | None = None,
|
|
39
|
+
transcription: Any = None,
|
|
39
40
|
) -> DubbingResult:
|
|
40
41
|
"""Dub a video into a target language.
|
|
41
42
|
|
|
42
43
|
Args:
|
|
43
44
|
enable_diarization: Enable speaker diarization to clone each speaker's
|
|
44
45
|
voice separately. Requires additional VRAM for the diarization model.
|
|
46
|
+
transcription: Optional pre-computed Transcription object. When provided,
|
|
47
|
+
the internal Whisper transcription step is skipped.
|
|
45
48
|
"""
|
|
46
49
|
if self._local_pipeline is None:
|
|
47
50
|
self._init_local_pipeline()
|
|
@@ -54,6 +57,7 @@ class VideoDubber:
|
|
|
54
57
|
voice_clone=voice_clone,
|
|
55
58
|
enable_diarization=enable_diarization,
|
|
56
59
|
progress_callback=progress_callback,
|
|
60
|
+
transcription=transcription,
|
|
57
61
|
)
|
|
58
62
|
|
|
59
63
|
def dub_and_replace(
|
|
@@ -65,8 +69,14 @@ class VideoDubber:
|
|
|
65
69
|
voice_clone: bool = True,
|
|
66
70
|
enable_diarization: bool = False,
|
|
67
71
|
progress_callback: Callable[[str, float], None] | None = None,
|
|
72
|
+
transcription: Any = None,
|
|
68
73
|
) -> Video:
|
|
69
|
-
"""Dub a video and return a new video with the dubbed audio.
|
|
74
|
+
"""Dub a video and return a new video with the dubbed audio.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
transcription: Optional pre-computed Transcription object. When provided,
|
|
78
|
+
the internal Whisper transcription step is skipped.
|
|
79
|
+
"""
|
|
70
80
|
result = self.dub(
|
|
71
81
|
video=video,
|
|
72
82
|
target_lang=target_lang,
|
|
@@ -75,6 +85,7 @@ class VideoDubber:
|
|
|
75
85
|
voice_clone=voice_clone,
|
|
76
86
|
enable_diarization=enable_diarization,
|
|
77
87
|
progress_callback=progress_callback,
|
|
88
|
+
transcription=transcription,
|
|
78
89
|
)
|
|
79
90
|
return video.add_audio(result.dubbed_audio, overlay=False)
|
|
80
91
|
|
|
@@ -114,21 +114,33 @@ class LocalDubbingPipeline:
|
|
|
114
114
|
voice_clone: bool = True,
|
|
115
115
|
enable_diarization: bool = False,
|
|
116
116
|
progress_callback: Callable[[str, float], None] | None = None,
|
|
117
|
+
transcription: Any | None = None,
|
|
117
118
|
) -> DubbingResult:
|
|
118
|
-
"""Process a video through the local dubbing pipeline.
|
|
119
|
+
"""Process a video through the local dubbing pipeline.
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
transcription: Optional pre-computed Transcription object. When provided,
|
|
123
|
+
the internal Whisper transcription step is skipped (saving time and VRAM).
|
|
124
|
+
Must be a ``videopython.base.text.transcription.Transcription`` instance
|
|
125
|
+
with populated ``segments``.
|
|
126
|
+
"""
|
|
119
127
|
from videopython.base.audio import Audio
|
|
120
128
|
|
|
121
129
|
def report_progress(stage: str, progress: float) -> None:
|
|
122
130
|
if progress_callback:
|
|
123
131
|
progress_callback(stage, progress)
|
|
124
132
|
|
|
125
|
-
report_progress("Transcribing audio", 0.05)
|
|
126
|
-
if self._transcriber is None or self._transcriber_diarization != enable_diarization:
|
|
127
|
-
self._init_transcriber(enable_diarization=enable_diarization)
|
|
128
|
-
self._transcriber_diarization = enable_diarization
|
|
129
|
-
|
|
130
133
|
source_audio = video.audio
|
|
131
|
-
|
|
134
|
+
|
|
135
|
+
if transcription is not None:
|
|
136
|
+
report_progress("Using provided transcription", 0.05)
|
|
137
|
+
else:
|
|
138
|
+
report_progress("Transcribing audio", 0.05)
|
|
139
|
+
if self._transcriber is None or self._transcriber_diarization != enable_diarization:
|
|
140
|
+
self._init_transcriber(enable_diarization=enable_diarization)
|
|
141
|
+
self._transcriber_diarization = enable_diarization
|
|
142
|
+
|
|
143
|
+
transcription = self._transcriber.transcribe(source_audio)
|
|
132
144
|
|
|
133
145
|
if not transcription.segments:
|
|
134
146
|
return DubbingResult(
|
|
@@ -48,6 +48,15 @@ LANGUAGE_NAMES = {
|
|
|
48
48
|
class TextTranslator:
|
|
49
49
|
"""Translates text between languages using local seq2seq models."""
|
|
50
50
|
|
|
51
|
+
# Languages without a direct opus-mt-{src}-{tgt} model. Maps (source, target)
|
|
52
|
+
# to an alternative HuggingFace model identifier.
|
|
53
|
+
_MODEL_OVERRIDES: dict[tuple[str, str], str] = {
|
|
54
|
+
("en", "pt"): "Helsinki-NLP/opus-mt-tc-big-en-pt",
|
|
55
|
+
("en", "ko"): "Helsinki-NLP/opus-mt-tc-big-en-ko",
|
|
56
|
+
("en", "ja"): "Helsinki-NLP/opus-mt-en-jap",
|
|
57
|
+
("en", "pl"): "Helsinki-NLP/opus-mt-en-zlw",
|
|
58
|
+
}
|
|
59
|
+
|
|
51
60
|
def __init__(self, model_name: str | None = None, device: str | None = None):
|
|
52
61
|
self.model_name = model_name
|
|
53
62
|
self.device = device
|
|
@@ -58,6 +67,9 @@ class TextTranslator:
|
|
|
58
67
|
def _get_local_model_name(self, source_lang: str, target_lang: str) -> str:
|
|
59
68
|
if self.model_name:
|
|
60
69
|
return self.model_name
|
|
70
|
+
override = self._MODEL_OVERRIDES.get((source_lang, target_lang))
|
|
71
|
+
if override:
|
|
72
|
+
return override
|
|
61
73
|
return f"Helsinki-NLP/opus-mt-{source_lang}-{target_lang}"
|
|
62
74
|
|
|
63
75
|
def _init_local(self, source_lang: str, target_lang: str) -> None:
|
|
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
|