Essays.club - Ensayos gratis, notas de cursos, notas de libros, tareas, monografías y trabajos de investigación
Buscar

Negocio electronico.

Enviado por   •  6 de Febrero de 2018  •  1.112 Palabras (5 Páginas)  •  370 Visitas

Página 1 de 5

...

Código C#.

- public int opcion;

- public string voz;

- Liststring> nombre = new Liststring>();

Creamos un Método llamado CargarVoces:

Código C#.

- public void CargarVoces()

- {

- foreach (InstalledVoice voz in oSynthesizer.GetInstalledVoices())

- {

- nombre.Add(voz.VoiceInfo.Name.ToString());

- }

-

- }

Cada voz contiene información como:

-Nombre.-Edad.-Género.-Cultura.-Etc.

Necesitamos el Nombre para seleccionar la voz mediante la Función SelectVoice el cual requiere un parámetro string.

Creamos un Método llamado MenuVoz

Código C#.

- public void MenuVoz()

- {

- int opcion = 0;

- do

- {

-

- Console.WriteLine("===============================");

- Console.WriteLine("===SELECCIONE VOZ DISPONIBLE===");

- Console.WriteLine("===============================");

- for (int i = 1; i nombre.Count()+1; i++)

- {

- Console.WriteLine(i + ". " + nombre[i-1].ToString() + ".");

- if (i == nombre.Count)

- {

- Console.WriteLine(i+1+". " +"Salir.");

- }

- }

-

- Console.WriteLine("===============================");

- opcion=Convert.ToInt16(Console.ReadLine());

-

- for (int i = 1; i nombre.Count() + 1; i++)

- {

- if (opcion == i)

- {

-

- voz = nombre[i-1].ToString();

- ElegirVoz();

- Console.WriteLine("Voz Seleccionada.");

-

- }

-

- }

-

-

- } while (opcion != nombre.Count()+1);

- }

Lo único "complejo" podría ser el porque la Índice del Item de nuestra Lista tiene un -1, esto debido a que la listatiene una dimensión la cual, al sobrepasarse no permitirá hacer referencia a un objeto no existente y tendremos el clásico "Índice fuera de Rango".

Creamos un Método ElegirVoz:

Código: [Seleccionar]

public void ElegirVoz()

{

oSynthesizer.SelectVoice(voz);

}Modificamos el Método Speech:

Código C#.

- public void speech()

- {

- CargarVoces();

- string first = "I'm ready";

- string a = "Yes";

- string b = "Hello, Today is: " + DateTime.Now.ToShortDateString();

- string c = "¿Do you Want to Exit this Command Window? Yes/No";

- string d = "";

- string e = "I'm Sorry, I can't Understand.";

- string f = "Bye";

-

- Console.WriteLine(first);

- oSynthesizer.Speak(first);

- Console.WriteLine(b);

- oSynthesizer.Speak(b);

-

- do

- {

-

- Console.WriteLine(c);

- oSynthesizer.Speak(c);

- d = Console.ReadLine();

- if (d == a)

- {

- Console.WriteLine(f);

- oSynthesizer.Speak(f);

-

- }

- if (d == "Change")

- {

- MenuVoz();

- speech();

- break;

- }

- else

- {

- Console.WriteLine(e);

- oSynthesizer.Speak(e);

- }

- } while (d != a);

- }

-

...

Descargar como  txt (8.3 Kb)   pdf (56.6 Kb)   docx (17.3 Kb)  
Leer 4 páginas más »
Disponible sólo en Essays.club