microsoft.speech合成器说话命令挂起

时间:2017-09-26 14:32:02

标签: c# synthesizer

我在不同的PC和不同版本的Windows上使用Microsoft.Speech合成器多年。我正在尝试在新的Windows 10 PC上设置开发和支持环境,但我无法让spsynthesizer正常工作。我已经两次下载了Microsoft SDK5.1和声音,以确保没有任何损坏。我已经使用调试器逐步完成了每行代码,所有内容都按预期工作,直到调用spsynthesizer.speak ...调用从不说话,永远不会返回程序。我尝试执行x86,x64和AnyCPU,我有一个Microsoft.Speech的参考条目。

有什么建议吗?这是简单的C#测试应用程序。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Speech.Synthesis;
namespace test_text_to_speech
{
class Program
{
    static void Main(string[] args)
    {
        Microsoft.Speech.Synthesis.SpeechSynthesizer spsynthesizer = new Microsoft.Speech.Synthesis.SpeechSynthesizer();
        System.Collections.ObjectModel.ReadOnlyCollection<Microsoft.Speech.Synthesis.InstalledVoice> myvoices;
        myvoices = spsynthesizer.GetInstalledVoices();
        spsynthesizer.SelectVoice(myvoices[0].VoiceInfo.Name); //Invoke the one which you want
        spsynthesizer.Volume = 100; // Can be 1 - 100
        spsynthesizer.Rate = 1; // can be 1 - 10 
        spsynthesizer.SetOutputToDefaultAudioDevice();

        PromptBuilder Thanks = new PromptBuilder();
            Thanks.AppendSsmlMarkup("<voice xml:lang=\"en-US\">");
        Thanks.StartStyle(new PromptStyle(PromptEmphasis.Strong));
            Thanks.AppendText("Hello World");
        Thanks.EndStyle();
        Thanks.AppendSsmlMarkup("</voice>");

        spsynthesizer.Speak(Thanks);
        spsynthesizer.Speak("try with no markup");

    }
}

}

0 个答案:

没有答案