Skip to content

Commit 30b43f6

Browse files
committed
Handle the case when there is no voice in the video and text to translate
1 parent d83d568 commit 30b43f6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

open_dubbing/translation.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,11 @@ def _add_translations(
130130
stripped_translation = re.sub(
131131
rf"^\s*{_BREAK_MARKER}\s*|\s*{_BREAK_MARKER}\s*$", "", translated_script
132132
)
133-
text_segments = stripped_translation.split(_BREAK_MARKER)
133+
if stripped_translation:
134+
text_segments = stripped_translation.split(_BREAK_MARKER)
135+
else:
136+
text_segments = []
137+
134138
if len(utterance_metadata) != len(text_segments):
135139
raise ValueError(
136140
"The utterance metadata must be of the same length as the text"

tests/translation_test.py

+5
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ def test_generate_script(self, test_name, utterance_metadata, expected_script):
139139
},
140140
],
141141
),
142+
(
143+
[],
144+
"",
145+
[],
146+
),
142147
],
143148
)
144149
def test_add_translations(

0 commit comments

Comments
 (0)