Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# SpeechSynthesizer.AddLexicon不遵守自定义重写_C#_Text To Speech_Speech Synthesis_Lexicon - Fatal编程技术网

C# SpeechSynthesizer.AddLexicon不遵守自定义重写

C# SpeechSynthesizer.AddLexicon不遵守自定义重写,c#,text-to-speech,speech-synthesis,lexicon,C#,Text To Speech,Speech Synthesis,Lexicon,我使用语音合成器将文本转换成语音。我想使用一个自定义词典文件,所以我使用了上推荐的AddLexicon方法 这是我的功能 public void ReadOut(string sentence) { using (SpeechSynthesizer synth = new SpeechSynthesizer()) { synth.SelectVoiceByHints(gender: VoiceGender.Male, ag

我使用语音合成器将文本转换成语音。我想使用一个自定义词典文件,所以我使用了上推荐的AddLexicon方法

这是我的功能

     public void ReadOut(string sentence)
    {
        using (SpeechSynthesizer synth = new SpeechSynthesizer())
        {
            synth.SelectVoiceByHints(gender: VoiceGender.Male, age: VoiceAge.Adult, voiceAlternate: 1, culture: CultureInfo.CreateSpecificCulture("en-US"));
            synth.Rate = -2;
            var fqn = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var uri = new Uri("file://" + fqn + "/CustomLexicon.pls");
            synth.AddLexicon(uri, "application/pls+xml");
            synth.Speak(sentence);
        }

    }
我的词典文件是

 <?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>

蓝色
B L I P
但是,当我将“BLUE”传递给函数时,它仍然输出BLUE而不是BLIP。我错过什么了吗


注意:我确保pls文件存在于正确的位置,并且其内容已正确填充。

这似乎是系统中的一个错误。根据此处接受的答案,合成器的语音实现: