TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
tan shen
NA
11
1.9k
Why the speak appears before the switching of picture.
Nov 8 2017 8:21 PM
SpeechSynthesizer ss =
new
SpeechSynthesizer();
PromptBuilder pb =
new
PromptBuilder();
SpeechRecognitionEngine sre =
new
SpeechRecognitionEngine();
Choices clist =
new
Choices();
int
counter = 0;
int
counter_CorrectAns = 0;
public
void
Question()
{
string
path = @
"C:\Users\Tan Wei Shen\Desktop\FYP\New folder\"
;
string
[] filePaths = Directory.GetFiles(path,
"*.jpg"
);
pictureBox1.Image = Image.FromFile(filePaths[counter]);
ss.SpeakAsync(
"What is this?"
);
clist.Add(
new
string
[] {
"apple"
,
"chicken"
,
"eraser"
});
Grammar gr =
new
Grammar(
new
GrammarBuilder(clist));
try
{
sre.RequestRecognizerUpdate();
sre.LoadGrammar(gr);
sre.SpeechRecognized += sre_SpeechRecognized;
sre.SetInputToDefaultAudioDevice();
sre.RecognizeAsync(RecognizeMode.Multiple);
}
catch
(Exception ex)
{
MessageBox.Show(ex.Message,
"Error"
);
}
}
private
void
WellDone()
{
timer1.Start();
sre.RecognizeAsyncStop();
label1.Visible =
false
;
string
path = @
"C:\Users\Tan Wei Shen\Desktop\FYP\correct\"
;
string
[] filePaths = Directory.GetFiles(path,
"*.png"
);
pictureBox1.Image = Image.FromFile(filePaths[counter_CorrectAns]);
ss.Speak(
"Well done"
);
counter++;
}
public
Form1()
{
InitializeComponent();
}
private
void
Form1_Load(
object
sender, EventArgs e)
{
}
private
void
sre_SpeechRecognized(
object
sender, SpeechRecognizedEventArgs e)
{
switch
(e.Result.Text.ToString())
{
case
"apple"
:
WellDone();
break
;
case
"chicken"
:
WellDone();
break
;
case
"eraser"
:
WellDone();
break
;
}
}
private
void
btnStart_Click(
object
sender, EventArgs e)
{
btnStart.Visible =
false
;
label1.Visible =
true
;
pictureBox1.Visible =
true
;
Question();
}
private
void
timer1_Tick(
object
sender, EventArgs e)
{
Question();
timer1.Stop();
}
Reply
Answers (
1
)
Getting error while using OpenXML for Excel Export
Connecting and using database