File size: 7,938 Bytes
3c9face
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
"""

Attribute map utility

---------------------



Expose a structured mapping of the voice design attributes described in

`prompt.txt` together with the inline emotion tags listed in

`emotions.txt`.  The module returns data that can be consumed by tooling

to programmatically build descriptions or sweep attribute combinations.

"""

from __future__ import annotations

import json
from pathlib import Path
from typing import Dict, Iterable, List, TypedDict


class AttributeMap(TypedDict, total=False):
    metadata: Dict[str, str]
    emotions: Dict[str, object]
    shared_attributes: Dict[str, Iterable[str]]
    realistic_only: Dict[str, object]
    creative_only: Dict[str, object]
    constraints: Dict[str, object]
    defaults: Dict[str, str]


MODULE_DIR = Path(__file__).resolve().parent
EMOTIONS_FILE = MODULE_DIR / "emotions.txt"
PROMPT_FILE = MODULE_DIR / "prompt.txt"


def _load_emotion_tags(path: Path) -> List[str]:
    if not path.exists():
        raise FileNotFoundError(f"Emotion tag file not found: {path}")

    tags: List[str] = []
    with path.open("r", encoding="utf-8") as handle:
        for raw_line in handle:
            line = raw_line.strip()
            if not line or line.startswith("#"):
                continue
            tags.append(line)
    return tags


def build_attribute_map(

    emotions_path: Path | None = None,

    prompt_path: Path | None = None,

) -> AttributeMap:
    """

    Return an attribute map that mirrors the guidance in `prompt.txt`.



    Parameters

    ----------

    emotions_path:

        Optional override for the emotion tag file. Defaults to

        `maya1/emotions.txt`.

    prompt_path:

        Included for symmetry/future validation. Defaults to

        `maya1/prompt.txt` and is currently used only for metadata.

    """

    emotions_file = emotions_path or EMOTIONS_FILE
    prompt_file = prompt_path or PROMPT_FILE

    emotion_tags = _load_emotion_tags(emotions_file)

    attribute_map: AttributeMap = {
        "metadata": {
            "source_prompt": str(prompt_file),
            "source_emotions": str(emotions_file),
            "description": (
                "Programmatic representation of Maya voice design attributes. "
                "Derived from prompt.txt guidance."
            ),
        },
        "emotions": {
            "inline_tags": emotion_tags,
            "persona_emotion_attribute": [
                "neutral",
                "energetic",
                "excited",
                "sad",
                "sarcastic",
                "dry",
            ],
            "intensity": ["low", "med", "high"],
        },
        "shared_attributes": {
            "age": ["20s", "30s", "40s"],
            "gender": ["male", "female"],
            "accent": [
                "american",
                "indian",
                "middle_eastern",
                "asian_american",
                "british",
            ],
            "pitch": ["low", "normal", "high"],
            "timbre_realistic": [
                "deep",
                "warm",
                "gravelly",
                "smooth",
                "raspy",
                "nasally",
                "throaty",
                "harsh",
            ],
            "timbre_creative": [
                "deep",
                "warm",
                "gravelly",
                "smooth",
                "raspy",
                "nasally",
                "throaty",
                "harsh",
                "robotic",
                "ethereal",
            ],
            "pacing": [
                "very_slow",
                "slow",
                "conversational",
                "brisk",
                "fast",
                "very_fast",
            ],
            "emotion_intensity": ["low", "med", "high"],
        },
        "realistic_only": {
            "domain": [
                "social_content",
                "podcast",
                "commercial",
                "education",
                "support",
                "entertainment",
                "corporate",
                "viral_content",
            ],
            "speaking_role": {
                "social_content": [
                    "youtube_vlogger",
                    "social_media_creator",
                    "influencer_voice",
                    "streamer_companion",
                ],
                "podcast": ["podcast_host", "interviewer"],
                "commercial": [
                    "ad_narrator",
                    "brand_spokesperson",
                    "product_demo_voice",
                    "sales_pitch_voice",
                ],
                "education": ["elearning_instructor", "kids_story_voice"],
                "support": [
                    "customer_support_agent",
                    "virtual_receptionist",
                    "healthcare_assistant",
                ],
                "entertainment": [
                    "storyteller",
                    "social_media_reaction",
                    "meme_voice",
                ],
                "corporate": [
                    "explainer_video_voice",
                    "event_host",
                    "corporate_training_narrator",
                ],
                "viral_content": ["short_form_narrator", "meme_voice"],
            },
            "register": ["formal", "neutral", "casual"],
        },
        "creative_only": {
            "character": [
                "animated_cartoon",
                "ai_machine_voice",
                "alien_scifi",
                "seductively",
                "flirty",
                "anime",
                "cyborg",
                "pirate",
                "dark_villain",
                "demon",
                "gangster",
                "mafia",
                "dramatic_narrator",
                "mythical_godlike_magical",
                "spy",
                "vampire",
                "alpha",
            ],
        },
        "constraints": {
            "pitch": {
                "note": (
                    "For age 40s, avoid high pitch (use sparingly, <= 15% of uses)."
                )
            },
            "creative_timbre": {
                "robotic": [
                    "ai_machine_voice",
                    "cyborg",
                    "alien_scifi",
                    "mythical_godlike_magical",
                ],
                "ethereal": [
                    "ai_machine_voice",
                    "cyborg",
                    "alien_scifi",
                    "mythical_godlike_magical",
                ],
            },
            "character_pacing_overrides": {
                "mafia": ["slow", "conversational"],
                "flirty": ["slow", "conversational"],
                "alpha": ["fast", "very_fast"],
                "seductively": ["very_slow", "slow"],
            },
            "defaults": "Default persona emotion should be neutral unless specified.",
        },
        "defaults": {
            "age": "20s",
            "gender": "female",
            "accent": "american",
        "pitch": "high",
            "timbre": "warm",
        "pacing": "brisk",
        "emotion": "excited",
            "emotion_intensity": "med",
            "domain": "social_content",
            "speaking_role": "influencer_voice",
            "register": "casual",
        },
    }

    return attribute_map


def main() -> None:
    """

    CLI helper: print the attribute map as JSON for inspection.

    """

    attribute_map = build_attribute_map()
    print(json.dumps(attribute_map, indent=2, sort_keys=True))


if __name__ == "__main__":
    main()