需要帮助C ++中的C#chatbot集成 [英] Need Help with Intergration of C# chatbot in C++
问题描述
大家好,
这是我在这里的第一篇文章,需要你的帮助。我对编程非常陌生并有一个小型的C#程序,它使用预编译的.dll Chabot也是用c#编写的,但我正在尝试
将这个Chabot作为我的车辆的AI集成(想想套件出来的nightrider )在C ++中用于cryengine 3 free sdk。我编写的代码在C ++中从控制台获取输入并将文本响应转换为语音(TTS)并使用语音识别将我的单词输入
到文本并输入到控制台窗口(语音到文本)。我想要做的是将文本输入控制台,从我的语音发送到Chabot .dll,这是用我的C ++程序用C#编写的,以及来自Chabot .dll的响应发送到我的C ++
程序得到的转换为语音。
Chatbot C#如下所示:它只是打开一个控制台窗口,允许我通过文本与聊天机器人交谈,并获得文本响应来自Chatbot AIML引擎。
使用System;
使用AIMLbot;
namespace CryBot
{
class program
{
static void Main(string [] args)
{
Bot cryBot = new Bot();
cryBot.loadSettings();
用户myUser =新用户(" consoleUser",cryBot);
cryBot.isAcceptingUserInput = false;
cryBot.loadAIMLFromFiles();
cryBot.isAcceptingUserInput = true;
while(true)
{
Console.Write(" CryEngine Player:");
string input = Console.ReadLine();
if(input.ToLower()==" quit")
{
break;
}
else
{
请求r =新请求(输入,myUser,cryBot);
结果res = cryBot.Chat(r);
Console.WriteLine(" CryBot:" + res.Output);
}
}
}
}
}
实际上我没有
甚至需要显示控制台窗口,我真正想要的是具有与Chabot AIML引擎通过语音进行通信的相同功能,然后将Chabot响应转换为语音响应。< o:p>< / o:p>
我需要来自上面的C ++等效代码可以直接从visual studio 2010 C ++访问C#AIMLBot.dll然后插入我的C ++语音到文本/文本到语音代码,这样我就可以在使用C ++的
cryengine 3免费sdk中使用。任何帮助将是赞赏的人,干杯J< o:p>< / o:p>
Hello KingBadger
您无法在本机C ++中使用托管程序集(C#.NET)中的对象。您可以通过使用托管C ++ / CLI来解决这个问题,但由于我没有这方面的经验,我可以给您发一个链接: http://msdn.microsoft.com/en-us/magazine/cc163852.aspx
Hi Guys,
This is my first post on here as need your help. I’m very new to programming and have a small C# program that uses a precompiled .dll Chabot also written in c#, but I’m trying to integrate this Chabot as an AI for my vehicle (think Kit out of nightrider) in C++ for the cryengine 3 free sdk. I’ve written code that takes input from console in C++ and convert the text response to speech (TTS) and that uses speech recognition to enter my words into text and inputs to console window (speech to text). What I want to do though is have the text entered into console from my voice sent to the Chabot .dll that is made in C# from my C++ program and the response from the Chabot .dll sent to my C++ program to get converted to speech.
The Chatbot C# is as follows: All it does is open a console window that allows me to talk to the chatbot by text, and gets a text response from the Chatbot AIML engine.
using System; using AIMLbot; namespace CryBot { class Program { static void Main(string[] args) { Bot cryBot = new Bot(); cryBot.loadSettings(); User myUser = new User("consoleUser", cryBot); cryBot.isAcceptingUserInput = false; cryBot.loadAIMLFromFiles(); cryBot.isAcceptingUserInput = true; while (true) { Console.Write("CryEngine Player: "); string input = Console.ReadLine(); if (input.ToLower() == "quit") { break; } else { Request r = new Request(input, myUser, cryBot); Result res = cryBot.Chat(r); Console.WriteLine("CryBot: " + res.Output); } } } } }
In fact I don’t
even need to display the console window, what I really want is to have the same functionality of being to communicate by voice with the Chabot AIML engine, and the Chabot response to then be converted into a speech response.<o:p></o:p>
I need equivalent code from above for C++ that can access C# AIMLBot.dll directly from visual studio 2010 C++ to then plug into my C++ speech to text / Text to speech code so I can use in the cryengine 3 free sdk that uses C++. Any help would be appreciated guys, Cheers J<o:p></o:p>
Hello KingBadger
You cannot consume objects from managed assemblies (C#.NET) in native C++. You might get around this by using managed C++/CLI, but as I have no experience with this I can just post you a link: http://msdn.microsoft.com/en-us/magazine/cc163852.aspx
这篇关于需要帮助C ++中的C#chatbot集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!