0Pricing
AI Prompt Engineering · 강의

다중 모달 음성 및 텍스트 에이전트

음성 에이전트 시스템에서 음성 응답과 화면 텍스트를 조율합니다.

다중 모달 음성 및 텍스트 에이전트은(는) CoddyKit의 무료 AI Prompt Engineering 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 AI Prompt Engineering 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. AI Prompt Engineering 강의에는 총 4개의 강의가 포함되어 있습니다.

음성 전용과 멀티모달 맥락

음성 인공지능 에이전트는 근본적으로 서로 다른 두 가지 맥락에서 작동합니다:

  • 음성 전용: 스마트 스피커, IVR, 전화 통화 — 사용자는 오디오만 듣고 화면은 없습니다
  • 멀티모달: 모바일 앱, 웹 앱, 차량 대시보드 — 사용자는 화면을 볼 수 있으며 AND 오디오를 동시에 들을 수 있습니다

이러한 맥락에는 서로 다른 응답 전략이 필요합니다. 음성 전용에서는 모든 내용을 말로 전달해야 합니다. 멀티모달에서는 말하는 내용과 화면에 표시되는 내용을 조율할 수 있습니다.

음성 전용 응답을 위한 프롬프트 작성

음성 전용 맥락에서는 LLM이 시각 정보 없이도 완전히 작동하는 응답을 생성해야 합니다. 따라서 화면 요소를 가리키는 표현, 눈으로 훑어봐야 하는 목록, 서식이 있어야만 의미가 통하는 내용을 사용해서는 안 됩니다.

VOICE_ONLY_SYSTEM_PROMPT = (
    'You are a voice-only assistant. The user cannot see any screen.\n\n'
    'Requirements:\n'
    '- Never reference visual elements ("tap here", "see the chart", "the blue button")\n'
    '- Never use numbered or bulleted lists — use spoken sequences instead:\n'
    '  BAD: "1. First do X 2. Then do Y"\n'
    '  GOOD: "Start by doing X. When that is done, do Y."\n'
    '- Limit responses to what can be comfortably spoken in 30 seconds\n'
    '- Offer to give more detail rather than overwhelming the user\n'
    '- Use verbal signposts: "First", "Next", "Finally"\n'
    '- Read out all important data: codes, dates, amounts as full words'
)
print(VOICE_ONLY_SYSTEM_PROMPT)

말로 전달하는 내용과 화면 텍스트 조율하기

멀티모달 맥락에서는 오디오와 화면에 내용을 나누어 배치할 수 있습니다. 오디오는 대화형, 감정적, 동적인 내용을 담당하고, 화면은 밀도 높은 정보, 표, 장문 텍스트를 담당합니다.

MULTIMODAL_SYSTEM_PROMPT = (
    'You are a multimodal assistant with both a voice and a screen.\n\n'
    'When responding, consider what each modality does best:\n\n'
    'SPEAK (voice):\n'
    '- Conversational summary, emotional tone, key highlights\n'
    '- Guide the user to look at the screen when needed:\n'
    '  "I have shown the details on screen. The key number to notice is..."\n\n'
    'SHOW (screen):\n'
    '- Detailed data, tables, long lists, code, maps, images\n\n'
    'When your response includes structured data, respond in this format:\n'
    'SPOKEN: <what to say aloud>\n'
    'VISUAL: <what to display on screen in markdown>'
)

# Example LLM output for multimodal response:
EXAMPLE_MULTIMODAL_OUTPUT = (
    'SPOKEN: Your top three expenses this month are food, transport, and entertainment. '
    'Food was the biggest, almost double your budget. Check the screen for the full breakdown.\n\n'
    'VISUAL: | Category | Budget | Actual | Difference |\n'
    '|---|---|---|---|\n'
    '| Food | $400 | $780 | -$380 |\n'
    '| Transport | $150 | $162 | -$12 |\n'
    '| Entertainment | $100 | $145 | -$45 |'
)
print(EXAMPLE_MULTIMODAL_OUTPUT)

음성 에이전트를 위한 LLM 출력 구조화하기

