speechmarkdown.formatters.ssml_base#

Classes#

TagsObject

Helper representing a tag object structure resolving nested values.

SsmlFormatterBase

Abstract base class for all Speech Markdown formatters.

Module Contents#

class speechmarkdown.formatters.ssml_base.TagsObject(base: SsmlFormatterBase)[source]#

Helper representing a tag object structure resolving nested values.

base[source]#
tags: Dict[str, Any][source]#
text: str = ''[source]#
tag(tag_name: str | None, attrs: Dict[str, Any] | None, augment: bool = False) None[source]#
voice_tag_named(voices: Dict[str, Any] | None, name: str) bool[source]#
voice_tag(value: str | None) None[source]#
class speechmarkdown.formatters.ssml_base.SsmlFormatterBase(options: speechmarkdown.options.SpeechOptions)[source]#

Bases: speechmarkdown.formatters.base.FormatterBase

Abstract base class for all Speech Markdown formatters.

XML_ESCAPE_MAPPING: Dict[str, str][source]#
XML_UNESCAPE_MAPPING: Dict[str, str][source]#
valid_voices: Dict[str, Any][source]#
section_tags: List[str] = [][source]#
modifier_key_mappings[source]#
ssml_tag_sort_order = ['emphasis', 'say-as', 'prosody', 'amazon:domain', 'amazon:effect', 'amazon:emotion', 'voice',...[source]#
modifier_key_to_ssml_tag_mappings[source]#
format(ast: speechmarkdown.parser.ASTNode | List[speechmarkdown.parser.ASTNode]) str[source]#

Format the given AST into a string.

Parameters:

ast (Union[ASTNode, List[ASTNode]]) – The parsed AST node(s).

Returns:

The formatted result.

Return type:

str

add_section_start_tag(tags_sorted_asc: List[str], so: TagsObject, lines: List[str]) None[source]#
add_section_end_tag(lines: List[str]) None[source]#
add_tag(tag: str, ast: speechmarkdown.parser.ASTNode | List[speechmarkdown.parser.ASTNode], new_line: bool, new_line_after_end: bool, attr: Dict[str, Any] | None, lines: List[str]) List[str][source]#
apply_tags_object(tmo: TagsObject, lines: List[str]) List[str][source]#
extract_parenthesized_text(node: speechmarkdown.parser.ASTNode) str[source]#
get_short_ipa_object(ast: speechmarkdown.parser.ASTNode, fallback_text: str = '') TagsObject[source]#
get_short_sub_object(ast: speechmarkdown.parser.ASTNode) TagsObject[source]#
add_speak_tag(ast: speechmarkdown.parser.ASTNode | List[speechmarkdown.parser.ASTNode], new_line: bool, new_line_after_end: bool, attr: Dict[str, Any] | None, lines: List[str]) List[str][source]#
add_comment(comment_text: str, lines: List[str]) List[str][source]#
start_tag(tag: str, attr: Dict[str, Any] | None, new_line: bool = False) str[source]#
end_tag(tag: str, new_line: bool = False) str[source]#
void_tag(tag: str, attr: Dict[str, Any] | None) str[source]#
add_tag_with_attrs(lines: List[str], text: str | None, tag: str, attrs: Dict[str, Any] | None, force_end_tag: bool = False) List[str][source]#
get_tag_with_attrs(text: str | None, tag: str, attrs: Dict[str, Any] | None) str[source]#
sentence_case(text: str) str[source]#
escape_xml_characters(unescaped: str) str[source]#
get_voice_tag_fallback(name: str) Dict[str, Any] | None[source]#