String Filter
A tiny string cleaner that strips separators from your TTS script
- filtered_string
String Filter is the unglamorous utility in this pack: it splits a single string on a delimiter and joins the pieces back together with nothing, giving you a cleaned-up string. In a TTS → Whisper captioning workflow you often have script text full of line breaks, punctuation, or separators you don't want to leak into your subtitle segments - and this is the node that strips them out.
How it works. It takes three inputs: single_string (the text to clean), delimiter (what to strip), and is_escape_char (a boolean, default false). The source builds a regex pattern [delimiter]+ and re.splits on it, then joins the pieces into one string. The is_escape_char flag matters when your delimiter uses ASCII escapes like \n, \t, or \" - flip it on and those get translated to their real characters before splitting, so you can strip literal newlines without pasting an actual line break into the field. One output: filtered_string (STRING).
So "Hello\nworld\nagain" with delimiter \n and is_escape_char on becomes "Helloworldagain". Want to strip a set of punctuation? A delimiter of ,。 removes both. It's a sibling to the pack's StringToStringList node, which splits the same way but returns a list instead of re-joining - different outputs, same mechanics.
Install. It ships in teddy1565/ComfyUI-TTS2Whisper. ComfyUI Manager: search "ComfyUI-TTS2Whisper", install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/teddy1565/ComfyUI-TTS2Whisper
Dependencies are pypinyin, numpy, torchaudio, torch - heavy for a string utility, but they're shared across the pack. No model downloads.
The gotcha: the delimiter isn't a plain literal - it's dropped straight into a regex character class. That means characters with special meaning inside a class, like \, ], or ^, need care, and the trailing + means runs of the delimiter collapse together (which is usually what you want anyway). If you're stripping something like a backslash, you may need to think about how it lands in the pattern. For ordinary punctuation and whitespace, it just works.
Honest take: this is a small utility you won't reach for constantly, but when you need to normalize a TTS script before it hits the alignment nodes, it's exactly the right size - no learning curve, does one thing, and lives in the same pack as the rest of the pipeline.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| single_string | STRING | — | |
| delimiter | STRING | — | |
| is_escape_char | BOOLEAN | false | if use ascii escape char, must enable |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| filtered_string | STRING | — |