C#およびMicrosoft Speech.Recognition and Speech.Synthesis
-
28-09-2019 - |
質問
私はC#を初めて使用していますが、Speech.Recognitionは初めてです。私はチュートリアルを非常に長く検索しましたが、それほど多くは見つかりませんでした。すべてを正しく含めたかどうかは静かではありません。
私がダウンロードしました:
私はローカルをプログラミングしています、私はWindows XP、.NETフレームワーク3.5を持っています。
今、私は「Hello World」と言ったり、入力として1つか2つの単語を言ったりするような、いくつかの簡単なコードを始めたいだけです。
フォローしようとしましたが、もちろん動作しません。>エラー:
「Typ-またはnamespaceName」「SpeechSynthesizer」は見つかりませんでした(使用型または組み立てverweisがありませんか?)」
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;
}
}
所属していません StackOverflow