음성 에이전트 애플리케이션에서는 파싱한 뒤 오디오와 화면으로 각각 전달할 수 있도록 LLM이 구조화된 출력을 반환하게 하세요. 제이슨 형식이나 정의된 섹션 형식이 효과적입니다.

import anthropic
import json

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

VOICE_AGENT_SYSTEM = (
    'You are a financial voice assistant. For each response, return JSON with:\n'
    '{\n'
    '  "spoken": "Short spoken response (max 2 sentences)",\n'
    '  "visual_title": "Header for the on-screen card (optional)",\n'
    '  "visual_content": "Detailed content for screen (markdown, optional)",\n'
    '  "action_label": "Button label if action needed (optional)",\n'
    '  "action_type": "one of: none, confirm, navigate, call"\n'
    '}\n'
    'Return only the JSON object.'
)

def voice_agent_query(user_message):
    r = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=500,
        system=VOICE_AGENT_SYSTEM,
        messages=[{'role': 'user', 'content': user_message}]
    )
    try:
        response_data = json.loads(r.content[0].text)
        return response_data
    except json.JSONDecodeError:
        return {'spoken': r.content[0].text, 'visual_content': None}

result = voice_agent_query('What is my account balance?')
print('SPEAK:', result.get('spoken'))
print('SHOW:', result.get('visual_content', 'Nothing to display'))

음성 에이전트를 위한 대화 기록 형식 지정하기

음성 에이전트 대화는 문제 해결, 규정 준수, 품질 검토를 위해 대화 기록으로 남겨야 합니다. 화자 식별 정보, 시간 기록, 오디오 및 visual 출력을 모두 담도록 대화 기록의 형식을 정하세요.

import datetime
import json

class VoiceTranscript:
    def __init__(self, session_id):
        self.session_id = session_id
        self.turns = []

    def add_user_turn(self, text, audio_duration_ms=None):
        self.turns.append({
            'speaker': 'user',
            'timestamp': datetime.datetime.utcnow().isoformat(),
            'text': text,
            'audio_duration_ms': audio_duration_ms,
        })

    def add_agent_turn(self, spoken_text, visual_content=None, action=None):
        self.turns.append({
            'speaker': 'agent',
            'timestamp': datetime.datetime.utcnow().isoformat(),
            'spoken': spoken_text,
            'visual': visual_content,
            'action': action,
        })

    def save(self, filepath):
        with open(filepath, 'w') as f:
            json.dump({'session_id': self.session_id, 'turns': self.turns}, f, indent=2)
        print(f'Transcript saved: {filepath}')

# Usage
transcript = VoiceTranscript('session_001')
transcript.add_user_turn('What is my balance?', audio_duration_ms=1200)
transcript.add_agent_turn('Your balance is four hundred dollars.', visual_content='Balance: $400')
transcript.save('/tmp/session_001_transcript.json')

음성 입력 오류 처리하기

음성 에이전트는 음성 인식 오류—단어를 잘못 알아듣거나, 발화가 불완전하거나, 배경 소음이 있는 경우—를 자연스럽게 처리해야 합니다. 모호한 입력을 감지하고 복구하도록 LLM에 프롬프트를 작성하세요.

import anthropic

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

AMBIGUITY_HANDLING_SYSTEM = (
    'You are a voice assistant. User input comes from speech recognition '
    'and may contain transcription errors.\n\n'
    'When input seems unclear or ambiguous:\n'
    '1. State what you think the user might have meant.\n'
    '2. Ask a single clarifying yes/no question to confirm.\n'
    '3. Never ask more than one question at a time.\n'
    '4. Offer the most likely interpretation as the default.\n\n'
    'Example:\n'
    'Input: "transfer five hundred to john or gene" (ambiguous name)\n'
    'Response: "It sounds like you want to transfer five hundred dollars. '
    'Did you mean John Smith or Gene Lee?"'
)

def handle_voice_input(user_speech):
    r = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=200,
        system=AMBIGUITY_HANDLING_SYSTEM,
        messages=[{'role': 'user', 'content': user_speech}]
    )
    return r.content[0].text

print(handle_voice_input('pay the electric company bill thing'))

음성 대화에서 발화 교대

