From 38835f62d393b1376b52d4c71d9e883a6edbb060 Mon Sep 17 00:00:00 2001 From: CGlide Date: Tue, 23 Jun 2026 03:11:59 +0200 Subject: [PATCH] Delete speech_length_calculator.py --- speech_length_calculator.py | 51 ------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 speech_length_calculator.py diff --git a/speech_length_calculator.py b/speech_length_calculator.py deleted file mode 100644 index 8f41b78..0000000 --- a/speech_length_calculator.py +++ /dev/null @@ -1,51 +0,0 @@ -import re -import math - -class SpeechLengthCalculator: - @classmethod - def INPUT_TYPES(s): - return { - "required": { - "text": ("STRING", {"multiline": True, "default": 'Enter your script here. "Make sure to put spoken words inside quotes!"'}), - "fps": ("INT", {"default": 24, "min": 1, "max": 120, "step": 1}), - "additional_time": ("FLOAT", {"default": 0.0, "min": 0.0, "step": 0.1}), - }, - "optional": { - "text_input": ("STRING", {"forceInput": True}), - } - } - - # Added "STRING" to RETURN_TYPES - RETURN_TYPES = ("INT", "INT", "INT", "STRING") - # Added "text" to RETURN_NAMES - RETURN_NAMES = ("slow_frame_count", "average_frame_count", "fast_frame_count", "text") - FUNCTION = "calculate_speech" - CATEGORY = "WhatDreamsCost" - - def calculate_speech(self, text, fps, additional_time=0.0, text_input=None): - # Prioritize the connected text_input if provided, otherwise fallback to the text widget - active_text = text_input if (text_input is not None and isinstance(text_input, str) and text_input.strip() != "") else text - - # Regex to find words inside double quotes, single quotes, or smart quotes - matches = re.findall(r'"([^"]*)"|\'([^\']*)\'|“([^”]*)”|‘([^’]*)’', active_text) - - # Extract matches, handling all possible captured groups from the regex - quoted_text = " ".join([next((g for g in m if g), "") for m in matches]) - - # Split by whitespace to get words and count them - words = quoted_text.split() - word_count = len(words) - - def calc_frames(wpm): - if word_count == 0 and additional_time == 0: - return 0 - minutes = word_count / wpm - seconds = (minutes * 60) + additional_time - return math.ceil(seconds * fps) - - slow_frames = calc_frames(100) - avg_frames = calc_frames(130) - fast_frames = calc_frames(160) - - # Added active_text as the 4th returned value - return (slow_frames, avg_frames, fast_frames, active_text) \ No newline at end of file