AI Prompt Engineering · 강의

자연스러운 음성을 위한 TTS 프롬프트 패턴

TTS 출력을 개선하는 문장 구조, 구두점, 속도 조절 신호를 알아봅니다.

레슨 1/413개 단계

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

TTS 프롬프트 작성이 다른 이유

텍스트 음성 변환 시스템은 입력한 텍스트를 그대로 오디오로 변환합니다. 독자는 시각적인 텍스트에서 혼란스러운 부분을 다시 읽을 수 있지만, 청취자는 오디오를 선형적으로 경험하므로 모호한 문장을 해석하기 위해 잠시 멈출 수 없습니다.

TTS용 글을 쓸 때는 단어가 어떻게 들리는지 생각해야 합니다. 리듬, 문장 길이, 발음의 모호성, 굵은 글씨나 글머리 기호 같은 시각적 서식의 부재를 고려해야 합니다.

문장 길이: 짧을수록 좋습니다

절이 여러 개 포함된 길고 복잡한 문장은 오디오로 들을 때 따라가기 어렵습니다. TTS 시스템은 문법적으로는 올바르지만 음향적으로는 어색한 지점에서 리듬을 끊는 경우가 많습니다. 자연스러운 음성을 위해 문장을 10~20단어로 작성하십시오.

# Prompt a model to generate TTS-optimized text
TTS_SYSTEM_PROMPT = (
    'You are writing text that will be read aloud by a text-to-speech system.\n\n'
    'Rules:\n'
    '- Use short, clear sentences (10-20 words each).\n'
    '- Avoid complex nested clauses.\n'
    '- End each sentence with a period for clear pause signals.\n'
    '- Avoid parenthetical asides in the middle of sentences.\n'
    '- Use conversational vocabulary — write as you would speak.\n'
    '- Never use bullet points, headers, or markdown formatting.'
)

# Bad (long, nested):
BAD = (
    'The transformer architecture, which was introduced in the landmark 2017 paper '
    '"Attention is All You Need" by Vaswani et al. at Google, fundamentally changed '
    'natural language processing by replacing recurrence with self-attention.'
)

# Good (TTS-friendly):
GOOD = (
    'The transformer architecture changed natural language processing. '
    'It was introduced in 2017 by researchers at Google. '
    'Their key innovation was replacing recurrence with self-attention.'
)

오디오 신호로 사용하는 문장 부호

TTS 엔진은 문장 부호를 사용해 말하는 속도와 간격을 조절합니다.

  • 마침표 (.): 문장의 완전한 끝, 더 긴 멈춤
  • 쉼표 (,): 짧은 멈춤
  • 물음표 (?): 올라가는 억양
  • 느낌표 (!): 강조와 활기
  • 세미콜론 (;): 엔진에 따라 동작이 다르며, 무시되는 경우가 많음
  • 엠 대시 (—): 어색한 멈춤을 유발하는 경우가 많으므로 피해야 함

말하는 간격을 안정적으로 조절하려면 엠 대시나 세미콜론 대신 명시적인 마침표를 사용하십시오.

TTS_PUNCTUATION_PROMPT = (
    'Write the following content for text-to-speech narration. '
    'Use only periods, commas, and question marks for punctuation. '
    'Avoid em dashes, semicolons, colons, and parentheses. '
    'Break complex thoughts into multiple short sentences.\n\n'
    'Content to rewrite: {content}'
)

# Example transformation
original = (
    'There are three main factors to consider: cost, quality, and speed — '
    'and often, you can only optimize for two of them (this is sometimes '
    'called the project management triangle).'
)

for_tts = (
    'There are three main factors to consider. The first is cost. '
    'The second is quality. The third is speed. '
    'Usually, you can only optimize for two of these at once. '
    'This is sometimes called the project management triangle.'
)
print(for_tts)

모호한 약어 피하기