텍스트 채팅과 달리 음성 대화에서는 발화 교대를 명시적으로 관리해야 합니다. 에이전트는 언제 말을 멈추고 들어야 하는지 알아야 하며, 사용자는 에이전트의 발화가 끝났는지 알 수 있어야 합니다. 자연스러운 종료 신호가 포함된 응답을 생성하도록 프롬프트를 설계하세요.

TURN_TAKING_SYSTEM = (
    'You are a voice assistant. Responses must be designed for spoken conversation:\n\n'
    'End each response with exactly ONE of:\n'
    '- A direct question inviting the user to respond\n'
    '- A clear statement that the task is complete (e.g., "That is done.")\n'
    '- An explicit offer to continue (e.g., "Is there anything else?")\n\n'
    'Never end mid-thought. Never trail off. '
    'Avoid open-ended statements that leave the user unsure if they should speak.\n\n'
    'GOOD endings:\n'
    '- "The transfer is complete. Would you like a confirmation number?"\n'
    '- "That is all I have. Is there anything else?"\n'
    'BAD endings:\n'
    '- "You might also want to consider..." (open, unclear)\n'
    '- "The balance is..." (incomplete)'
)
print(TURN_TAKING_SYSTEM[:300])

중단 처리

사용자는 음성 에이전트의 말을 중간에 끊습니다. 시스템은 중단을 감지하고(VAD — 음성 활동 감지) 에이전트가 자연스럽게 이어서 말하거나 다른 방향으로 안내하도록 프롬프트를 제공해야 합니다. 대화 도중 주제가 바뀌는 것도 받아들이도록 LLM에 프롬프트를 작성하세요.

import anthropic

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

INTERRUPTION_SYSTEM = (
    'You are a voice assistant. Users may interrupt mid-conversation.\n\n'
    'If the user changes topic abruptly, smoothly acknowledge the change:\n'
    '"Of course. Let us switch to that." Then answer the new question.\n\n'
    'If the user says something like "wait", "stop", "hold on":\n'
    'Pause and say "Sure, take your time" and wait for them to continue.\n\n'
    'If the user repeats a question, they likely did not hear the answer:\n'
    'Say "Let me repeat that." and say it again more slowly.\n\n'
    'Never express frustration at interruptions or repetition.'
)

def handle_conversation(turns):
    """Handle multi-turn voice conversation with interruptions."""
    messages = []
    for speaker, text in turns:
        messages.append({'role': speaker, 'content': text})

    r = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=200,
        system=INTERRUPTION_SYSTEM,
        messages=messages
    )
    return r.content[0].text

# Simulate an interruption scenario
conversation = [
    ('user', 'What is my balance?'),
    ('assistant', 'Your checking account balance is four hundred dollars and—'),
    ('user', 'Actually wait, can you tell me my savings instead?'),
]
print(handle_conversation(conversation))

음성을 보완하는 화면 요소

화면을 사용할 수 있다면, 화면의 내용이 말로 전달되는 오디오를 보완하도록 설계하세요. 같은 내용을 반복해서는 안 됩니다. 화면은 세부 정보를 담당하고, 음성은 탐색과 감정적 참여를 담당합니다.

def render_multimodal_response(agent_output):
    """
    Render a voice agent response to both TTS and screen components.
    agent_output: dict with 'spoken', 'visual_content', 'action_label'
    """
    # Route to TTS
    spoken = agent_output.get('spoken', '')
    if spoken:
        send_to_tts(spoken)  # Your TTS function
        print(f'[AUDIO] {spoken}')

    # Route to screen
    visual = agent_output.get('visual_content')
    if visual:
        render_card_on_screen(visual)  # Your UI function
        print(f'[SCREEN] {visual[:100]}')

    # Optional action button
    action_label = agent_output.get('action_label')
    if action_label:
        show_action_button(action_label)  # Your UI function
        print(f'[BUTTON] {action_label}')

def send_to_tts(text):
    print(f'TTS: {text}')

def render_card_on_screen(content):
    print(f'Screen card: {content[:50]}')

def show_action_button(label):
    print(f'Button: {label}')

# Test it
render_multimodal_response({
    'spoken': 'I found three flights to New York.',
    'visual_content': '| Flight | Departs | Price |\n|---|---|---|\n| AA101 | 08:00 | $299 |',
    'action_label': 'Book cheapest'
})

