Skip to main content

Module speakers

Module speakers 

Source
Expand description

Speaker recognition: the CAST block, speakers.json, and the built-in fallback list. Port of the speaker half of XILP001_script_parser.py.

Structsยง

CastEntry
One CAST-block entry.
SpeakerMatch
A speaker matched at the start of a line.
Speakers
Display names (match order) plus the display โ†’ key map.

Constantsยง

BUILTIN ๐Ÿ”’
Built-in display names, already longest-first as the Python literal is.

Staticsยง

NON_WORD ๐Ÿ”’
PAREN ๐Ÿ”’
ROLE_DASH ๐Ÿ”’
SPACES ๐Ÿ”’

Functionsยง

builtin_key_order ๐Ÿ”’
builtin_speakers
The built-in table, for callers that need it without any script context.
display_to_key
Display name โ†’ normalized key: drop parentheticals and punctuation, lowercase, collapse whitespace to underscores.
extract_cast_from_script
Parse the CAST: bullet block from the script header.
key_to_display
Reverse map key โ†’ first display name, as generate_cast_config builds it from the module-level SPEAKER_KEYS.
load_speakers
Merge CAST-block entries with speakers.json, falling back to the built-ins only when neither exists.
load_speakers_registry
Full speakers.json entries keyed by speaker key, for cast skeletons.
read_speakers_json ๐Ÿ”’
resolve_speakers_file
Which speakers.json to load, without reading it.
try_match_speaker
Match a known speaker prefix, splitting off any (direction).