Error handling 我希望我的程序能够访问网页、电子邮件、Facebook和twitter,而无需打开窗口

Error handling 我希望我的程序能够访问网页、电子邮件、Facebook和twitter,而无需打开窗口,error-handling,speech-recognition,Error Handling,Speech Recognition,我一直在尝试制作一个V.I(虚拟智能),可以回答你的问题,你可以告诉它做一些事情,比如告诉我我有多少封电子邮件,告诉我是否有人给我发了一封电子邮件,如果我问它问题,它可以搜索网页,例如,如果我问它正在读什么,它可以搜索维基百科,并告诉我阅读后的前几个单词。这是到目前为止的代码,用于语音识别和回答某些问题。请告诉我如何纠正一些错误,比如V.I说hello,IDE说不可访问的代码 using System; using System.Collections.Generic; using System

我一直在尝试制作一个V.I(虚拟智能),可以回答你的问题,你可以告诉它做一些事情,比如告诉我我有多少封电子邮件,告诉我是否有人给我发了一封电子邮件,如果我问它问题,它可以搜索网页,例如,如果我问它正在读什么,它可以搜索维基百科,并告诉我阅读后的前几个单词。这是到目前为止的代码,用于语音识别和回答某些问题。请告诉我如何纠正一些错误,比如V.I说hello,IDE说不可访问的代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Speech.Recognition;
using System.Speech.Synthesis;
using System.Runtime.InteropServices;
using System.IO;
using System.Xml;
using System.Xml.Linq ;
using System.Web ;


namespace JAPA
{ 
    public partial class Form1 : Form
    {
        SpeechRecognitionEngine _myrecognizer = new SpeechRecognitionEngine ();
        SpeechSynthesizer EDI = new SpeechSynthesizer();

        //The string Cevent(Conputer event) is a variable that will be used for the termination of the computer.
        string Cevent;
        //The string QandA(Question and answer) this is a mehtod full of cases for a respond from japa
        string QandA;
        //this is a string to be used  for Japa when he  is communicating
        string Japaspeech;

        public Form1()
        {
            InitializeComponent();

            ///This block of code handles the SpeechRecognition
            _myrecognizer.SetInputToDefaultAudioDevice();
            _myrecognizer.SpeechRecognized += new EventHandler < SpeechRecognizedEventArgs > (_myrecognizer_SpeechRecognized);
            _myrecognizer.RecognizeAsync(RecognizeMode.Multiple);
        }



        private void _myrecognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            throw new NotImplementedException();
        }



        private void Form1_Load(object sender, EventArgs e)
        {

        }



        /// <summary>
        /// This block contains code for the termination of the computer.
        /// </summary>
        public void computerdeath()
        {
            switch (Cevent)
            {
              case " shutdown":
                  System.Diagnostics.Process.Start("shutdown,'-s'");
                  break;
              case " closeup ":
                  System.Diagnostics.Process.Start("shutdown,'-s'");
                  break;
              case "log off ":
                  System.Diagnostics.Process.Start("shutdown,'-l'");
                  break;
              case "hibernate":
                  System.Diagnostics.Process.Start("shutdown,'-h'");
                  break;
              case "restart":
                  System.Diagnostics.Process.Start("shutdown,'-r'");
                  break;
            }
        }



        //This methid contains cases for incasity of questions by user.
        public void Myname()
        {  
            switch ( QandA)
            {
                case "your name ":
                break;

                case "identity":
                break;

                case " your alias":
                break;

                case   "your surname":
                break;
            }
        }

