Buffy: Tool that wraps and improves Woof
Woof is amazing! However I noticed it did have a high fail rate on some long sentences due to your sentence splitter needing a bit of improvements. Originally even on a small a small doc Gettysburg Address it had three very bad failures, until I fixed it.
I ended up writing a pre-processor Python function that fixes it. It made Woof go from failing quite often (to be honest) to having zero failures even on tons of documents I tested it with. All you need to do is look at my 'preprocess.py' file, and incorporate that into the core library. In a nutshell it intelligently places commas strategically which makes your own sentence splitter no longer fail. So you could add this logic to perfect your code.
The sentence splitter can leave a piece that ends mid-phrase, and Woof then repeats its last words. A 4-line change fixes it in the cases I tested.
Clay-Ferguson reported this in https://github.com/Clay-Ferguson/Buffy, and I reproduced it. In _split_conj, a piece over 120 characters with no punctuation is cut before a conjunction near its middle. The left half then ends on words like “for those” or “devotion to”. On the Gettysburg Address, Whisper hears “for those for those” at that boundary on seeds 0, 1, and 2. The retry check does not catch it, since the bad take is the one returned every time.
The change keeps a trailing comma on the left half, so every piece ends on punctuation. Against revision be70296, it replaces line 22 of underdog_woof/textsplit.py:
- return _split_conj(s[:c].strip(), clause_max) + _split_conj(s[c:].strip(), clause_max)
+ left = _split_conj(s[:c].strip(), clause_max)
+ if not left[-1].endswith((",", ";", ":", "\u2014", "--")):
+ left[-1] += ","
+ return left + _split_conj(s[c:].strip(), clause_max)
On the Gettysburg Address (10 sentences, 3 seeds, Juno, transcribed with whisper.cpp base.en), inserted words drop from 8 to 0 and word error rate from 2.4% to 1.4%. On the Declaration of Independence (33 lines, 1 seed) I saw no measurable change, 2.0% against 2.2%, which is within noise. No cut position moves, so text your splitter already handles cleanly comes out exactly as before.
I haven’t judged how the added pause sounds, only that the repeats are gone. I also haven’t tested other voices or text types.
Nice job! Looking forward to trying this out soon. I probably should've fixed it in the actual 'textsplit.py' like you did (instead of my external hack). At the time I was wanting to avoid touching Underdog code, so I didn't, but thanks for sharing what's probably the real "fix". Hopefully the Underdog team will see this too.