TTS for multiple fields together

At some point in time before Anki 2.1.20, AwesomeTTS allowed users to concatenate multiple fields together for on-the-fly TTS. The syntax looked like this (to be inserted into the card template):

<tts ...>

A number of months ago, I removed that functionality to use the standard Anki 2.1.20 TTS tag but it removed the ability to read multiple fields together (they need to be fed into the TTS engine together for a natural output).

I’m working on an evolution to AwesomeTTS and i’m trying to figure out how to replicate this functionality as some users have been asking for it. It seems to me the best option is to leverage Anki’s card template rendering and use some proprietary TTS tag format just like what AwesomeTTS used to do. Can someone think of an alternative ?

Note that this successor to AwesomeTTS will give the user the option of using the standard Anki 2.1.20 TTS tag, or this proprietary TTS tag for maximum flexibility.

Internally Anki can already handle this use case - the tts: filter simply rewrites the field into an [anki:tts] tag that is handled by the UI. It is not currently advertised, as the syntax could use some more thought before we commit to making it public. The thinking behind the syntax is that it should be easy to extract with a simple regex, and it should allow arbitrary options to be provided in a key/value format, so that each implementation can ignore keys it does not understand. Some things that we might want to change first:

  • currently the first argument (the language) is special-cased and has no associated key
  • options are embedded inside the tag; they might be better placed in the opening tag instead
  • spaces and square brackets can’t be included in the keys or values. This may be an acceptable limitation (and the TTS code automatically replaces spaces with underscores in voice names already), but could use a bit more thought.

@dae if I understand what you are saying, I could do [anki:tts][en_US]{Field1} {Field2}[/anki:tts] and Field1 and Field2 would get concatenated before being sent to the TTS player ?

I just tried with one of my notes: [anki:tts][zh_HK]{Chinese} {English}[/anki:tts] it doesn’t look like Chinese and English are being replaced with their field values. The TTS engine gets as input {Chinese} {English}

You’re missing a pair of curly brackets on the field names. But as mentioned above, this syntax is not set in stone yet. I’ve created a ticket on the issue tracker; please post any comments you have there: Decide on a syntax for tts outside of field references · Issue #1507 · ankitects/anki · GitHub