Spaces:
Running
Running
zach
commited on
Commit
·
6bb0509
1
Parent(s):
ae60c0f
Improve voice descriptions and normalized claude prompt
Browse files- src/constants.py +18 -25
- src/integrations/anthropic_api.py +19 -9
src/constants.py
CHANGED
@@ -42,43 +42,36 @@ SELECT_OPTION_B: str = "Select Option B"
|
|
42 |
# inspiration for generating creative, expressive text inputs for TTS, and generating novel voices.
|
43 |
SAMPLE_CHARACTER_DESCRIPTIONS: dict = {
|
44 |
"🧘 Meditation Guru": (
|
45 |
-
"A
|
46 |
-
"
|
47 |
-
"
|
48 |
),
|
49 |
"🚀 Stranded Astronaut": (
|
50 |
-
"
|
51 |
-
"with
|
52 |
-
"transmission, with an undercurrent of wistful melancholy."
|
53 |
),
|
54 |
-
"🎬 Noir
|
55 |
-
"A
|
56 |
-
"
|
57 |
-
"chosen with the precision of a private eye piecing together clues."
|
58 |
),
|
59 |
"🕯️ Victorian Ghost Storyteller": (
|
60 |
-
"A
|
61 |
-
"between whispers and dramatic
|
62 |
-
"building tension through perfectly timed pauses and haunting inflections."
|
63 |
),
|
64 |
"🌿 British Naturalist": (
|
65 |
-
"A
|
66 |
-
"
|
67 |
-
"animated excitement, painting vivid pictures of the natural world's endless marvels."
|
68 |
),
|
69 |
"🌟 Texan Storyteller": (
|
70 |
-
"A
|
71 |
-
"
|
72 |
-
"tales with the unhurried grace of a front-porch conversation."
|
73 |
),
|
74 |
"🏴☠️ Pirate Captain": (
|
75 |
-
"A
|
76 |
-
"
|
77 |
-
"gruff authority with the playful spirit of a born storyteller."
|
78 |
),
|
79 |
"🏄 Surfer Dude": (
|
80 |
-
"A
|
81 |
-
"
|
82 |
-
"carefree laughter and an infectious enthusiasm for life's simple pleasures."
|
83 |
),
|
84 |
}
|
|
|
42 |
# inspiration for generating creative, expressive text inputs for TTS, and generating novel voices.
|
43 |
SAMPLE_CHARACTER_DESCRIPTIONS: dict = {
|
44 |
"🧘 Meditation Guru": (
|
45 |
+
"A mindfulness instructor with a gentle, soothing voice that flows at a slow, measured pace with natural "
|
46 |
+
"pauses. Their consistently calm, low-pitched tone has minimal variation, creating a peaceful auditory "
|
47 |
+
"experience."
|
48 |
),
|
49 |
"🚀 Stranded Astronaut": (
|
50 |
+
"An astronaut in deep space communicating with a clear, precise voice with subtle radio distortion. "
|
51 |
+
"Speaking with controlled emotion, technical accuracy, measured pacing and thoughtful silences."
|
|
|
52 |
),
|
53 |
+
"🎬 Noir Detective": (
|
54 |
+
"A 1940s private investigator narrating with a low, gravelly voice and deliberate pacing. "
|
55 |
+
"Speaks with a cynical, world-weary tone that drops lower when delivering key observations."
|
|
|
56 |
),
|
57 |
"🕯️ Victorian Ghost Storyteller": (
|
58 |
+
"A Victorian-era raconteur speaking with a refined British accent and formal, precise diction. Voice "
|
59 |
+
"modulates between hushed, tense whispers and dramatic declarations when describing eerie occurrences."
|
|
|
60 |
),
|
61 |
"🌿 British Naturalist": (
|
62 |
+
"A wildlife documentarian speaking with a crisp, articulate British accent and clear enunciation. Voice "
|
63 |
+
"alternates between hushed, excited whispers and enthusiastic explanations filled with genuine wonder."
|
|
|
64 |
),
|
65 |
"🌟 Texan Storyteller": (
|
66 |
+
"A woman from rural Texas speaking with a warm voice and distinctive Southern drawl featuring elongated "
|
67 |
+
"vowels. Talks unhurriedly with a musical quality and occasional soft laughter."
|
|
|
68 |
),
|
69 |
"🏴☠️ Pirate Captain": (
|
70 |
+
"A seafaring pirate captain commanding with a rough, weathered voice that varies from quiet growls to "
|
71 |
+
"authoritative shouts. Exaggerates consonants, particularly rolling Rs, when giving orders."
|
|
|
72 |
),
|
73 |
"🏄 Surfer Dude": (
|
74 |
+
"A California surfer talking with a casual, slightly nasal voice and laid-back rhythm. Uses rising "
|
75 |
+
"inflections at sentence ends and bursts into spontaneous laughter when excited."
|
|
|
76 |
),
|
77 |
}
|
src/integrations/anthropic_api.py
CHANGED
@@ -87,9 +87,9 @@ class AnthropicConfig:
|
|
87 |
@staticmethod
|
88 |
def build_expressive_prompt(character_description: str) -> str:
|
89 |
"""
|
90 |
-
Constructs and returns a prompt based
|
91 |
-
|
92 |
-
|
93 |
|
94 |
Args:
|
95 |
character_description (str): A description of the character's voice and persona.
|
@@ -98,12 +98,22 @@ class AnthropicConfig:
|
|
98 |
str: The prompt to be passed to the Anthropic API.
|
99 |
"""
|
100 |
return f"""
|
101 |
-
Character Description: {character_description}
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
"""
|
108 |
|
109 |
|
|
|
87 |
@staticmethod
|
88 |
def build_expressive_prompt(character_description: str) -> str:
|
89 |
"""
|
90 |
+
Constructs and returns a prompt based on the provided character description.
|
91 |
+
This prompt instructs Claude to generate expressive dialogue that aligns semantically
|
92 |
+
with the character's voice qualities and persona, optimized for TTS synthesis.
|
93 |
|
94 |
Args:
|
95 |
character_description (str): A description of the character's voice and persona.
|
|
|
98 |
str: The prompt to be passed to the Anthropic API.
|
99 |
"""
|
100 |
return f"""
|
101 |
+
Character Description: {character_description}
|
102 |
+
|
103 |
+
Please generate a short monologue (100-300 characters) that this character would naturally say.
|
104 |
+
The dialogue should:
|
105 |
+
|
106 |
+
- Match the speaking style, vocabulary, and emotional tone described in the character description
|
107 |
+
- Include appropriate speech patterns, pauses, and vocal mannerisms mentioned in the description
|
108 |
+
- Feel authentic to the character's background and situational context
|
109 |
+
- Express a complete thought with a clear beginning and end
|
110 |
+
- Sound natural when spoken aloud (avoid words that are difficult to pronounce)
|
111 |
+
- Use only standard punctuation (periods, commas, question marks, exclamation points, ellipses)
|
112 |
+
- Avoid quotation marks, parentheses, asterisks, or special formatting
|
113 |
+
- Be at least 100 characters but not exceed 300 characters in length
|
114 |
+
|
115 |
+
Respond ONLY with the dialogue itself. Do not include any explanations, quotation marks,
|
116 |
+
or additional context.
|
117 |
"""
|
118 |
|
119 |
|