mirror of
https://github.com/openai/whisper.git
synced 2025-11-24 14:35:57 +00:00
Merge a388f1c3ba4a94ed5b9f5aece23d43a7beed1cc4 into 90db0de1896c23cbfaf0c58bc2d30665f709f170
This commit is contained in:
commit
63fdf0a058
@ -129,12 +129,16 @@ class SubtitlesWriter(ResultWriter):
|
||||
max_line_count: Optional[int] = None,
|
||||
highlight_words: bool = False,
|
||||
max_words_per_line: Optional[int] = None,
|
||||
subtitle_format: Optional[str] = None,
|
||||
font_color: Optional[str] = None,
|
||||
):
|
||||
options = options or {}
|
||||
max_line_width = max_line_width or options.get("max_line_width")
|
||||
max_line_count = max_line_count or options.get("max_line_count")
|
||||
highlight_words = highlight_words or options.get("highlight_words", False)
|
||||
max_words_per_line = max_words_per_line or options.get("max_words_per_line")
|
||||
subtitle_format = subtitle_format or options.get("subtitle_format", None)
|
||||
font_color = font_color or options.get("font_color", "#ffffff")
|
||||
preserve_segments = max_line_count is None or max_line_width is None
|
||||
max_line_width = max_line_width or 1000
|
||||
max_words_per_line = max_words_per_line or 1000
|
||||
@ -209,7 +213,7 @@ class SubtitlesWriter(ResultWriter):
|
||||
|
||||
yield start, end, "".join(
|
||||
[
|
||||
re.sub(r"^(\s*)(.*)$", r"\1<u>\2</u>", word)
|
||||
re.sub(r"^(\s*)(.*)$", fr"\1<font color={font_color}><{subtitle_format}>\2</{subtitle_format}></font>", word)
|
||||
if j == i
|
||||
else word
|
||||
for j, word in enumerate(all_words)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user