简体   繁体   English

如何使用System.Speech

[英]How to work with System.Speech

So I have: 所以我有:

C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework.NETFramework\\v4.0\\Profile\\Client\\ System.Speech.dll C:\\ Program Files(x86)\\ Reference Assemblies \\ Microsoft \\ Framework.NETFramework \\ v4.0 \\ Profile \\ Client \\ System.Speech.dll

...and I can add the reference to Visual Studio but using System.Speech etc won't register with the console, and therefore speech synthesis and recognition does not work. ...我可以添加对Visual Studio的引用,但是using System.Speech等不会向控制台注册,因此语音合成和识别不起作用。

Would appreciate any and all help, thanks! 非常感谢任何帮助,谢谢!

You need to add a reference to the System.Speech assembly, then you are free to use speech like so: 您需要添加对System.Speech程序集的引用,然后您可以像这样使用语音:

using System;
using System.Speech; // <-- sounds like what you are using, not necessary for this example
using System.Speech.Recognition; // <--- you need this

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SpeechRecognizer recognizer = new SpeechRecognizer())
            {
                // do something
            }
        }
    }
}

Adding reference 添加参考

Just in case, here is the reference I am using (via project . References.Add Reference... ): 以防万一,这是我正在使用的参考(通过项目 .References.Add参考... ):

在此输入图像描述

It is not necessary to use the Browse function. 没有必要使用Browse功能。 I'm assuming you are not using COM too. 我假设你也没有使用COM。

Tell me more 告诉我更多

Its a little out of date but this tutorial shows you how to get started using the System.speech class 它有点过时,但本教程向您展示如何开始使用System.speech类

It sounds like what you are doing now is trying to use the class directly. 听起来你现在正在尝试直接使用该类。 The first step is to make an instance of the SpeechSynthesizer or SpeechRecognizer class with which you can perform the System.speech actions. 第一步是使实例SpeechSynthesizerSpeechRecognizer与您可以执行System.speech动作类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM