Anki TTS crash if Cloze begins with "<" symbol

Hi.

I’m experiencing a recurring issue where Anki crashes whenever my cloze begins with the “<” (less than) symbol. The error occurs only on this symbol and if the TTS language is set to english (no crash if set to sv_SE but the symbol isnt read aloud). I’ve tried it multiple computers (all Swedish windows) and it persists when running Anki in safe mode.

This is very irritating since I have to edit the card each time this happens (quite often because medical cards) and restart anki to make TTS work again.

Debug information: (My windows is in Swedish, Anki in English US)
Anki 24.11 (87ccd24e) (ao)
Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
Platform: Windows-10-10.0.22631

Traceback (most recent call last):
  File "aqt.taskman", line 144, in _on_closures_pending
  File "aqt.taskman", line 88, in <lambda>
  File "aqt.sound", line 300, in <lambda>
  File "aqt.sound", line 355, in _on_done
  File "concurrent.futures._base", line 439, in result
  File "concurrent.futures._base", line 391, in __get_result
  File "concurrent.futures.thread", line 58, in run
  File "aqt.sound", line 299, in <lambda>
  File "aqt.tts", line 531, in _play
  File "<COMObject SAPI.SpVoice>", line 2, in Speak
pywintypes.com_error: (-2147352567, 'Undantag inträffade.', (0, None, 'XML parser error', None, 0, -2147200958), None)"

My card templates contains

TTS front: {{tts en_US voices=Microsoft_Zira speed=2.2:cloze:Text}}
TTS back: {{tts en_US voices=Microsoft_Zira speed=2.2:cloze-only:Text}}

Does anyone know how I can fix it?

Thanks

1 Like

Original post: Reddit - Dive into anything

From SpeechVoiceSpeakFlags (SAPI 5.4) | Microsoft Learn, it seems like the default behaviour is to treat it as xml if it starts with <

Right now the only explicit flag that anki sets is SVSFlagsAsync

I suspect setting SVSFIsNotXML should fix it, but i don’t use tts so i don’t know if people actually currently use xml in their tts fields

EDIT: This only happens if it’s actually < and not &lt;, which means the field editor should also have trouble displaying your note :thinking:

2 Likes

I don’t think XML processing is expected or supported.

Logged on Anki TTS crash if Cloze begins with “<” symbol · Issue #3650 · ankitects/anki · GitHub

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.