Partajați prin


TtsEngineSsml.AddLexicon(Uri, String, ITtsEngineSite) Method

Definition

Adds a lexicon to the SynthesizerVoice implemented by the current TtsEngineSsml instance.

public:
 abstract void AddLexicon(Uri ^ uri, System::String ^ mediaType, System::Speech::Synthesis::TtsEngine::ITtsEngineSite ^ site);
public abstract void AddLexicon (Uri uri, string mediaType, System.Speech.Synthesis.TtsEngine.ITtsEngineSite site);
abstract member AddLexicon : Uri * string * System.Speech.Synthesis.TtsEngine.ITtsEngineSite -> unit
Public MustOverride Sub AddLexicon (uri As Uri, mediaType As String, site As ITtsEngineSite)

Parameters

uri
Uri

A valid instance of System.Uri indicating the location of the lexicon information.

mediaType
String

A string containing the media type of the lexicon. Media types are case insensitive.

site
ITtsEngineSite

A reference to an ITtsEngineSite interface used to interact with the platform infrastructure.

Examples

The implementation of AddLexicon uses the ITtsEngineSite interface passed in to load a lexicon from a resource. It then stores a System.IO.Stream to the lexicon in a System.Collections.Generic.Dictionary instance, indexed by the lexicon URI.

public static Dictionary<Uri, Stream> _aLexicons = new Dictionary<Uri, Stream>();  

 public void AddLexicon(Uri uri, string mediaType, ITtsEngineSite site) {  
    Stream stream = site.LoadResource(uri, mediaType);  
    _aLexicons.Add(uri, stream);  
}  

 public void RemoveLexicon(Uri uri, ITtsEngineSite site) {  
     Stream stream;  
     if (_aLexicons.TryGetValue(uri, out stream)) {  
         stream.Close();  
         _aLexicons.Remove(uri);  
     }  
}  

Remarks

A pronunciation lexicon is a collection of words or phrases together with their pronunciations specified using an appropriate pronunciation alphabet.

This method is typically called by the platform infrastructure in response to a System.Speech.Synthesis based applications calling AddLexicon and using the synthesizer voice implemented by the current TtsEngineSsml instance.

The value of mediaType is typically a MIME specification, as the SSML specification uses MIME for media specifications.

Notes to Implementers

It is the responsibility of the implementation to be fully familiar with and be able to process the lexicon stored at uri. The implementation must also keep track and manage the lifetimes of all lexicons it adds.

Applies to