我将在C#Window表单应用程序中显示识别语音结果。但是,在将结果转换为字符串并将其显示在文本框中时遇到了问题。
在这里附上我的代码: 在我的Voice.cs中
namespace GUI_FYP
{
class Voice
{
public static async Task<RecognitionResult> RecognizeSpeechAsync()
{
var config = SpeechConfig.FromSubscription("xxxxxxxxxxxxxxxx", "southeastasia");
using (var recognizer = new SpeechRecognizer(config))
{
var result = await recognizer.RecognizeOnceAsync();
return result;
}
}
}
}
在我的Form.cs
private void VoiceStart_Click_1(object sender, EventArgs e)
{
Voice.RecognizeSpeechAsync().Wait();
string command = Voice.RecognizeSpeechAsync().Result.ToString;
VoiceBox.Text = command;
}