Domanda

Sono nuovo in C# e sono nuovo a Speech.Recognition. Ho cercato molto tempo per i tutorial ma non ho trovato molto, non sono nemmeno tranquillo sicuro di aver incluso tutto correttamente.

Ho scaricato:

Sto programmando locale, ho Windows XP, .NET Framework 3.5.

Ora voglio solo iniziare con alcune semplici righe di codice, mi piace dire "ciao mondo" o dire una o due parole come input.

Ho provato a seguire e ovviamente non funziona:> Errore:

Non è stato possibile trovare "il discorso di tipo tip o nomi" SpeechSyntesizer "(è un uso di Direktive o un Assemblyverweis mancante?)"

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

modificare:

Ciao, ti ho provato il codice, ma usando Speechlib; Non è stato trovato:>

beh, ora ho scritto:

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

Ma ricevo un errore con:

NumericUpdown1, SPVOICE, SpeechVoicesPeakFlags, TextBox1 e Timeout

È stato utile?

Soluzione

Project + Aggiungi riferimento, scheda .NET, selezionare "System.Speech".

Un modello di progetto pre-seleziona diversi assiemi .NET. Ma solo quelli comuni, come System.dll, System.core.dll, eccetera. Devi aggiungere tu stesso quelli "insoliti".

Altri suggerimenti

Puoi provare questo:

ottenere 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;
            }
        }
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top