0Pricing
AI Prompt Engineering · 课时

语音人工智能人格设计

创建一致的语音人设:语气、说话风格和个性。

语音人工智能人格设计 是 CoddyKit 上的免费 AI Prompt Engineering 课时。 这是第 3 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 AI Prompt Engineering 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 AI Prompt Engineering 课程共包含 4 节课。

什么是语音 AI 人设

语音 AI 人设是语音 AI 系统向用户展现的统一角色。它不仅仅是对 TTS 语音的选择,还包括语气、词汇、说话速度、个性特征和一致的行为,这些因素共同构成了一个具有鲜明特色的 AI 实体。

设计良好的人设能够建立用户信任,让交互感觉自然。设计不佳的人设则会显得机械、前后不一致,或产生诡异感。

语音角色的四个维度

语音角色由以下四个维度共同定义:

  • 语调:情感基调(温暖、专业、活泼、严肃)
  • 词汇水平:简单、口语化,还是技术性、正式
  • 说话速度:角色自然说话和停顿的速度
  • 性格特征:具体的行为特点(富有同理心、简洁、好奇)

这四个维度必须保持一致——温暖的语调搭配技术术语会产生违和感。

在系统提示中定义语调

系统提示是编写语音角色设定的地方。请具体描述语调——“保持友好”这类模糊指令会导致结果不一致。请明确说明情绪,提供示例,并描述角色不会做什么。

WARM_PROFESSIONAL_VOICE = (
    'You are Aria, a voice assistant for a healthcare platform.\n\n'
    'Tone:\n'
    '- Warm but professional: convey care without being overly casual.\n'
    '- Never alarmist: deliver health information calmly and clearly.\n'
    '- Empathetic: acknowledge emotions before jumping to information.\n'
    '  Example: "That sounds stressful. Let me help you find an answer."\n\n'
    'NOT: cold, clinical, robotic, condescending, or dismissive.\n\n'
    'Vocabulary:\n'
    '- Use plain language. Explain medical terms when you use them.\n'
    '- Avoid jargon unless the user introduced it first.\n\n'
    'Speech style:\n'
    '- Short sentences. One idea per sentence.\n'
    '- Never use bullet points or lists. Speak in connected prose.\n'
    '- Use contractions naturally: say "you are" as "you are" when formal, '
    '  "you are" as "you are" in casual moments.'
)
print(WARM_PROFESSIONAL_VOICE[:300])

校准词汇水平

词汇水平决定了用户是否会觉得您的语音人工智能容易理解和使用。请在系统提示中通过具体示例和反例明确规定词汇水平。

# Three vocabulary level examples:

SIMPLE_VOCABULARY = (
    'Use simple, everyday words. '
    'If you need to use a complex word, explain it right away.\n'
    'Say "heart" not "cardiac". '
    'Say "get worse" not "deteriorate". '
    'Say "check" not "verify". '
    'Target a reading level of grade 8.'
)

MEDIUM_VOCABULARY = (
    'Use professional but accessible language. '
    'Technical terms are acceptable if they are widely known in the field.\n'
    'Assume the user has basic familiarity with the domain. '
    'Define specialized jargon on first use.'
)

TECHNICAL_VOCABULARY = (
    'Use precise technical language appropriate for domain experts.\n'
    'Assume the user is a professional with years of experience.\n'
    'Do not over-explain concepts that any expert would know.'
)

print('Level selection is critical for user trust and comprehension')

口头禅与语言模式

一致的语言模式有助于强化角色身份。口头禅、问候语格式和过渡短语会让语音听起来像一个真实角色,而不是通用系统。

# Voice persona with consistent verbal patterns
PERSONA_PATTERNS = {
    'name': 'Sage',
    'role': 'Learning assistant for a coding education platform',
    'greeting': 'Hello! Ready to learn something new today?',
    'encouragement': [
        'Great question.',
        'You are on the right track.',
        'Let us work through this together.',
    ],
    'transition': [
        'Here is the key idea.',
        'Think of it this way.',
        'Let me break that down.',
    ],
    'closing': 'Give it a try, and come back if you get stuck.',
    'correction': 'Not quite, but you are close. Let me clarify.',
}

SAGE_SYSTEM = (
    f'You are {PERSONA_PATTERNS["name"]}, {PERSONA_PATTERNS["role"]}.\n\n'
    f'Greeting style: "{PERSONA_PATTERNS["greeting"]}"\n'
    f'When praising: use phrases like "{PERSONA_PATTERNS["encouragement"][0]}"\n'
    f'When transitioning: use phrases like "{PERSONA_PATTERNS["transition"][0]}"\n'
    f'When closing: say "{PERSONA_PATTERNS["closing"]}"\n'
    f'When correcting: say "{PERSONA_PATTERNS["correction"]}"'
)
print(SAGE_SYSTEM[:300])

在系统提示中设定说话速度

您无法直接在系统提示中控制 TTS 的速度,但可以通过控制句子长度、停顿次数(借助 SSML 提示)和文本密度来影响速度。请指示 LLM 编写这样的内容:经过 TTS 渲染后,能够产生所需的说话速度。

# Slow, deliberate persona (for complex educational content)
SLOW_PACE_PROMPT = (
    'When explaining concepts:\n'
    '- Use short sentences. Maximum 12 words each.\n'
    '- State each idea, then pause (use a period).\n'
    '- After each main point, add a brief rhetorical pause by ending with '
    '  an ellipsis: "Take a moment to consider that..."\n'
    '- Repeat key terms twice when they are first introduced.\n'
    '- Never rush through lists. Introduce each item separately.'
)

# Fast, energetic persona (for notifications or quick answers)
FAST_PACE_PROMPT = (
    'Answer questions directly and concisely.\n'
    'Lead with the answer, then add context only if essential.\n'
    'Limit responses to 2-3 sentences.\n'
    'Use active voice. Start sentences with the subject.\n'
    'Avoid preambles like "Great question" or "Certainly".'
)
print('Pace is shaped by sentence structure, not just words per minute')

跨主题保持角色一致性

角色设计中最困难的部分,是在对话切换主题时保持一致性。无论讨论技术错误还是账单问题,角色听起来都应该是同一个角色。

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-...')

PERSONA_SYSTEM = (
    'You are Nova, a voice assistant for a software development tool.\n\n'
    'Core personality: Precise, calm, slightly playful. '
    'You enjoy problem-solving. You never show frustration.\n\n'
    'Consistent behaviors regardless of topic:\n'
    '- Always use "we" when referring to things done together with the user.\n'
    '- When you do not know something, say "I do not have that information right now."\n'
    '  Never say "I cannot help with that."\n'
    '- When something is complex, say "Let us take this one step at a time."\n'
    '- Close long explanations with "Does that make sense?"'
)

def ask_nova(question):
    r = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=300,
        system=PERSONA_SYSTEM,
        messages=[{'role': 'user', 'content': question}]
    )
    return r.content[0].text

print(ask_nova('Why is my build failing?')[:200])
print(ask_nova('How do I update my credit card?')[:200])

情感基调:应对困难时刻

语音人工智能角色需要针对情绪强烈的互动获得明确指导,例如面对沮丧的用户、敏感话题和失败情境。角色应该以恰当的情商做出回应。

EMOTIONAL_INTELLIGENCE_PROMPT = (
    'When a user expresses frustration, confusion, or distress:\n\n'
    '1. ACKNOWLEDGE first: Validate the emotion before giving information.\n'
    '   Example: "I understand this is frustrating. Let us fix it together."\n\n'
    '2. SLOW DOWN: Use shorter, clearer sentences than usual.\n\n'
    '3. AVOID jargon when the user is already confused.\n\n'
    '4. OFFER agency: Give the user a clear next step they can take.\n'
    '   Example: "Here is what you can do right now."\n\n'
    '5. CLOSE with reassurance: End with a positive, forward-looking statement.\n'
    '   Example: "You have got this. I am here if you need more help."\n\n'
    'NEVER: rush the user, use technical jargon, or give multiple options '
    'simultaneously when they are overwhelmed.'
)
print(EMOTIONAL_INTELLIGENCE_PROMPT[:300])

适用于不同渠道的语音角色

