Vocab-Apps / anki-hyper-tts

HyperTTS Addon for Anki
GNU General Public License v3.0
73 stars 10 forks source link

Regex Text Replacement Rules for Realtime TTS don't seem to work. #188

Closed jamesesw closed 1 month ago

jamesesw commented 1 month ago

I tried realtime TTS for my deck and, while it works great for fields that don't need much extra processing, I have a field that consists of a list of definitions, of which I only want audio for the first item. I could easily make it happen when generating audio files by using a regex filter but, when trying to recreate it in realtime TTS, the regex filter did not work for html tags.

Now, I believe that this is because of the option "Run text replacement rules last (uncheck to run first)" doesn't seem to be doing anything.

This is my field <div style="text-align: left;" class="yomitan-glossary"><ul><li>trial</li><li>test</li></ul></div>

and my regex rule (?<=/li)(.*)(?=/div) replaced for an empty space.

This should be outputting "trial" but instead outputs "trial test"

luc-vocab commented 1 month ago

if you want text replacement rules to operate on the untransformed HTML, you have to do two things here: https://www.vocab.ai/tutorials/hypertts-collection-audio#text-processing

give it a try, let me know if you're stuck, I can help you out (i'll need your deck).

jamesesw commented 1 month ago

Yes, I understand what those options do, and like I said, they work properly when creating audio files, but do not provide the same result when creating realtime audio for my cards, even when the same settings are checked and the same filters are provided, as you can see: Screenshot_12 Screenshot_13

one outputs "trial" as would be expected, the other one outputs "trial test" no matter what settings I check or uncheck.

luc-vocab commented 1 month ago

Unfortunately you are right and my reply was completely misguided. When processing realtime audio through the Anki TTS tag, unfortunately the text that makes it way to HyperTTS is already processed (anki strips out html tags). This means the amount of detailed text processing you can do on HyperTTS is limited when it comes to realtime TTS. Would you be able to send me your deck ? From the Anki main screen, click File → Export, click Export... . Then locate apkg file you just created, and upload it to https://www.dropbox.com/request/X9L4mhPqEcfvKFuSm2nK

jamesesw commented 1 month ago

Deck is pretty huge, let me export a smaller sample sized deck for convenience.

luc-vocab commented 1 month ago

Hi, I looked at your deck and I apologize I don't have a solution for realtime TTS. The issue is that Anki delivers the text to us already pre-processed when using realtime TTS. Are you open to collection audio ? The text processing capabilites are much more powerful here since we have access to the raw HTML.

jamesesw commented 1 month ago

Thanks for taking a look at it, Luc. Yes, I have generated audio files for all the cards, this experiment to use realtime was just to save some space on Media storage as my deck keeps growing. In any case, I can always make a new field to save a simplified version of the English field, and make realtime TTS read that one out instead. But for now I don't mind having the audio files.

luc-vocab commented 1 month ago

OK thank you. It's unfortunate that we lose out on lot of capabilities when using realtime TTS but unfortunately that's how Anki works right now.