From fc547c5c185ea322d63bd221508cd4d2f55a094f Mon Sep 17 00:00:00 2001 From: Meisoftcoltd <38667978+Meisoftcoltd@users.noreply.github.com> Date: Fri, 22 May 2026 20:45:25 +0000 Subject: [PATCH] Fix AutoLoopCalculatorTTSBatch data type bug for downstream TTS nodes - Removed `INPUT_IS_LIST = True` to prevent ComfyUI from implicitly converting input values to lists and expecting lists as outputs. - Refactored `calculate` to handle list inputs natively using `isinstance` while correctly interacting with the standard Text Reader's native Python lists. - Changed the return signature to emit native primitive values (`str`, `int`) instead of wrapping them in lists, correctly accommodating downstream integration with TTS models (e.g. Fish Speech) that expect pure strings. --- loop.py | 19 +++++++------------ test_loop_syntax.py | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 test_loop_syntax.py diff --git a/loop.py b/loop.py index 8430c3c..2a23608 100644 --- a/loop.py +++ b/loop.py @@ -117,7 +117,7 @@ class AutoLoopCalculatorTTSBatch: } } - INPUT_IS_LIST = True + # 💡 FIX: Eliminado INPUT_IS_LIST = True para evitar que ComfyUI modifique los tipos de salida RETURN_TYPES = ("STRING", "INT", "INT", "STRING") RETURN_NAMES = ("current_text", "current_index", "total_chunks", "log") FUNCTION = "calculate" @@ -133,16 +133,11 @@ class AutoLoopCalculatorTTSBatch: loop.global_step_by_chunk = True - # 💡 FIX: Desempaquetar la doble lista generada por INPUT_IS_LIST = True - if isinstance(text_list, list) and len(text_list) > 0 and isinstance(text_list[0], list): - texts = text_list[0] - elif isinstance(text_list, list): - texts = text_list - else: - texts = [text_list] + # Como eliminamos INPUT_IS_LIST, text_list llega como la lista pura desde el Reader + texts = text_list if isinstance(text_list, list) else [text_list] - mode = split_mode[0] if isinstance(split_mode, list) else split_mode - idx = current_loop_index[0] if isinstance(current_loop_index, list) else current_loop_index + mode = split_mode + idx = current_loop_index current_batch_idx = getattr(loop, 'global_batch_index', 0) if current_batch_idx >= len(texts): @@ -191,8 +186,8 @@ class AutoLoopCalculatorTTSBatch: _log(f" -> 📜 Texto a procesar: {current_chunk_text[:75]}...") _log(f"{'='*50}\n") - # Must return as lists because INPUT_IS_LIST = True - return ([current_chunk_text], [safe_index], [total_chunks], ["\n".join(log_output)]) + # 💡 FIX: Devolvemos valores nativos, no listas + return (current_chunk_text, safe_index, total_chunks, "\n".join(log_output)) @register_node class AutoLoopCalculatorLTX: diff --git a/test_loop_syntax.py b/test_loop_syntax.py new file mode 100644 index 0000000..eadf78b --- /dev/null +++ b/test_loop_syntax.py @@ -0,0 +1,26 @@ +import sys +from unittest.mock import MagicMock + +sys.modules['torch'] = MagicMock() +sys.modules['comfy'] = MagicMock() +sys.modules['comfy.model_management'] = MagicMock() + +# Mocking relative import +class MockRegisterNode: + def __call__(self, cls): + return cls + +import builtins +real_import = builtins.__import__ + +def mocked_import(name, globals=None, locals=None, fromlist=(), level=0): + if name == '' and level > 0 and 'register_node' in fromlist: + mock_module = MagicMock() + mock_module.register_node = MockRegisterNode() + return mock_module + return real_import(name, globals, locals, fromlist, level) + +builtins.__import__ = mocked_import + +import loop +print("Sintaxis de loop.py verificada correctamente.")