我是C#的新手,我是Speech.revention的新手。我搜索了很长时间的教程,但没有发现那么多,我什至不确定是否正确包含了所有内容。

我下载了:

我正在本地编程,我有Windows XP,.NET Framework 3.5。

现在,我只想开始一些简单的代码行,例如说“ Hello World”或说一个或两个单词作为输入。

我尝试关注,当然它不起作用:>错误:

找不到“典型或命名点”“ SpeechSynthesizer”(是使用direktive或insemblyverweis缺少的?)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Recognition;
using System.Speech.Synthesis;

namespace System.Speech.Recognition { }
namespace System.Speech.AudioFormat {}
namespace System.Speech.Recognition.SrgsGrammar{}
namespace System.Speech.Synthesis { }
namespace System.Speech.Synthesis.TtsEngine { }

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            SpeechSynthesizer foo = new SpeechSynthesizer();
            foo.Speak("Test");  
        }
    }
}

编辑:

您好,我尝试了您的代码,但是使用SpeechLib;找不到:>

好吧,我写道:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Recognition;
using System.Speech.Synthesis;
using System.SpeechLib;

namespace System.SpeechLib { }
namespace System.Speech.Recognition { }
namespace System.Speech.AudioFormat {}
namespace System.Speech.Recognition.SrgsGrammar{}
namespace System.Speech.Synthesis { }
namespace System.Speech.Synthesis.TtsEngine { }

但是我有一个错误:

numericupdown1,spvoice,speechvoicespeakflags,textbox1和超时

有帮助吗?

解决方案

项目 +添加参考,.NET选项卡,选择“ System.Speech”。

项目模板预选了几个.NET组件。但是,只有常见的system.dll,system.core.dll等常见的常见。您必须自己添加“不寻常的”。

其他提示

您可以尝试一下:

得到 Interop.SpeechLib.dll

using SpeechLib;

private void ReadText(string readText)
        {
            int iCounter = 0;
            while (Convert.ToInt32(numericUpDown1.Value) > iCounter)
            {
                SpVoice spVoice = new SpVoice();
                spVoice.Speak(textBox1.Text, SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak);
                spVoice.WaitUntilDone(Timeout.Infinite);
                iCounter = iCounter + 1;
            }
        }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top