Text To Speech: Text Replacement (eg > reads as "greater than")

Is there any way to customize how the native anki TTS reads certain text?
eg:
↓ reads as “decreased”

reads as “greater than”
reads as “less than”
AMS reads as “altered mental status”
Na+ reads as “sodium”

I know that the Awesome TTS plugin has this ability, but I switched to native as the native TTS can be read on mobile and desktop.

I don’t think so. You could emulate the AwesomeTTS behaviour via Javascript replacing the chars and acronyms for the strings you want to listen.

Interesting! I may or may not have the technical ability to carry this out. I have some basic familiarity with python scripting, AutoHotkey scripting, and general coding principals, but not with javascript or creating an Anki addon specifically. Does “using Javascript to replace the chars and acronyms” seem like something I could accomplish with my current skill set? If so how would I go about doing this? Thanks for any help that can be provided!

I’ experimented with what and does not work, as the tts is expecting a field reference.

<script>
var text = "{{Front}}";
text = text.replace("&gt;", "greater than");
text = text.replace("&lt;", "less than");
text = text.replace("AMS", "altered mental status");
text = text.replace("Na+", "sodium");
document.getElementById("modified").innerHTML = text;
</script>

I guess that can be accomplished by creating a similar method that this:


Let's see what other more familiar with Anki code have to say about this.
1 Like

I’m afraid that won’t work, as the TTS processing happens before the text reaches the webview. There is no built in way to accomplish this across platforms at the moment, but it may come in a future update.

3 Likes

You can batch-generate audio files with AwesomeTTS, in which case you’ll have the same audio on desktop and mobile.

2 Likes

I previously tried that years ago for one of my decks and it did work, but my card database is now so large that the added size generating the audio files is too much for my phone. The native TTS (even without abbreviation support) is still the best option for my situation, I’ll just wait and hope for the feature to be added. Thanks.

Sorry for barging in but I have a similiar question, I’m wondering if it possibile to have some kind of restriction on tts, like “strip off text between brackets option” on the awesometts addon or regex option. Thank you.

Use HyperTTS, which gives you absolute full control over text replacement logic, with easy preview.