开发者

C# and Microsoft Speech.Recognition and Speech.Synthesis

I'm new to C# and I'm new to Speech.Recognition. I searched very long for tutorials but didn't find that much, I'm even not quiet sure whether I included everything correctly.

I downloaded:

  • SDK
  • Runtime
  • Languages

I'm programming local, I have Windows XP, .net framework 3.5.

Now I just want to get started with some simple lines of code, like to say "hello world" or say one or two words as input.

I tried following, and of course it doesn't work :> error:

"The Typ- or Namespacename "SpeechSy开发者_运维知识库nthesizer" couldn't be found (Is a Using-Direktive or a Assemblyverweis missing?)"

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");  
        }
    }
}

edit:

hello, i tried you code,but using SpeechLib; couldn't be found :>

well now i wrote:

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

but I get an error with:

numericUpDown1,SpVoice,SpeechVoiceSpeakFlags,textBox1 and Timeout


Project + Add Reference, .NET tab, select "System.Speech".

A project template pre-selects several .NET assemblies. But only common ones, like System.dll, System.Core.dll, etcetera. You have to add the 'unusual' ones yourself.


you can try this:

get 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;
            }
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