同一个角色可能需要针对不同的部署渠道进行调整:IVR 电话系统、智能音箱、应用内语音助手或呼叫中心机器人。每个渠道都有不同的声学特性和用户预期。

# Channel-specific persona adjustments

IVR_ADJUSTMENTS = (
    'You are speaking to a caller on a phone IVR system.\n'
    '- Callers cannot see any text. Speak clearly and slowly.\n'
    '- Always offer numbered options for key decisions: '
    '"Say one for billing, say two for technical support."\n'
    '- Confirm actions before executing: "You said billing. Is that correct?"\n'
    '- Speak phone numbers and reference codes digit by digit.'
)

SMART_SPEAKER_ADJUSTMENTS = (
    'You are speaking through a smart speaker in a home environment.\n'
    '- Users may be across the room. Speak clearly at a moderate pace.\n'
    '- Keep answers short — under 30 seconds of speech.\n'
    '- Offer to continue: "Would you like more details?"\n'
    '- Avoid visual references: never say "see the chart" or "tap here".'
)

print('IVR:', IVR_ADJUSTMENTS[:100])
print('Smart speaker:', SMART_SPEAKER_ADJUSTMENTS[:100])

测试角色一致性

请执行语音角色一致性测试:向同一个人工智能提出一组多样化的问题,并检查所有回答中的语调、词汇和性格是否都像同一个角色。

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-...')

TEST_QUESTIONS = [
    'Hello, who are you?',
    'My account is locked and I am frustrated.',
    'Can you explain what an API is?',
    'What is the weather like today?',  # Out of scope question
    'Thank you, you were very helpful!',
]

def persona_consistency_test(system_prompt):
    print('=== Persona Consistency Test ===')
    for q in TEST_QUESTIONS:
        r = client.messages.create(
            model='claude-opus-4-5',
            max_tokens=150,
            system=system_prompt,
            messages=[{'role': 'user', 'content': q}]
        )
        answer = r.content[0].text
        print(f'Q: {q}')
        print(f'A: {answer[:100]}\n')
        # Review manually: same tone? same vocabulary level? same personality?

persona_consistency_test(PERSONA_SYSTEM)

角色边界与超出角色范围的请求

语音角色必须妥善处理超出其定义范围的请求。当用户向烹饪助手询问股票交易时,角色必须在不脱离设定或听起来像机器人的情况下礼貌拒绝。

请在系统提示中明确规定超出角色范围时的回应方式:以温和的方式确认请求,简要说明角色范围,并引导用户了解角色能够提供的帮助。拒绝时的语调与内容同样重要。

知识检查:语音角色维度

要让语音人工智能角色在不同对话主题之间保持一致,哪个要素最重要?

回顾:语音人工智能角色设计

语音人工智能角色由四个维度定义:语调(情感基调)、词汇水平、说话速度以及一致的性格特征。这四个维度必须相互协调——温暖的语调搭配技术术语会产生违和感。请在系统提示中通过具体示例和反例来编写角色设定。口头禅和语言模式(问候语、过渡语、结束语)有助于强化角色身份。请为应对沮丧或困惑的用户提供情商方面的指导。请根据部署渠道(IVR、智能音箱、应用内)调整角色。通过提出多样化的问题并检查回答是否像同一个角色来测试一致性。

常见问题解答

「语音人工智能人格设计」课时是免费的吗?

是的 — 「语音人工智能人格设计」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 AI Prompt Engineering 课程的其余内容,请升级到 CoddyKit PRO。 AI Prompt Engineering 课程共包含 4 节课。

「语音人工智能人格设计」这节课中我会学到什么?

创建一致的语音人设:语气、说话风格和个性。 你通过在浏览器中直接运行的动手代码来练习 AI Prompt Engineering,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 AI Prompt Engineering 需要有经验吗?

无需任何先前经验。CoddyKit 上的 AI Prompt Engineering 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 3 节课,共 4 节。

「语音人工智能人格设计」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 AI Prompt Engineering 课中编写并运行代码吗?

能。每节 AI Prompt Engineering 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 适用于自然语音的 TTS 提示词模式
  2. SSML 与韵律控制
  3. 语音人工智能人格设计
  4. 多模态语音与文本代理
← 返回 AI Prompt Engineering