我想使用语音命令打开OpenFileDialog
我有一个例外我无法查看文件对话框我使用表单应用程序,这是我的代码:
private void StartVoiceCommand(object sender, SpeechRecognizedEventArgs e)
{
else if(e.Result.Text == "media")
{
SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
speechSynthesizer.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Teen);
speechSynthesizer.Speak("Choose media files");
speechSynthesizer.Dispose();
openFilesToolStripMenuItem.PerformClick();
}
}
并且openfiletoolstripmenuitem
代码为:
[STAThread]
private void openFilesToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.Filter = "Media Files|*.mp3;*.mp4";
open.Multiselect = true;
if(DialogResult.OK == open.ShowDialog())
{
files = open.SafeFileNames;
path = open.FileNames;
for(int i =0;i<files.Length;i++)
{
listBox1.Items.Add(files[i]);
}
}
}
这是我的Program.cs
代码
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}