Okay, so I've been messing around with C# for the past couple of days, and I when I say I'm new to the language, I started just days ago and this is my first actual project, whilst using C#. Anyway, I can get my project working, however, I seem to be running into a few minor and annoying bugs, one bug is that I swear that the mic picks up the voice synth, and then uses the output from my project as a command.
Only reason I think this may be the cause is due to the fact that I've been getting sick of hearing audio feedback, so I decided to mute it, and use a text box to output what's actually going on. Well when there's 0 audio feedback, it works pretty great for the first part, but when I have my volume setting to anything where the mic may pick up the audio feedback, then it runs commands that I don't want it to. Is there a way around this? Maybe muting the mic while and only while the system is speaking?
Now as for my second bug, I know this is purely down to me having a lack of understanding as to how the grammar and grammar builder classes work, I will invest more time into it, when I have the time. But for this part, I'm trying to make my project look at an entirely different set of commands, once the user says a key phrase, such as, "Google ____ for me" or "Run ____ for me", as an example. I keep getting a few silly errors, but these silly errors seem to be down to the fact that I'm still learning how to code in C#.
When I run the commands it initially has, it seems to work 100% fine, 0 errors, unless you include the fact that it's picking up the output, which I WOULD LOVE to solve, I mean it seems like such a stupid error to me. I just feel the need to get around that. I did try Synth.Speak(String s)
instead of Synth.SpeakAsync(String s)
, but as it turns out, it didn't make much difference.
I mean this project doesn't have to work as I'd hope it would, but it sure as hell would be fun and pretty cool if I can get it to work, and I'm trying my very best to be persistent with it. So far, I've got a couple of automated process, like the system sets up a profile/account so to speak somewhere on the C drive, because everyone has a C drive, however the user can choose where to store other files, such as the commands and replies, etc, all through the use of a simple GUI. Now this part works 100% fine, it's able to look at the profile and find the files associated with this program, etc.
I just seem to be experiencing some silly bugs/errors, like earlier, I just did a huge brain fart, and I messed up with my logic, but I guess that happens to even the best on some days? We all have those 'slow' days so to speak?
So if anyone who's pretty good with C#, and specifically the Speech lib, could you please lend me a hand? Even if it's just pointing me to good learning material, etc. I've been browsing the web, obviously, just to get as far as I have with my project.
EDIT:
As it turns out, I was wrong about the program picking up the synth's output, I must be doing something wrong with my logic, I'm simply trying to get the software to loop through an array if you like, to find x command. As you can see below, however, my issue is that it seems to absolutely love the element of the array, at position 1, and I'm not sure why? - Keep in mind, I could still be brain farting, it's nearly 2am here, and I've been up trying to develop this further and further all the time, but after this post, I'm gonna call it a night.
So here's a sample of some of my code, where I think it's going wrong:
// all of this is done in the speech rec event
for (int i = 0; i < bot.getCommands().Count; i++)
{
Boolean CommandFound = false;
if (e.Result.Text == bot.getCommands()[i])
{
txt_Chat_Box.Text += "\n";
txt_Chat_Box.Text += "\n" + bot.getCommands()[i];
txt_Chat_Box.Text += "\n" + bot.getReplies()[i];
reply = bot.getReplies()[i]; // assign the reply value
// make him actually speak
synthesizer.SpeakAsync(bot.getReplies()[i]);
CommandFound = true;
}
// break out of the loop - Note, I can't use return due to code below...
if (CommandFound == true) { break; }
}
// I.E.
if (reply == "The date is...")
{
String theDate = DateTime.Now.ToShortDateString();
synthesizer.SpeakAsync(theDate);
txt_Chat_Box.Text += " " + theDate;
}