HHousen / lecture2notes

Consider using in PYL-R1714
Performance
Major
8 months ago4 years old
Consider merging these comparisons with 'in' by using 'bands in (('R', 'G', 'B'), ('R', 'G', 'B', 'A'))'. Use a set instead if elements are hashable.
 48    """
 49    pil_img = Image.fromarray(image)
 50    bands = pil_img.getbands()
 51    if bands == ("R", "G", "B") or bands == ("R", "G", "B", "A"): 52        thumb = pil_img.resize((thumb_size, thumb_size))
 53        SSE, bias = 0, [0, 0, 0]
 54        if adjust_color_bias:
Consider merging these comparisons with 'in' by using 'method in ('deepspeech', 'vosk')'. Use a set instead if elements are hashable.
864    for chunk in tqdm(chunks, desc="Processing Chunks"):
865        if chunk.endswith(".wav"):
866            chunk_path = Path(chunk_dir) / chunk
867            if method == "deepspeech" or method == "vosk":868                if model_dir is None:
869                    raise AssertionError
870                model = load_model(method, model_dir)
Consider merging these comparisons with 'in' by using 'params.transcription_method in ('deepspeech', 'vosk')'. Use a set instead if elements are hashable.
 75
 76        # Perform argument checks
 77        if (
 78            params.transcription_method == "deepspeech" 79            or params.transcription_method == "vosk"
 80        ) and params.transcribe_model_dir is None:
 81            logger.error(
Consider merging these comparisons with 'in' by using 'output_path.suffix not in ('.srt', '.vtt')'. Use a set instead if elements are hashable.
 31        if output_path.suffix == "":
 32            output_path = output_path.with_suffix(".vtt")
 33            sub_format = "vtt"
 34        elif output_path.suffix != ".srt" and output_path.suffix != ".vtt": 35            raise Exception(
 36                "Only .srt and .vtt files are supported. You tried to create a "
 37                + output_path.suffix
Consider merging these comparisons with 'in' by using 'x not in ('large_stroke_width', 'large_height')'. Use a set instead if elements are hashable.
 86        enabled_checks = [
 87            x
 88            for x in enabled_checks
 89            if x != "large_stroke_width" and x != "large_height" 90        ]
 91
 92    # Start by selecting the first block and first paragraph in that block