Skip to content

Commit

Permalink
Fix linters. Add --video if not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaslek committed Feb 28, 2023
1 parent 427cab0 commit f1a993a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 2 additions & 0 deletions openbb_terminal/forecast/forecast_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 7 additions & 8 deletions openbb_terminal/forecast/whisper_model.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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("-------------------------")
Expand Down
2 changes: 1 addition & 1 deletion openbb_terminal/forecast/whisper_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit f1a993a

Please sign in to comment.