コードの音声合成クラスが ListBoxItem.toString() から単語を読み上げるのに苦労しています。btnStart_Clicked() メソッドの foreach ループは、問題が始まると思われる場所です。
test = testLstSet.lstWordlist.Items.ToString();
speech.SpeakAsync(test);
スピーチシンセは私に教えてくれます:
「system.windows.forms.listbox + object.collections」
誰か助けてくれませんか?すべてのコードについて申し訳ありませんが、できるだけ多くの情報を提供したかったのです。
私は何を間違っていますか?
public partial class MyClass : Form
{
private bool testStarted = false;
private SpeechSynthesizer speech;
private string evalWord = null;
string test;
bool testBit = false;
TestList testLstSet;
public SpellingBee(TestList tstLst)
{
InitializeComponent();
testLstSet = tstLst;
speech = new SpeechSynthesizer();
speech.SpeakAsync("Hello! Welcome to The test. Shall we begin?");
}
private void btnStart_Click(object sender, EventArgs e)
{
if (testStarted)
return;
else
{
testStarted = true;
foreach(var item in wrdLstSet.lstWordlist.Items)
{
test = testLstSet.lstWordlist.Items.ToString();
speech.SpeakAsync(test);
while(!testBit)
{
}
}
}
}
private void btnSubmit_Click(object sender, EventArgs e)
{
string evalWord = this.txtAnswer.Text;
bool answer = string.Equals(evalWord, test, StringComparison.OrdinalIgnoreCase);
if (answer)
{
speech.SpeakAsync("That's right! Good Job!");
testbit = true;
}
else
{
speech.SpeakAsync("That is incorrect.");
testbit = true;
}
}
}
}