我是C#的新手,也是Speech.Recognition的新手。我搜索了很长时间的教程,但没有找到那么多,我甚至不确定我是否包括一切正确。
我下载了:
我在本地编程,我有Windows,.net框架3.5。
现在我只想从一些简单的代码行开始,比如说"hello world“,或者说一两个单词作为输入。
我尝试了以下操作,当然它不能运行:>错误:
无法找到“类型”或“名称”"SpeechSynthesizer“(是缺少”使用-Direktive“还是”程序集“?)
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和超时值
发布于 2010-10-08 12:13:13
项目+添加引用,.NET选项卡,选择"System.Speech“。
项目模板预选几个.NET程序集.但只有普通的,如System.dll,System.Core.dll,等等。你必须自己加上“不寻常的”。
发布于 2010-10-08 11:43:37
你可以试试这个:
获取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;
}
}https://stackoverflow.com/questions/3890102
复制相似问题