Question about TTS Audio Buttons

I’m having a very punctual issue. My template looks as following:

So, the audios works with TTS, so, what basically what these audios plays is based on the content of the fields “Anverso” and “Example”.

The audios of TTS work perfectly but the problem is that in some cards, I don’t have examples, therefore, the button for playing the example audio isn’t necessary. However, it appears anyway.

My question is, Is there any way to make that button dissappear if the Example field is empty?

I think to solve this we’ll have to see the template itself, not the preview. Both front and back please – and best if it is

\```
\text in a code block. 
\```

Conditional Replacement
It is possible to include certain text, fields, or HTML on your cards only if a field is empty or not empty. An example:

This text is always shown.

{{#FieldName}}
    This text is only shown if FieldName has text in it
{{/FieldName}}

{{^FieldName}}
    This text is only shown if FieldName is empty
{{/FieldName}}

https://docs.ankiweb.net/templates/generation.html#conditional-replacement

1 Like

I considered that too, but if the field is actually empty, you don’t need Conditional Replacement. You can just call the field replacement and nothing will appear. Conditional Replacement allows you to trigger other text/markings show or not show based on the field contents.

Both –

{{#Audio 1}}
    {{Audio 1}}
{{/Audio 1}}

– and –

{{Audio 1}}

– will show the same thing. If there is a sound tag in Audio 1, the play button will show up. If there isn’t, the play button won’t

So since this field is empty, and the button is showing up anyway, that tells me it’s more complex on the template (possibly related to it being aligned at the bottom right, having a title, having a formatted play button, etc.).

1 Like

Thanks guys, I will be testing this later today or tomorrow. I will let you know if it worked out.

I tried the conditional replacement and it worked! Thanks

1 Like