        void _myrecognizer_SpeechRecognized(object sender,SpeechRecognizedEventArgs e)
        {
            switch (Japaspeech)
            {  //This part heads the greetings japa will recieve and her reply
                case "Hi":
                    break;
                case "Hey there":
                    break;
                case "Mate":
                    break;
                case "doing*":
                    break;

                case "going on*":
                    break ;
                    //This part of the code replies the greetings  
                    EDI.Speak("Hello there");
            }
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用系统组件模型;
使用系统数据;
使用系统图;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
使用System.Windows.Forms;
使用系统语音识别;
使用系统、语音、合成;
使用System.Runtime.InteropServices;
使用System.IO;
使用System.Xml;
使用System.Xml.Linq;
使用System.Web;
名称空间JAPA
{ 
公共部分类Form1:Form
{
SpeechRecognitionEngine_MyRecognitor=新建SpeechRecognitionEngine();
SpeechSynthesizer EDI=新的SpeechSynthesizer();
//字符串Cevent(Conputer事件)是用于终止计算机的变量。
字符串Cevent;
//字符串QandA(问题和答案)这是一种充满日本回复案例的方法
串坎达;
//这是Japa在交流时使用的字符串
字符串Japaspeech;
公共表格1()
{
初始化组件();
///这段代码处理语音识别
_myrecognizer.setInputOdeFaultAudioDevice();
_myrecognizer.SpeechRecognized+=新事件处理程序(\u myrecognizer\u SpeechRecognized);
_myrecognizer.RecognizeAsync(RecognizeMode.Multiple);
}
私有void\u myrecognizer\u SpeechRecognized(对象发送方,SpeechRecognizedEventArgs e)
{
抛出新的NotImplementedException();
}
私有void Form1\u加载(对象发送方、事件参数e)
{
}
/// 
///此块包含终止计算机的代码。
/// 
公众死亡()
{
开关(Cevent)
{
案例“关闭”:
系统.诊断.过程.启动(“关闭”'-s');
打破
案例“特写”:
系统.诊断.过程.启动(“关闭”'-s');
打破
案例“注销”:
系统.诊断.过程.启动(“关闭”-l';
打破
案例“休眠”:
系统.诊断.过程.启动(“关闭”'-h');
打破
案例“重启”:
系统.诊断.过程.启动(“关闭”'-r');
打破
}
}
//此methid包含用户提问不方便的案例。
public void Myname()
{  
开关(QandA)
{
案例“您的姓名”:
打破
案例“身份”:
打破
案例“您的别名”:
打破
案例“您的姓氏”:
打破
}
}
void\u myrecognizer\u SpeechRecognized(对象发送方,SpeechRecognizedEventArgs e)
{
交换机(Japaspech)
{//这部分是japa将收到的问候和她的回复
案例“Hi”:
打破
案例“你好”:
打破
“配偶”一案:
打破
案例“正在做*”:
打破
案例“正在进行*”:
打破
//这部分代码回复问候语
说(“你好”);
}
}
}
}

行中有无法访问的代码:

EDI.Speak("Hello there");

此代码无法访问,因为它前面有一个break语句。我建议您在继续之前先了解switch语句是如何工作的,因为
switch(Japaspeech)
中的所有中断看起来都是错误的。试着用手模拟代码的运行方式,看看哪里出了问题。

我不明白它们是怎么错的,我整晚都在读开关和断路器‘请告诉我最后一个是错的,因为在语句之前有
break
,所以开关会在语句执行之前结束。我假设您想要
EDI.Speak(“您好”)
执行,无论
Japaspeech
在哪种情况下匹配,这将使所有其他中断都不必要,因为只要找到匹配项,它们都会结束开关,如果您忽略它们,则
EDI.Speak(“你好”)将在任何匹配项上执行。这个假设可能是完全错误的,我不知道你到底想做什么。谢谢!,我试图做的是让EDI响应任何一种情况,这取决于用户说的是哪种情况。谢谢你的帮助,我很感激。请问谁能回答关于访问电子邮件和文件的第一个问题这里的问题是关于修复代码中的逻辑错误,而不是关于实现扩展。你应该将答案标记为已接受,或者指出为什么它不能回答问题本身,然后你应该真正将电子邮件作为一个单独的问题来提问,展示你迄今为止所做的尝试。