탐색으로 건너뛰기

발음 사전 사용하기

이 가이드에서는 프로그래밍 방식으로 발음 사전을 관리하는 방법을 알아봅니다.

사용 가이드 · ElevenAPI 빠른 시작을 완료했다고 가정합니다.

개요

발음 사전을 사용하면 AI 에이전트가 특정 단어나 구를 발음하는 방식을 맞춤 설정할 수 있습니다. 특히 다음과 같은 경우에 유용합니다.

  • 이름, 장소 또는 기술 용어의 발음 교정
  • 대화 전반에서 일관된 발음 유지
  • 지역별 발음 차이 맞춤 설정

ElevenLabs는 IPA와 CMU 알파벳을 모두 지원합니다.

발음 사전의 음소 태그는 eleven_v4, eleven_v4_turbo, eleven_flash_v2 및 eleven_v3 모델에서만 작동합니다.

다른 모델은 사전 음소 태그를 건너뛰고 기본 발음을 사용합니다. 다른 모델에서는 원하는 발음이 나오는 철자나 구로 대체할 수 있도록 별칭 태그를 대신 사용하세요.

영어 이외의 언어에서 IPA 및 CMU 발음을 사용하려면 eleven_v4 또는 eleven_v4_turbo 모델로 전환해야 합니다.

빠른 시작

이 가이드에서는 API 키와 SDK를 설정했다고 가정합니다. 아직 완료하지 않았다면 먼저 빠른 시작을 완료하세요.

1

발음 사전 파일 만들기

이 예시에서는 tomato라는 단어의 발음 사전 파일을 만듭니다.

이 규칙은 “IPA” 알파벳을 사용하며 tomato와 Tomato의 발음을 다른 발음으로 업데이트합니다. PLS 파일은 대소문자를 구분하므로 대문자 “T”가 있는 경우와 없는 경우를 모두 포함합니다.

Claude 또는 ChatGPT 같은 AI 도구를 사용하면 특정 단어의 IPA 또는 CMU 표기 생성을 도움받을 수 있습니다.

dictionary.pls
<?xml version="1.0" encoding="UTF-8"?>
<lexicon version="1.0"
xmlns="http://www.w3.org/2005/01/pronunciation-lexicon"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/01/pronunciation-lexicon
http://www.w3.org/TR/2007/CR-pronunciation-lexicon-20071212/pls.xsd"
alphabet="ipa" xml:lang="en-US">
<lexeme>
<grapheme>tomato</grapheme>
<phoneme>/tə'meɪtoʊ/</phoneme>
</lexeme>
<lexeme>
<grapheme>Tomato</grapheme>
<phoneme>/tə'meɪtoʊ/</phoneme>
</lexeme>
</lexicon>
2

SDK를 통해 파일에서 발음 사전 만들기

다음 코드로 파일을 만듭니다. 파일 이름은 example.py, example.mts, example.go, PronunciationDictionaries.java, example.rb 또는 example.php로 지정합니다. C#은 Program.cs의 내용을, Rust는 src/main.rs의 내용을 바꿉니다.

from elevenlabs import ElevenLabs, PronunciationDictionaryVersionLocator
from elevenlabs.play import play
elevenlabs = ElevenLabs()
with open("dictionary.pls", "rb") as f:
# this dictionary changes how tomato is pronounced
pronunciation_dictionary = elevenlabs.pronunciation_dictionaries.create_from_file(
file=f.read(), name="example"
)
audio_1 = elevenlabs.text_to_speech.convert(
text="Without the dictionary: tomato",
voice_id="aMSt68OGf4xUZAnLpTU8",
model_id="eleven_v4_turbo",
)
audio_2 = elevenlabs.text_to_speech.convert(
text="With the dictionary: tomato",
voice_id="aMSt68OGf4xUZAnLpTU8",
model_id="eleven_v4_turbo",
pronunciation_dictionary_locators=[
PronunciationDictionaryVersionLocator(
pronunciation_dictionary_id=pronunciation_dictionary.id,
version_id=pronunciation_dictionary.version_id,
)
],
)
# play the audio
play(audio_1)
play(audio_2)
3

코드 실행

python example.py

Python과 TypeScript는 두 버전을 모두 스피커로 재생합니다. 다른 SDK는 각각 without-dictionary.mp3와 with-dictionary.mp3에 저장합니다.

다음 단계