Pregunta

Soy nuevo en C# y soy nuevo en el discurso. Busqué mucho tutoriales, pero no encontré tanto, incluso no estoy tranquilo si incluí todo correctamente.

Yo descargué:

Estoy programando local, tengo Windows XP, .NET Framework 3.5.

Ahora solo quiero comenzar con algunas líneas simples de código, me gusta decir "hola mundo" o decir una o dos palabras como entrada.

Intenté seguir y, por supuesto, no funciona:> Error:

"El tipo de apacuación de típico o el nombre de nombre" SpeechSythesizer "no se pudo encontrar (¿falta un uso de direktive o un ensamblaje?"

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

editar:

Hola, probé tu código, pero usando SpeechLib; no se puede encontrar:>

Bueno, ahora escribí:

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

Pero recibo un error con:

NumericUpdown1, Spvoice, SpeechVoicesPeakFlags, TextBox1 y TIMeout

¿Fue útil?

Solución

Proyecto + Agregar referencia, pestaña .NET, seleccione "System.speech".

Una plantilla de proyecto preelecciona varios ensamblados .NET. Pero solo los comunes, como System.dll, System.core.dll, etcetera. Tienes que agregar los 'inusuales' usted mismo.

Otros consejos

Puedes probar esto:

obtener 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;
            }
        }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top