Capture null input/outputs

Captures empty text inputs or outputs that would interfere with TTS generation (input) or returning a none/null text value back to TGWUI (output)
This commit is contained in:
erew123 authored and GitHub committed 2025-01-25 23:14:05 +00:00
1 parent c8d2a6fa51
commit 8f5bb216a6
1 file changed
+15 -1
+15 -1
View File
@@ -708,6 +708,13 @@ def send_and_generate(
def output_modifier(string, state):
"""Modifies TGWUI output to include TTS audio"""
debug_func_entry()
# Input validation
if string is None:
print_func("Error: Received no text input from TGWUI so cannot generate TTS.", message_type="error")
print_func(f"Input text first 100 char's: {string[:100]}...", message_type="error")
return string
if not mode_manager.config["tgwui"]["tgwui_activate_tts"]:
return string
@@ -722,7 +729,9 @@ def output_modifier(string, state):
img_info = ""
cleaned_text, img_info = tgwui_extract_and_remove_images(string)
if cleaned_text is None:
return
print_func("Error: Image processing resulted in no text to generate TTS", message_type="error")
print_func(f"Input text first 100 char's: {cleaned_text[:100]}...", message_type="error")
return string
# Get current settings
language_code = languages.get(mode_manager.config["tgwui"]["tgwui_language"])
@@ -797,6 +806,11 @@ def output_modifier(string, state):
if mode_manager.config["tgwui"]["tgwui_show_text"]:
string += tgwui_reinsert_images(cleaned_text, img_info)
if string is None:
print_func("Error: Final processed text is None after image reinsertion", message_type="error")
print_func(f"Input text first 100 char's: {string[:100]}...", message_type="error")
return cleaned_text
shared.processing_message = "*Is typing...*"
return string
else: