SpeechSynthesizer.AddLexicon(Uri, String) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
SpeechSynthesizer 개체에 어휘집을 추가합니다.
public:
void AddLexicon(Uri ^ uri, System::String ^ mediaType);
public void AddLexicon (Uri uri, string mediaType);
member this.AddLexicon : Uri * string -> unit
Public Sub AddLexicon (uri As Uri, mediaType As String)
매개 변수
- uri
- Uri
lexicon 정보의 위치입니다.
- mediaType
- String
어휘집의 미디어 유형입니다. 미디어 형식 값은 대/소문자를 구분하지 않습니다.
예제
다음 예에서는 "blue" 라는 단어에 대 한 사용자 지정 발음이 포함 된 어휘를 추가 하 고 제거 하는 효과를 보여 줍니다. 어휘는 "blue"의 발음을 "bleep"와 같은 소리로 정의 합니다. 어휘가 로드 되는 동안 음성 신시사이저는 어휘 집에 정의 된 발음을 사용 합니다.
using System;
using System.Speech.Synthesis;
namespace SampleSynthesis
{
class Program
{
static void Main(string[] args)
{
// Initialize a new instance of the SpeechSynthesizer.
using (SpeechSynthesizer synth = new SpeechSynthesizer())
{
// Configure the audio output.
synth.SetOutputToDefaultAudioDevice();
// Speak the prompt.
synth.Speak("My favorite color is blue.");
// Add a lexicon that changes the pronunciation of "blue".
synth.AddLexicon(new Uri("C:\\test\\Blue.pls"), "application/pls+xml");
// Speak the prompt.
synth.Speak("My favorite color is blue.");
// Remove the lexicon.
synth.RemoveLexicon(new Uri("C:\\test\\Blue.pls"));
// Speak the prompt.
synth.Speak("My favorite color is blue.");
}
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}
다음은 j 어휘 파일의 내용입니다.
<?xml version="1.0" encoding="UTF-8"?>
<lexicon version="1.0"
xmlns="http://www.w3.org/2005/01/pronunciation-lexicon"
alphabet="x-microsoft-ups" xml:lang="en-US">
<lexeme>
<grapheme> blue </grapheme>
<phoneme> B L I P </phoneme>
</lexeme>
</lexicon>
설명
음성 용어는 지원 되는 phonetic의 문자와 문자로 구성 된 발음와 함께 단어나 구의 모음입니다. 애플리케이션에서 특수화 된 어휘에 대 한 사용자 정의 발음을 지정 하는 용어를 사용할 수 있습니다.
외부 어휘 파일에 지정 된 발음는 음성 신시사이저의 내부 어휘 집 또는 사전의 발음 보다 우선적으로 적용 됩니다. 그러나, 또는 메서드 중 하나를 사용 하 여 만든 프롬프트에서 발음 지정 된 인라인은 AppendTextWithPronunciation AppendSsmlMarkup AppendSsml 모든 어휘에 지정 된 발음 보다 우선적으로 적용 됩니다. 인라인 발음 한 단어의 단일 항목에만 적용 됩니다. 참조 사전 및 음성 알파벳 자세한 내용은 합니다.
개체에 여러 lexicons를 추가할 수 있습니다 SpeechSynthesizer . 현재 매개 변수에는 두 개의 값이 지원 됩니다 mediaType
.
이 값은
application/pls+xml
어휘가 j (발음 어휘 사양) 버전 1.0을 준수 함을 나타냅니다. 사용할 기본 형식입니다.값은
application/vdn.ms-sapi-lex
어휘 형식이 Microsoft 소유의 형식인 압축 되지 않은 어휘 임을 나타냅니다. 이는 레거시 형식 이므로 위에 설명 된 j 형식을 사용 하는 것이 좋습니다.