Python: captionbob.render
captionbob.render.effect_catalog
The effects of captionbob by name.
An effect is a subtitle effect of captionbob/effects. The dashboard and the command line call an effect a style. Each effect is named by the name of its file in captionbob/effects with no suffix. The table EFFECTS holds the settings class and the effect class of each effect, in the order of the default scripts tool, and says which effects take the caption measure.
An effect that also draws emoji layers next to its script has the method build_layers. Its script needs no emoji image. An emoji effect that takes a keyword picker shows its emoji on the captions that the picker gives a keyword, so the command line can give it the picker of the nouns and the adjectives of the transcript.
Source file: captionbob/render/effect_catalog.py
EffectEntry
class EffectEntry(NamedTuple)
One effect of the table.
Args:
name: The name of the file of the effect in captionbob/effects, with no suffix.settings_class: The frozen settings dataclass of the effect.effect_class: The effect class. Its build_ass_text gives the text of the ASS script.takes_measure: True when the effect class takes the caption measure as its second value.takes_keyword_picker: True when the effect draws emoji layers and its class takes the value keyword_picker, which names the captions that get an emoji.
find_effect
def find_effect(name: str) -> EffectEntry
Give the effect of a name.
Args:
name: The name of the file of the effect in captionbob/effects, with no suffix.
Returns:
The entry of the effect.
Raises:
ValueError: When no effect has the name.
has_emoji_layers
def has_emoji_layers(entry: EffectEntry) -> bool
Say whether an effect draws emoji layers next to its script.
Args:
entry: The entry of the effect.
Returns:
True when the effect class has the method build_layers.
build_effect
def build_effect(
entry: EffectEntry, settings: Any,
caption_measure: CaptionMeasure,
keyword_picker: KeywordPicker | None = None) -> Any
Make the effect of an entry with its settings.
Args:
entry: The entry of the effect.settings: The settings of the effect, an object of its settings class.caption_measure: The measure that the effect asks where libass draws each word. An effect that takes no measure does not get it.keyword_picker: The keyword picker of an effect that takes one. None keeps the default picker of the effect.
Returns:
The effect. Its build_ass_text gives the text of the ASS script.
Raises:
TypeError: When the settings are not an object of the settings class of the effect.ValueError: When a keyword picker is given to an effect that takes none.