首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >C#与微软Speech.Recognition和Speech.Synthesis

C#与微软Speech.Recognition和Speech.Synthesis
EN

Stack Overflow用户
提问于 2010-10-08 11:40:46
回答 2查看 4.6K关注 0票数 2

我是C#的新手,也是Speech.Recognition的新手。我搜索了很长时间的教程,但没有找到那么多,我甚至不确定我是否包括一切正确。

我下载了:

  • SDK
  • 运行时
  • 语言

我在本地编程,我有Windows,.net框架3.5。

现在我只想从一些简单的代码行开始,比如说"hello world“,或者说一两个单词作为输入。

我尝试了以下操作,当然它不能运行:>错误:

无法找到“类型”或“名称”"SpeechSynthesizer“(是缺少”使用-Direktive“还是”程序集“?)

代码语言:javascript
复制
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;找不到:>

现在我写到:

代码语言:javascript
复制
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和超时值

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-10-08 12:13:13

项目+添加引用,.NET选项卡,选择"System.Speech“。

项目模板预选几个.NET程序集.但只有普通的,如System.dll,System.Core.dll,等等。你必须自己加上“不寻常的”。

票数 3
EN

Stack Overflow用户

发布于 2010-10-08 11:43:37

你可以试试这个:

获取Interop.SpeechLib.dll

代码语言:javascript
复制
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;
            }
        }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3890102

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档