독자가 눈으로 보고 해석하는 약어는 TTS에서 잘못 발음되는 원인이 됩니다. TTS 엔진마다 약어를 처리하는 방식도 일관되지 않습니다.

  • Dr. → '의사' 또는 '운전'이라고 말할 수 있음
  • St. → '성인' 또는 '거리'?
  • vs. → '대' 또는 '브이에스'?
  • etc. → '기타' 또는 '엣시'?

정확한 발음을 보장하려면 TTS 텍스트에서 약어를 풀어 쓰십시오.

TTS_ABBREVIATION_RULES = (
    'When writing for text-to-speech:\n'
    '- Write "Doctor" not "Dr."\n'
    '- Write "Street" or "Saint" not "St."\n'
    '- Write "versus" not "vs."\n'
    '- Write "et cetera" not "etc."\n'
    '- Write "for example" not "e.g."\n'
    '- Write "that is" not "i.e."\n'
    '- Write out years: "twenty twenty-five" not "2025" when narrated in prose\n'
    '- Write out numbers under 10: "three" not "3" in conversational text\n'
    '- Spell out acronyms on first use: '
    '"Application Programming Interface, or API"\n'
)
print(TTS_ABBREVIATION_RULES)

잘못된 발음을 일으키는 단어

특정 단어나 패턴은 TTS 엔진에서 반복적으로 문제를 일으킵니다. 이러한 단어를 파악하고 대체 표현을 사용하십시오.

  • 동철이의어: 'read' (현재형과 과거형), '납' (금속과 안내의 의미), '바람/감다' — TTS는 발음 하나를 선택합니다
  • 드문 고유 명사: 기술 용어, 상표명, 외국어
  • 특수한 맥락의 숫자: 인터페이스 버전, 날짜 형식, 측정값
# Prompting LLM to detect and fix TTS pronunciation issues
TTS_REVIEW_PROMPT = (
    'Review the following text for text-to-speech pronunciation issues.\n'
    'Identify words that might be mispronounced by a TTS engine because they:\n'
    '1. Are homographs with multiple pronunciations\n'
    '2. Are technical terms, brand names, or foreign words\n'
    '3. Are abbreviations or acronyms\n'
    '4. Are numbers in unusual formats\n\n'
    'For each issue, provide the original text and a TTS-safe replacement.\n\n'
    'Text to review: {text}'
)

# Example issues and fixes
ISSUES = {
    'She read the docs': 'She read (past tense - ambiguous) -> She finished reading the docs',
    'Lead developer': 'Lead (metal or guide?) -> Lead (rhymes with feed) developer',
    'API v2.3.1': 'v2.3.1 -> version 2 point 3 point 1',
    'The .env file': 'dot E N V file (may say .env) -> the environment config file',
    'Re-init': 'may say Ray-in-it -> reinitialize',
}
for problem, fix in ISSUES.items():
    print(f'Issue: {problem}\nFix: {fix}\n')

TTS를 위한 숫자와 날짜

숫자는 TTS가 어색해지는 주요 원인입니다. 어떻게 읽어야 하는지 모호하지 않도록 숫자를 작성하십시오.

NUMBER_TTS_RULES = (
    'When writing numbers for TTS narration:\n'
    '- Dates: write "January fifteenth, 2025" not "01/15/2025"\n'
    '- Time: write "3 in the afternoon" not "15:00" in casual speech\n'
    '- Percentages: write "forty-five percent" not "45%" in narration\n'
    '- Large numbers: write "one point two million" not "1.2M"\n'
    '- Phone numbers: spell with hyphens "555-123-4567" (TTS reads each digit)\n'
    '- Currency: write "twelve dollars and fifty cents" not "$12.50" in speech\n'
    '- Fractions: write "three quarters" not "3/4"\n'
    '- Ordinals: write "first" not "1st" (TTS may say "one S T")\n'
)

# Apply when prompting the LLM to generate TTS scripts
TTS_SCRIPT_PROMPT = (
    'Write a 30-second product announcement for text-to-speech.\n'
    'Product: TaskFlow Pro, $49/month, 10,000 users worldwide, '
    'launched January 2025.\n\n'
    + NUMBER_TTS_RULES
)

시각적 서식 제거

마크다운과 HTML 서식은 눈으로 볼 때는 조용히 표시되지만, 일부 TTS 엔진에서는 소리 내어 읽힙니다. 별표, 해시 기호, 꺾쇠괄호는 제거하거나 음성 표현으로 바꿔야 합니다.

TTS_FORMAT_CONVERSION_PROMPT = (
    'Convert the following markdown text into plain prose suitable '
    'for text-to-speech narration.\n\n'
    'Rules:\n'
    '- Remove all markdown formatting (**, *, #, -, etc.)\n'
    '- Convert bullet lists into spoken sequences '
    '("First... Second... Third...")\n'
    '- Convert headers into topic introduction sentences\n'
    '- Remove any hyperlinks or URLs\n'
    '- Convert code snippets into descriptions '
    '("a Python function that...")\n\n'
    'Markdown text:\n'
    '{markdown_text}'
)

EXAMPLE_MARKDOWN = (
    '## Getting Started\n'
    '- Install the package with 'pip install mylib'\n'
    '- Set your **API key** in '.env'\n'
    '- Run 'python main.py' to start\n'
)

EXAMPLE_TTS = (
    'To get started, install the package using pip. '
    'Next, set your API key in your environment configuration file. '
    'Finally, run the main Python script to start.'
)
print(EXAMPLE_TTS)

전환 표현으로 말하는 흐름 조절하기

작성된 텍스트에서는 시각적 구조(문단, 제목)가 독자를 안내합니다. TTS 오디오에서는 청취자가 구조를 따라갈 수 있도록 말로 된 전환 표현이 필요합니다.

TRANSITION_PHRASES = {
    'starting_new_topic':    ['Let us now talk about', 'Moving on to', 'Next,'],
    'adding_information':    ['Additionally,', 'Also worth noting,', 'Furthermore,'],
    'contrasting':           ['However,', 'On the other hand,', 'That said,'],
    'concluding':            ['To summarize,', 'In short,', 'To wrap up,'],
    'sequencing':            ['First,', 'Second,', 'Then,', 'Finally,'],
    'emphasizing':           ['Importantly,', 'Keep in mind that', 'Note that'],
}

TTS_STRUCTURE_PROMPT = (
    'Write a two-minute explainer on {topic} for text-to-speech narration.\n'
    'Use verbal transition phrases to guide listeners through each point. '
    'Avoid headers or bullet points. '
    'Structure the content with clear spoken signposts '
    '("First...", "Moving on...", "To summarize...").'
)

print('Available transitions:')
for category, phrases in TRANSITION_PHRASES.items():
    print(f'  {category}: {phrases[0]}')

TTS 텍스트 테스트하기

TTS 품질을 신뢰성 있게 확인하는 유일한 방법은 직접 들어 보는 것입니다. 텍스트 생성 → TTS 인터페이스로 전송 → 듣기 → iterate의 반복 과정을 만드십시오. 텍스트를 눈으로 읽는 것에 의존하지 마십시오.

import openai
import pathlib

client = openai.OpenAI(api_key='sk-...')

def generate_and_test_tts(text, output_file='test_audio.mp3'):
    """Generate TTS audio from text for auditory review."""
    response = client.audio.speech.create(
        model='tts-1-hd',
        voice='alloy',   # alloy, echo, fable, onyx, nova, shimmer
        input=text,
        speed=1.0        # 0.25 to 4.0
    )

    audio_path = pathlib.Path(output_file)
    response.stream_to_file(audio_path)
    print(f'Audio saved to {audio_path}')
    print(f'Text length: {len(text)} chars, {len(text.split())} words')
    return audio_path

# Generate and listen before shipping
tts_text = (
    'Welcome to our weekly update. '
    'This week, the engineering team shipped three major features. '
    'First, we improved search speed by forty percent. '
    'Second, we added support for twelve new languages. '
    'Third, we launched our new mobile application.'
)
path = generate_and_test_tts(tts_text)

음성 선택과 프롬프트 일치시키기

