Question:
i am writing a program in c# and have a problem?
2009-04-26 06:42:16 UTC
this is code to make a program that when the name of an animal is spoken into a mic a picture of that animal is displayed that is the function i am having bother with here is the code it is the switch statement i am having bother with if you could replace the ? also any other suggestions would be helpfull

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SpeechLib;
namespace SimpleSpeechRecognition
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{


speechListBox1.Items.Add("dog");
speechListBox1.Items.Add("cat");
speechListBox1.Items.Add("hamster");
speechListBox1.Items.Add("elephant");
speechListBox1.Items.Add("lion");
speechListBox1.Items.Add("tiger");
speechListBox1.SpeechEnabled = true;
}

private void speechListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
MessageBox.Show(speechListBox1.SelectedItems[0].ToString());
SayPhrase(speechListBox1.SelectedItems[0].ToString());
}


private void SayPhrase(string PhraseToSay )
{

SpeechVoiceSpeakFlags SpFlags = new SpeechVoiceSpeakFlags();
SpVoice Voice = new SpVoice();
Voice.Speak(PhraseToSay, SpFlags);

}



private void pictureBox1_click(object sender, EventArgs e)
{
switch (?)
{


case "cat":
{
pictureBox1.Image = Image.FromFile(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\pictures\cat.jpg");
pictureBox1.Refresh();
}
case "dog":
{
pictureBox1.Image = Image.FromFile(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\pictures\dog.jpg");
pictureBox1.Refresh();
}
case "hamster":
{
pictureBox1.Image = Image.FromFile(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\pictures\hamster.jpg");
pictureBox1.Refresh();
}
case "elephant":
{
pictureBox1.Image = Image.FromFile(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\pictures\elephant.jpg");
pictureBox1.Refresh();
}
case "lion":
{
pictureBox1.Image = Image.FromFile(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\pictures\lion.jpg");
pictureBox1.Refresh();
}
case "tiger":
{
pictureBox1.Image = Image.FromFile(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\pictures\tiger.jpg");
pictureBox1.Refresh();
}
}

}




}
}
Four answers:
?
2009-04-26 13:12:41 UTC
Hmm should be (from where I'm sitting)



speechListBox1.Items.Name



You need to switch on the item in question which look like the item name in the listbox collection. Since you're using speech I'm not sure if there is another property that you can use (since I've never had to code speech recog before.



I don't know if the speechlib you're using works but I did find an article and blog that is more up to date and documents writing an app that recognises speech from sound...



Hope this helps!
?
2016-12-05 22:45:28 UTC
This seems to be using graph concept - you're able to understand approximately Prims set of rules as what are desiring is a minimum spanning tree for a related weighted undirected graph. this implies it unearths a subset of the sides that kinds a tree that contains each and every vertex, the place the full weight of each and every of the sides interior the tree is minimized the different one that includes innovations is Kruskal's set of rules. it is pc technology 3 hundred and sixty 5 days 3 stuff. - right it is a pair of hyperlinks to an occasion of Prims & Kruscals alorithmns
Shocking_Wired
2009-04-26 06:52:10 UTC
sorry mate im looking into making a game with C# but i havent started learning the code yet.



Thing is that your really asking the wrong people here, its out of 99% of this website are slackjawed rejects so im gonna say check into an actual C# forum for answers or xbla coding forums as it runs on the C# code.
Freebirdgonewild
2009-04-26 07:04:36 UTC
I believe you would replace the ? with speechListBox1


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...