# Basic TTS promptbasic_prompt = "Hello, welcome to our application!"# Enhanced TTS prompt with voice characteristicsenhanced_prompt = """Speak in a friendly, professional tone:"Hello, welcome to our application! We're excited to have you here.""""
# Character-based promptscharacter_prompts = { "narrator": """ As a professional narrator, speak clearly and engagingly: "In today's world, technology continues to evolve at an unprecedented pace." """, "teacher": """ As an enthusiastic teacher, explain with patience and clarity: "Let me explain how this process works step by step." """, "announcer": """ As a confident announcer, deliver with authority: "Ladies and gentlemen, welcome to tonight's special event!" """, "friend": """ As a close friend, speak warmly and casually: "Hey there! I wanted to share something exciting with you." """}
def create_emotional_prompts(): """Create prompts with specific emotional tones""" emotional_prompts = { "excited": """ Speak with excitement and enthusiasm: "I have amazing news to share with you today!" """, "calm": """ Speak in a calm, soothing manner: "Take a deep breath and relax. Everything will be okay." """, "serious": """ Speak with gravity and importance: "This is a critical matter that requires your immediate attention." """, "playful": """ Speak with a playful, light-hearted tone: "Guess what? I have a fun surprise for you!" """, "sympathetic": """ Speak with empathy and understanding: "I understand how difficult this must be for you." """ } return emotional_prompts# Usage exampleemotional_prompts = create_emotional_prompts()
def create_context_aware_prompts(): """Create prompts that consider context and audience""" context_prompts = { "business_meeting": """ For a professional business meeting, speak with authority and clarity: "Let's review the quarterly results and discuss our next steps." """, "educational_content": """ For educational content, speak clearly and at an appropriate pace: "Today we'll learn about the fundamentals of machine learning." """, "customer_service": """ For customer service, speak with patience and helpfulness: "I'm here to help you resolve this issue. Let me walk you through the solution." """, "entertainment": """ For entertainment content, speak with energy and charisma: "Welcome to the most exciting show you'll see today!" """ } return context_prompts
def create_technical_prompts(): """Create prompts with technical specifications""" technical_prompts = { "slow_clear": """ Speak slowly and clearly for accessibility: "Please listen carefully to these important instructions." """, "fast_energetic": """ Speak quickly with high energy: "Get ready for an action-packed adventure!" """, "whispered": """ Speak in a whispered, intimate tone: "This is our little secret, just between you and me." """, "loud_announcement": """ Speak loudly and clearly for an announcement: "ATTENTION: Please proceed to the nearest exit immediately." """ } return technical_prompts
def create_voice_cloning_prompts(): """Create prompts for voice cloning scenarios""" cloning_prompts = { "personal_assistant": """ Clone this voice for a personal assistant: "Good morning! I'm your AI assistant, ready to help you with your tasks today." """, "audiobook_narrator": """ Clone this voice for audiobook narration: "Chapter one: The beginning of our journey into the unknown." """, "podcast_host": """ Clone this voice for podcast hosting: "Welcome back to our weekly podcast. Today we're discussing fascinating topics." """, "character_voice": """ Clone this voice for a specific character: "Greetings, traveler! I am the wise wizard of these lands." """ } return cloning_prompts
def create_voice_design_prompts(): """Create prompts for custom voice design""" design_prompts = { "young_professional": """ Design a voice for a young professional: - Age: 25-30 - Gender: Female - Accent: American - Tone: Confident and approachable "Hello, I'm Sarah, your project manager. Let's discuss your requirements." """, "experienced_mentor": """ Design a voice for an experienced mentor: - Age: 50-60 - Gender: Male - Accent: British - Tone: Wise and encouraging "My dear student, let me share with you the wisdom of experience." """, "friendly_guide": """ Design a voice for a friendly tour guide: - Age: 30-40 - Gender: Neutral - Accent: Australian - Tone: Enthusiastic and informative "Welcome to our beautiful city! Let me show you the most amazing sights." """ } return design_prompts
def create_accessibility_prompts(): """Create prompts for accessibility-focused content""" accessibility_prompts = { "screen_reader": """ Optimize for screen reader users: "Navigation menu. Home, About, Services, Contact. Press Enter to select." """, "learning_disability": """ Speak clearly for users with learning disabilities: "Let's break this down into simple steps. First, click the blue button." """, "elderly_users": """ Speak slowly and clearly for elderly users: "Please take your time. There's no rush. Let me explain this carefully." """, "hearing_impaired": """ Speak with clear pronunciation: "I will speak slowly and clearly. Please let me know if you need repetition." """ } return accessibility_prompts
def test_prompt_variations(): """Test different prompt variations""" base_content = "Welcome to our new feature" variations = [ # Variation 1: Basic "Welcome to our new feature", # Variation 2: With tone "Exciting news! Welcome to our new feature", # Variation 3: With context "As your AI assistant, I'm excited to introduce you to our new feature", # Variation 4: With emotion "I'm thrilled to share our amazing new feature with you!", # Variation 5: With instruction "Listen carefully as I introduce you to our revolutionary new feature" ] return variations# Test different variationsvariations = test_prompt_variations()for i, variation in enumerate(variations, 1): print(f"Variation {i}: {variation}")
Be specific about tone and emotion - Include context when relevant - Test
different variations - Consider your audience - Use natural language
❌ Don'ts
Don’t use overly complex sentences - Don’t ignore cultural context - Don’t
assume tone without specifying - Don’t use technical jargon unnecessarily -
Don’t forget to test your prompts
def generate_dynamic_prompts(context, audience, emotion): """Generate prompts dynamically based on context""" templates = { "greeting": { "formal": "Good {time_of_day}, {audience}. I hope you're doing well.", "casual": "Hey {audience}! How's it going?", "friendly": "Hello there, {audience}! Great to see you!" }, "instruction": { "patient": "Let me guide you through this step by step, {audience}.", "confident": "I'll show you exactly how to do this, {audience}.", "encouraging": "You've got this, {audience}! Let's do it together." } } # Select appropriate template based on context template = templates[context][emotion] # Fill in dynamic values prompt = template.format( audience=audience, time_of_day="morning" # Could be dynamic ) return prompt# Example usagegreeting_prompt = generate_dynamic_prompts("greeting", "everyone", "friendly")print(greeting_prompt)
class SpeechPromptTemplate: def __init__(self): self.templates = { "announcement": """ As a {role}, announce with {tone}: "{content}" """, "explanation": """ As a {role}, explain with {tone}: "{content}" """, "conversation": """ As a {role}, speak {tone}: "{content}" """ } def generate_prompt(self, template_type, role, tone, content): """Generate prompt using template""" template = self.templates[template_type] return template.format( role=role, tone=tone, content=content )# Usage exampletemplate = SpeechPromptTemplate()announcement = template.generate_prompt( "announcement", "professional announcer", "authority and clarity", "The event will begin in 5 minutes")print(announcement)
Effective prompt engineering for speech models requires understanding both the
technical capabilities and the human aspects of communication. Always test
your prompts with real users when possible.
Be mindful of cultural sensitivity and appropriateness when crafting prompts.
What sounds natural in one culture may not work in another.