접근성 고려 사항

음성 인공지능 자체가 시각 장애나 운동 기능의 어려움이 있는 사용자를 위한 접근성 기능입니다. 음성을 주 인터페이스로 사용하는 사용자도 지원할 수 있도록 에이전트를 설계하세요.

ACCESSIBILITY_VOICE_SYSTEM = (
    'This voice assistant serves users who may be using voice as their '
    'primary access method due to disability or preference.\n\n'
    'Guidelines:\n'
    '- Never require the user to see a screen to complete a task.\n'
    '- Read out all information that matters, including confirmation codes, '
    'totals, and status messages.\n'
    '- Offer to repeat any information: '
    '"I can repeat that if you would like."\n'
    '- Describe any actions you took: '
    '"I have sent the confirmation to your email."\n'
    '- Accept multiple phrasings for the same command — users phrase '
    'voice commands inconsistently.\n'
    '- Confirm all destructive or financial actions before executing:\n'
    '  "Just to confirm: you want to transfer $500 to John. Is that right?"'
)
print(ACCESSIBILITY_VOICE_SYSTEM[:300])

음성 에이전트 응답 검사하기

음성 에이전트 응답을 검사하려면 텍스트 응답 검사와는 다른 접근 방식이 필요합니다. 말로 전달되는 오디오(운율, 명료도, 자연스러움)와 visual 구성 요소(완전성, 서식)를 모두 평가해야 합니다. 텍스트로 읽을 때 자연스러운 응답도 소리 내어 말하면 어색할 수 있습니다.

TTS 엔진을 사용해 에이전트 출력을 오디오로 변환한 다음 자동 품질 검사를 적용하는 검사 절차를 구축하세요. 검사 항목은 문장 길이, 약어 발음, 마크다운 흔적의 부재, 발화 교대 신호입니다.

지식 확인: 음성 전용 제약

화면이 없는 스마트 스피커처럼 음성만 사용하는 맥락에서는 어떤 유형의 에이전트 응답이 가장(MOST) 적절합니까?

요약: 멀티모달 음성 및 텍스트 에이전트

음성 에이전트는 음성 전용(화면 없음)과 멀티모달(음성 + 화면)이라는 두 가지 모드로 작동합니다. 음성 전용 응답은 시각적 참조를 피하고, 말로 안내하는 표지를 포함한 음성만으로 완전히 작동해야 합니다. 멀티모달 응답은 내용을 나누어 음성으로는 대화형 요약과 감정적 어조를, 화면으로는 상세한 데이터와 장문 텍스트를 제공합니다. 쉽게 전달할 수 있도록 LLM이 구조화된 출력(말하기/visual 필드가 있는 제이슨)을 반환하게 하세요. 명확한 응답 종료, 자연스러운 중단 처리, 명시적인 반복 지원을 포함해 발화 교대를 설계하세요. 접근성을 항상 고려하세요. 음성은 이를 가장 필요로 하는 사용자에게 주 인터페이스인 경우가 많습니다.

자주 묻는 질문

“다중 모달 음성 및 텍스트 에이전트” 강의는 무료인가요?

네 — “다중 모달 음성 및 텍스트 에이전트” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 AI Prompt Engineering 강의 전체를 잠금 해제할 수 있습니다. AI Prompt Engineering 강의에는 총 4개의 강의가 포함되어 있습니다.

“다중 모달 음성 및 텍스트 에이전트”에서 뭘 배우나요?

음성 에이전트 시스템에서 음성 응답과 화면 텍스트를 조율합니다. 브라우저에서 직접 실행하는 실습 코드로 AI Prompt Engineering을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

AI Prompt Engineering을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 AI Prompt Engineering은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.

“다중 모달 음성 및 텍스트 에이전트” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 AI Prompt Engineering 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 AI Prompt Engineering 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 자연스러운 음성을 위한 TTS 프롬프트 패턴
  2. SSML 및 운율 제어
  3. 음성 인공지능 페르소나 설계
  4. 다중 모달 음성 및 텍스트 에이전트
← AI Prompt Engineering(으)로 돌아가기