Anki Forums

Cloze: play sound only when particular cloze answer is revealed

I have a language learning cloze card where I want to highlight the equivalency between two sentences:

{{c1::Volvamos a casa.}}

{{c2::Vamos}} a volver a casa.

I want to get a sound recording of “vamos a volver a casa” to play only when c2 is revealed as the answer. And I want a sound recording of “volvamos a casa” to play when c1 is revealed as the answer.

I have tried the following:

{{c1::Volvamos a casa.}}

{{c2::Vamos}} a volver a casa.

{{c1::[sound:volvamos a casa.mp3]}} {{c2::[sound:vamos a volver a casa.mp3]}}

However, this plays the sound not only when the relevant cloze is revealed as the answer, but also on the card where it isn’t a cloze question. e.g. you end up with a front-side that looks like this:

Volvamos a casa.

[...] a volver a casa.

[sound:volvamos a casa.mp3]

…and a back-side like this:

Volvamos a casa.

[...] a volver a casa.

[sound:volvamos a casa.mp3][sound:vamos a volver a casa.mp3]

Where you what you want is …

Volvamos a casa.

[...] a volver a casa.

… with a back-side like this:

Volvamos a casa.

Vamos a volver a casa.

[sound:vamos a volver a casa.mp3]

Is there a way of doing what I want to do here, while still using a cloze card, and taking advantage of the convenience that the cloze system provides (over and above complex custom card templates etc.)

Conditional generation provides a special field so you can check which card you are rendering. If you wanted to display the “hint1” field on the first cloze, and “hint2” field on the second cloze for example, you could use the following template:

{{cloze:Text}}

{{#c1}}
    {{Hint1}}
{{/c1}}

{{#c2}}
    {{Hint2}}
{{/c2}}

https://docs.ankiweb.net/#/templates/generation?id=cloze-templates

1 Like

Many thanks @kelciour

1 Like