2010-10-08 29 views
2

Je suis nouveau à C# et je suis nouveau à Speech.Recognition. J'ai cherché très longtemps pour des tutoriels, mais je n'ai pas trouvé grand-chose, je ne suis même pas sûr d'avoir tout compris correctement.C# et Microsoft Speech.Recognition et Speech.Synthesis

Je téléchargé:

Je suis la programmation locale, je Windows XP, NET Framework 3.5.

Maintenant, je veux juste commencer avec quelques lignes de code simples, comme dire "bonjour monde" ou dire un ou deux mots en entrée.

J'ai essayé la suite, et bien sûr, il ne fonctionne pas:> erreur:

"The Typ- or Namespacename "SpeechSynthesizer" 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"); 
     } 
    } 
} 

modifier:

bonjour, j'ai essayé votre code, mais en utilisant SpeechLib; n'a pu être trouvée:>

bien maintenant je l'ai écrit:

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

mais je reçois une erreur:

numericUpDown1,SpVoice,SpeechVoiceSpeakFlags,textBox1 and Timeout

Répondre

3

Projet + Ajouter une référence, onglet .NET, sélectionnez "System.Speech". Un modèle de projet présélectionne plusieurs assemblys .NET.

Mais seulement les plus communs, comme System.dll, System.Core.dll, etcetera. Vous devez ajouter les «inhabituels» vous-même.

+1

+1. 'Using' ne fait que créer des raccourcis vers les espaces de noms. Pour les utiliser, vous devez lier des assemblys au projet. – Mike

+0

merci, j'ai pris system.speech et maintenant ça marche! greate - (savez-vous comment je passe à la langue allemande?) – Tyzak

+0

Oui, trois années d'allemand au lycée aidé. Mais je ne pense pas que vous l'obtiendrez sur une machine Windows à moins que la version Windows soit allemande. Pas sûr de ce qui est nécessaire, de l'argent sans doute. Commencer une autre question à ce sujet sur superuser.com –

0

vous pouvez essayer ceci:

obtenir 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; 
      } 
     }