C # et Microsoft Speech.Recognition and Speech.Synthesis
-
28-09-2019 - |
Question
Je suis nouveau dans C # et je suis nouveau dans la déclaration de discours. J'ai recherché très longtemps des tutoriels mais je n'ai pas trouvé grand-chose, je ne suis même pas silencieux si j'ai tout inclus correctement.
J'ai téléchargé:
Je programmer local, j'ai Windows XP, .NET Framework 3.5.
Maintenant, je veux juste commencer avec quelques lignes de code simples, comme dire "bonjour le monde" ou dire un ou deux mots comme entrée.
J'ai essayé de suivre, et bien sûr cela ne fonctionne pas:> Erreur:
"Le typ- ou namespacename" SpeechSyntheSizer "n'a pas pu être trouvé (un usage-direktive ou un assemblyverweis manque-t-il?)"
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");
}
}
}
Éditer:
Bonjour, j'ai essayé votre code, mais en utilisant SpeechLib; On ne peut pas être trouvé:>
Eh bien maintenant, j'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 j'obtiens une erreur avec:
NumericUpdown1, SpVoice, SpeechVoicesPeakflags, TextBox1 et Timeout
La solution
Project + Ajouter une référence, .NET Tab, sélectionner "System.Speech".
Un modèle de projet présélectionne plusieurs assemblages .NET. Mais seuls communs, comme System.dll, System.Core.dll, etctera. Vous devez ajouter vous-même les «inhabituels».
Autres conseils
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;
}
}