gpt4 book ai didi

error-handling - 我希望我的程序无需打开窗口即可访问网页,电子邮件,Facebook和Twitter

转载 作者:行者123 更新时间:2023-12-03 09:06:37 25 4
gpt4 key购买 nike

我一直在尝试制作一个可以回答您的问题的VI(虚拟智能),您可以告诉它做一些事情,例如告诉我我有多少封电子邮件,告诉我是否有人给我发送了电子邮件以及我是否询问它质疑它可以搜索一个网页,例如,如果我问它正在阅读什么,它可以搜索Wikipedia并告诉我单词阅读后的前几个单词。到目前为止,这是用于语音识别和对某些问题的答复的代码。请告诉我如何纠正一些错误,例如V.I向您问好,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");
}
}
}
}

最佳答案

该行有无法访问的代码:

EDI.Speak("Hello there");

该代码无法访问,因为您之前直接有一个break语句。我建议您在继续之前先学习一下switch语句的工作方式,因为 switch (Japaspeech)中的所有中断似乎都是错误的。尝试模仿代码将如何手动运行,以查看出现问题的地方。

关于error-handling - 我希望我的程序无需打开窗口即可访问网页,电子邮件,Facebook和Twitter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33451527/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com