각 TTS 음성에는 서로 다른 강점이 있습니다. 콘텐츠의 분위기에 맞춰 음성을 선택하십시오.

  • 따뜻함/서사적: 이야기 전달, 교육 콘텐츠
  • 전문적/중립적: 비즈니스 보고서, 기술 문서
  • 활기참/밝음: 마케팅, 제품 시연, 알림

음성의 자연스러운 말투에 맞는 콘텐츠를 작성하도록 LLM에 지시하십시오.

VOICE_SPECIFIC_PROMPTS = {
    'professional': (
        'Write in a clear, neutral, professional tone. '
        'Use complete sentences. Avoid contractions. '
        'Suitable for business reports and documentation.'
    ),
    'warm_narrative': (
        'Write in a warm, engaging, conversational tone. '
        'Use contractions naturally. '
        'Speak directly to the listener using "you" and "we". '
        'Suitable for educational content and storytelling.'
    ),
    'energetic': (
        'Write in an upbeat, enthusiastic tone. '
        'Use shorter sentences for impact. '
        'Include emphasis words like "amazing", "incredible", "now". '
        'Suitable for marketing and product announcements.'
    ),
}

# Select based on use case
use_case = 'warm_narrative'
print(VOICE_SPECIFIC_PROMPTS[use_case])

LLM-TTS 처리 흐름 설계

운영 환경의 처리 흐름에서는 LLM이 텍스트를 생성하고, 그 텍스트를 TTS 엔진으로 전달합니다. 두 시스템은 조정되어야 합니다. LLM은 읽기용이 아니라 TTS용 텍스트를 생성한다는 사실을 알고 있어야 하며, TTS 인터페이스에 텍스트를 보내기 전에 시스템 프롬프트나 후처리 단계에서 TTS에 적합한 규칙을 적용해야 합니다.

LLM 출력과 TTS 입력 사이에 가벼운 후처리 단계를 추가하십시오. 새어 나온 마크다운은 strip으로 제거하고, 약어를 풀어 쓰며, 문장 길이를 확인하십시오. 이렇게 하면 LLM의 서식 오류가 오디오 문제로 이어지기 전에 잡아낼 수 있습니다.

지식 확인: TTS 문장 구조

다음 중 텍스트 음성 변환 내레이션에 가장 적합하게 서식이 지정된 텍스트는 무엇입니까?

복습: 자연스러운 음성을 위한 TTS 프롬프트 패턴

TTS 텍스트는 눈이 아니라 귀를 위해 작성해야 합니다. 핵심 규칙은 다음과 같습니다. 문장을 10~20단어로 유지하고, 말하는 간격에는 마침표와 쉼표만 사용하며, 모든 약어와 숫자를 풀어 쓰고, 마크다운과 시각적 서식을 모두 제거하며, 시각적 구조를 대신할 말로 된 전환 표현을 사용하십시오. 동철이의어, 기술 용어, 특수한 숫자 형식은 잘못된 발음을 일으키므로 찾아서 바꾸십시오. 생성된 오디오를 텍스트로 읽지 말고 항상 직접 들어 보며 테스트하십시오.

무료로 시작

AI 튜터와 함께 AI Prompt Engineering을(를) 배우세요 — 무료

브라우저에서 실제 코드를 작성하고 실행하며, 24/7 AI 튜터로부터 즉각적인 도움을 받고, 웹이나 앱에서 중단한 부분부터 계속 학습하세요.

코스
53
레슨
199

자주 묻는 질문

“자연스러운 음성을 위한 TTS 프롬프트 패턴” 강의는 무료인가요?

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

“자연스러운 음성을 위한 TTS 프롬프트 패턴”에서 뭘 배우나요?

TTS 출력을 개선하는 문장 구조, 구두점, 속도 조절 신호를 알아봅니다. 브라우저에서 직접 실행하는 실습 코드로 AI Prompt Engineering을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

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

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

“자연스러운 음성을 위한 TTS 프롬프트 패턴” 강의는 얼마나 걸리나요?

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

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

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

이 강의의 모든 강의

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