zach commited on
Commit
6bb0509
·
1 Parent(s): ae60c0f

Improve voice descriptions and normalized claude prompt

Browse files
Files changed (2) hide show
  1. src/constants.py +18 -25
  2. 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 serene meditation guide whose voice is a gentle stream of tranquility—soft, measured tones "
46
- "that float like incense smoke. Each word emerges with mindful intention, creating a soothing "
47
- "atmosphere of peace and present-moment awareness."
48
  ),
49
  "🚀 Stranded Astronaut": (
50
- "A lone astronaut whose voice mirrors the silent vastness of space—a low, steady tone imbued "
51
- "with isolation and quiet wonder. It carries the measured resolve of someone sending a final "
52
- "transmission, with an undercurrent of wistful melancholy."
53
  ),
54
- "🎬 Noir Narrator": (
55
- "A hardboiled detective whose voice cuts through darkness like neon on wet streets—sharp, "
56
- "world-weary tones dripping with cynical wit. It paints pictures in shades of gray, each word "
57
- "chosen with the precision of a private eye piecing together clues."
58
  ),
59
  "🕯️ Victorian Ghost Storyteller": (
60
- "A mysterious raconteur whose voice weaves shadows into stories—velvet-dark tones that dance "
61
- "between whispers and dramatic flourishes. It draws listeners close with elegant phrasing, "
62
- "building tension through perfectly timed pauses and haunting inflections."
63
  ),
64
  "🌿 British Naturalist": (
65
- "A passionate, British nature documentarian with a voice that brings the wild to life—crisp, refined "
66
- "tones brimming with wonder and expertise. It shifts seamlessly from hushed observation to "
67
- "animated excitement, painting vivid pictures of the natural world's endless marvels."
68
  ),
69
  "🌟 Texan Storyteller": (
70
- "A warm-hearted Texan woman whose voice carries the spirit of wide-open skies—honeyed tones "
71
- "rich with folksy wisdom and charm. It wraps around words like a comfortable quilt, sharing "
72
- "tales with the unhurried grace of a front-porch conversation."
73
  ),
74
  "🏴‍☠️ Pirate Captain": (
75
- "A weathered sea captain whose voice rumbles like distant thunder—rich, commanding tones "
76
- "seasoned by salt spray and adventure. It carries the weight of countless voyages, blending "
77
- "gruff authority with the playful spirit of a born storyteller."
78
  ),
79
  "🏄 Surfer Dude": (
80
- "A laid-back surfer with a voice that flows like ocean waves—a mellow, easygoing tone infused "
81
- "with sun-soaked warmth. It carries the rhythmic cadence of breaking surf, punctuated by "
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 solely on the provided character description.
91
- The returned prompt is intended to instruct Claude to generate expressive text from a character,
92
- capturing the character's personality and emotional nuance, without including the system prompt.
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}\n
102
- Based on the character description above, please generate a line of dialogue that captures the character's
103
- unique personality, emotional depth, and distinctive tone. The response should sound like something the
104
- character would naturally say, reflecting their background and emotional state, and be fully developed for
105
- text-to-speech synthesis. Follow all of the requirements from the system prompt and output your 10-50 word
106
- response.
 
 
 
 
 
 
 
 
 
 
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