diff --git a/openbb_terminal/forecast/forecast_controller.py b/openbb_terminal/forecast/forecast_controller.py index 4c2698ad1255..b76a429cd73b 100644 --- a/openbb_terminal/forecast/forecast_controller.py +++ b/openbb_terminal/forecast/forecast_controller.py @@ -3347,6 +3347,8 @@ def call_whisper(self, other_args: List[str]): parser = self.add_standard_args( parser, ) + if other_args and "--video" not in other_args: + other_args.insert(0, "--video") ns_parser = self.parse_known_args_and_warn( parser, other_args, diff --git a/openbb_terminal/forecast/whisper_model.py b/openbb_terminal/forecast/whisper_model.py index a691ec76b41f..8980f35b3d6e 100644 --- a/openbb_terminal/forecast/whisper_model.py +++ b/openbb_terminal/forecast/whisper_model.py @@ -1,6 +1,6 @@ """Utilize OpenAI Whisper to transcribe and summarize text""" __docformat__ = "numpy" -# pylint: disable=I0011,C0413 +# pylint: disable=I0011,C0413,R0915,R0912,R0914 import logging import os import tempfile @@ -76,11 +76,11 @@ def transcribe_and_summarize( if video == "": console.print("[red]Please provide a video URL. [/red]") return - else: - # check to make sure the video is a valid URL with a .com - if not ((video.startswith("https") or "youtube" in video) and ".com" in video): - console.print("[red]Please provide a valid video URL. [/red]") - return + + # check to make sure the video is a valid URL with a .com + if not ((video.startswith("https") or "youtube" in video) and ".com" in video): + console.print("[red]Please provide a valid video URL. [/red]") + return os.makedirs(output_dir, exist_ok=True) @@ -300,8 +300,7 @@ def transcribe_and_summarize( (1 - (summary_text_length / original_text_length)) * 100, 2 ) # if there is negative reduction, set to 0 - if percent_reduction < 0: - percent_reduction = 0 + percent_reduction = max(percent_reduction, 0) console.print("") console.print("-------------------------") diff --git a/openbb_terminal/forecast/whisper_utils.py b/openbb_terminal/forecast/whisper_utils.py index b3f2b3918377..a969487d95fa 100644 --- a/openbb_terminal/forecast/whisper_utils.py +++ b/openbb_terminal/forecast/whisper_utils.py @@ -48,7 +48,7 @@ def break_line(line: str, length: int): def process_segment(segment: dict, line_length: int = 0): segment["text"] = segment["text"].strip() - if line_length > 0 and len(segment["text"]) > line_length: + if line_length and len(segment["text"]) > line_length: # break at N characters as per Netflix guidelines segment["text"] = break_line(segment["text"], line_length)