mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00

We can now show replay buttons for the audio contained in {{FrontSide}} without having to play it again when the answer is shown. The template code now always defers FrontSide rendering, as it wasn't a big saving, and meant the logic had to be implemented twice.
41 lines
865 B
Python
41 lines
865 B
Python
# Copyright: Ankitects Pty Ltd and contributors
|
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
"""
|
|
Sound/TTS references extracted from card text.
|
|
|
|
These can be accessed via eg card.question_av_tags()
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import List, Union
|
|
|
|
|
|
@dataclass
|
|
class TTSTag:
|
|
"""Records information about a text to speech tag.
|
|
|
|
See tts.py for more information.
|
|
"""
|
|
|
|
field_text: str
|
|
lang: str
|
|
voices: List[str]
|
|
# each arg should be in the form 'foo=bar'
|
|
other_args: List[str]
|
|
|
|
|
|
@dataclass
|
|
class SoundOrVideoTag:
|
|
"""Contains the filename inside a [sound:...] tag.
|
|
|
|
Video files also use [sound:...].
|
|
"""
|
|
|
|
filename: str
|
|
|
|
|
|
# note this does not include image tags, which are handled with HTML.
|
|
AVTag = Union[SoundOrVideoTag, TTSTag]
|