2

私はC#を初めて使用し、Speech.Recognitionを初めて使用します。チュートリアルを非常に長い間検索しましたが、それほど多くは見つかりませんでした。すべてが正しく含まれているかどうかさえわかりません。

私がダウンロードしました:

私はローカルでプログラミングしています。WindowsXP、.netFramework3.5を使用しています。

ここで、「hello world」と言ったり、入力として1つまたは2つの単語を言ったりするなど、いくつかの簡単なコード行から始めたいと思います。

フォローしてみましたが、もちろん動作しません:>エラー:

「Typ-またはNamespacename「SpeechSynthesizer」が見つかりませんでした(Using-DirektiveまたはAssemblyverweisがありませんか?)」

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 { }

しかし、次のエラーが発生します。

nudeUpDown1、SpVoice、SpeechVoiceSpeakFlags、textBox1およびタイムアウト

4

2 に答える 2

3

Project + Add Reference、.NETタブで、「System.Speech」を選択します。

プロジェクトテンプレートは、いくつかの.NETアセンブリを事前に選択します。ただし、System.dll、System.Core.dllなどの一般的なもののみです。「珍しい」ものを自分で追加する必要があります。

于 2010-10-08T12:13:13.233 に答える
0

あなたはこれを試すことができます:

得る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;
            }
        }
于 2010-10-08T11:43:37.757 に答える