欧拉密SDK 下载 地址 : 欧拉密SDK
欧拉密SDK 下载 并解压 会得到这四个文件夹 根据需求使用相应的 .dll 库
欧拉密官方网站
注册账号之后点击应用管理模块
点击创建新应用
根据提示创建你的应用
配置对话模块 默认全部勾选 注意保存设置
可以查看 欧拉密 Key 和 Secret 值
打开 欧拉密 NLI管理系统
点击我的语法
新建自定义语法
注意编写格式 回答模块包括 语音回答和自定义回答两种模式
编写格式
编写完成后注意保存
点击发布 发布之后才可以使用
如果不满意 可以在再次编辑
编辑完成注意保存和发布
返回应用管理 并点击配置模块
勾选自定义回答模块 保存设置 自定义回答模块就完成了
新建一个项目工程 并在 Assets 路径下新建一个 Plugins的文件夹
并把 AipSdk.dll Newtonsoft.Json.dll 拖入
基础创建
音源创建
脚本搭载
特别说明:如果想要使用欧拉密的相关模块,需要去欧拉密官方网站进行项目配置,默认创建的项目是全部勾选的
如果想要自定义配置的话需要自己手动配置并发布,才可以正常使用。
特别注意:百度的文字转语音API是免费的,但是语音识别转文字是需要付费使用的哟。
如果脚本 《ASR_ZH》 using Ai.Olami.Example; 引用报错就把这个代码添加到你的项目里面。
/*
Copyright 2017, VIA Technologies, Inc. & OLAMI Team.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;
using System.Text;
using System.Net;
using System.IO;
using System.Collections.Specialized;
using System.Security.Cryptography;
namespace Ai.Olami.Example
{
class NluApiSample
{
public static string API_NAME_SEG = "seg";
public static string API_NAME_NLI = "nli";
private string _ApiBaseUrl;
private string _AppKey;
private string _AppSecret;
///
/// 设置访问OLAMI服务的授权信息
///
/// 从OLAMI开发人员控制台获得的AppKey
/// 从OLAMI开发控制台的AppSecret
public void SetAuthorization(string appKey, string appSecret)
{
this._AppKey = appKey;
this._AppSecret = appSecret;
}
///
/// 设置本地化以选择服务区域,这与不同的服务器url或语言等有关。
///
/// API服务的URL
public void SetLocalization(string apiBaseURL)
{
this._ApiBaseUrl = apiBaseURL;
}
///
/// 获取输入文本的NLU识别结果。
///
/// HTTP参数“API =xxx”的API名称
/// 你想要识别的文本
/// 识别结果
public string GetRecognitionResult(string _ApiName, string _InputText)
{
string _Result;
double _Timestamp = Convert.ToInt64((DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds);
// 准备消息以生成MD5摘要
StringBuilder _SignMsg = new StringBuilder()
.Append(_AppSecret)
.Append("api=")
.Append(_ApiName)
.Append("appkey=")
.Append(_AppKey)
.Append("timestamp=")
.Append(_Timestamp)
.Append(_AppSecret);
// 生成MD5摘要
MD5 _Md5 = MD5.Create();
StringBuilder _Sign = new StringBuilder();
byte[] _Hash = _Md5.ComputeHash(Encoding.Default.GetBytes(_SignMsg.ToString()));
for (int i = 0; i < _Hash.Length; i++)
{
_Sign.Append(_Hash[i].ToString("X2"));
}
// 通过HTTP POST请求NLU服务
using (WebClient _Client = new WebClient())
{
Console.WriteLine("Sending 'POST' request to URL : " + _ApiBaseUrl);
NameValueCollection _ApiParam = null;
if (_ApiName == NluApiSample.API_NAME_SEG)
{
_ApiParam = new NameValueCollection()
{
{ "appkey", _AppKey },
{ "api", NluApiSample.API_NAME_SEG },
{ "timestamp", _Timestamp.ToString() },
{ "sign", _Sign.ToString() },
{ "rq", _InputText }
};
}
else if (_ApiName == NluApiSample.API_NAME_NLI)
{
_ApiParam = new NameValueCollection()
{
{ "appkey", _AppKey },
{ "api", NluApiSample.API_NAME_NLI },
{ "timestamp", _Timestamp.ToString() },
{ "sign", _Sign.ToString() },
{ "rq", "{\"data_type\":\"stt\", \"data\":{\"input_type\":1,\"text\":\"" + _InputText + "\"}}" }
};
}
byte[] _Response = _Client.UploadValues(_ApiBaseUrl, _ApiParam);
_Result = System.Text.Encoding.UTF8.GetString(_Response);
}
return _Result;
}
}
}
using Baidu.Aip.Speech;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net.Http;
using UnityEngine;
using UnityEngine.Networking;
///
/// 语音合成
///
public class VoiceSynthesis_ZH : MonoBehaviour
{
[Header("音源")]
public AudioSource _Audio;
[Header("AI 发声器")]
public Pronouncer _Pronouncer = Pronouncer.Duyaya;
//全局变量
public static VoiceSynthesis_ZH _World;
//网页文字转语音
private string _Url;
//百度语音识别SDK
private Asr _AipClient;
private void Start()
{
_World = this;
}
//获取 Web网页音源信息并播放
public IEnumerator GetAudioClip(string AudioText)
{
//_Url = "https://tsn.baidu.com/text2audio?tex=" + AudioText +
// "+&lan=zh&cuid=7919875968150074&ctp=1&aue=6&tok=25.3141e5ae3aa109abb6fc9a8179131181.315360000.1886566986.282335-17539441";
_Url = "http://tsn.baidu.com/text2audio?tex=" + AudioText +
"&tok=25.3141e5ae3aa109abb6fc9a8179131181.315360000.1886566986.282335-17539441" +
"&cuid=a7a0e3326da873c6fb0609e6385a82b934c9cb11" +
"&ctp=1" +
"&lan=zh" +
"&spd=5" +
"&pit=5" +
"&vol=10" +
"&per=" + (((int)_Pronouncer).ToString()) +
"&aue=6";
using (UnityWebRequest _AudioWeb = UnityWebRequestMultimedia.GetAudioClip(_Url, AudioType.WAV))
{
yield return _AudioWeb.SendWebRequest();
if (_AudioWeb.isNetworkError)
{
yield break;
}
AudioClip _Cli = DownloadHandlerAudioClip.GetContent(_AudioWeb);
_Audio.clip = _Cli;
_Audio.Play();
}
}
///
/// 获取 Web网页音源信息并播放 附带延迟时间
///
///
///
///
public IEnumerator GetAudioClip(string AudioText,float _DelayedTimer)
{
//_Url = "https://tsn.baidu.com/text2audio?tex= AudioText &lan=zh&cuid=7919875968150074&ctp=1&aue=6&tok=25.3141e5ae3aa109abb6fc9a8179131181.315360000.1886566986.282335-17539441
// "";
yield return new WaitForSeconds(_DelayedTimer);
_Url = "http://tsn.baidu.com/text2audio?tex=" + AudioText +
"&tok=25.3141e5ae3aa109abb6fc9a8179131181.315360000.1886566986.282335-17539441" +
"&cuid=a7a0e3326da873c6fb0609e6385a82b934c9cb11" +
"&ctp=1" +
"&lan=zh" +
"&spd=5" +
"&pit=5" +
"&vol=10" +
"&per=" + (((int)_Pronouncer).ToString()) +
"&aue=6";
using (UnityWebRequest _AudioWeb = UnityWebRequestMultimedia.GetAudioClip(_Url, AudioType.WAV))
{
yield return _AudioWeb.SendWebRequest();
if (_AudioWeb.isNetworkError)
{
yield break;
}
AudioClip _Cli = DownloadHandlerAudioClip.GetContent(_AudioWeb);
_ASRMusic.clip = _Cli;
_ASRMusic.Play();
}
}
///
/// 语音识别
///
/// param >
/// < returns > returns >
private IEnumerator Recognition(AudioClip _Clip)
{
//开放 音频 长度
float[] _Sample = new float[_Clip.samples];
//用片段中的样本数据填充数组
_Clip.GetData(_Sample, 0);
//数据转换
short[] _IntData = new short[_Sample.Length];
byte[] _ByteData = new byte[_IntData.Length * 2];
for (int i = 0; i < _Sample.Length; i++)
{
_IntData[i] = (short)(_Sample[i] * short.MaxValue);
}
Buffer.BlockCopy(_IntData, 0, _ByteData, 0, _ByteData.Length);
//返回Json数据 (数据 格式 码率)
var _Result = _AipClient.Recognize(_ByteData, "pcm", 16000);
//获取Json 数据中的 讲话内容
var _Speaking = _Result.GetValue("result");
//检测是否有内容
if (_Speaking == null)
{
StopAllCoroutines();
yield return null;
}
//讲话内容转换为 字符串
string _UsefulText = _Speaking.First.ToString();
print(_UsefulText);
yield return 0;
}
///
/// 访问令牌获取
///
///
private static class AccessToken
{
// 调用getAccessToken()获取的 access_token建议根据expires_in 时间 设置缓存
// 返回token示例
public static String TOKEN = "24.adda70c11b9786206253ddb70affdc46.2592000.1493524354.282335-1234567";
// 百度云中开通对应服务应用的 API Key 建议开通应用的时候多选服务
private static String clientId = "百度云应用的AK";
// 百度云中开通对应服务应用的 Secret Key
private static String clientSecret = "百度云应用的SK";
public static String GetAccessToken()
{
String authHost = "https://aip.baidubce.com/oauth/2.0/token";
HttpClient client = new HttpClient();
List<KeyValuePair<string, string>> paraList = new List<KeyValuePair<string, string>>();
paraList.Add(new KeyValuePair<string, string>("grant_type", "client_credentials"));
paraList.Add(new KeyValuePair<string, string>("client_id", clientId));
paraList.Add(new KeyValuePair<string, string>("client_secret", clientSecret));
HttpResponseMessage response = client.PostAsync(authHost, new FormUrlEncodedContent(paraList)).Result;
String result = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);
return result;
}
}
///
/// AI 发音器
///
public enum Pronouncer
{
//普通女声
Female,
//普通男生
Male,
//特殊男声
Teshunan,
//情感合成男生
Duxiaoyao,
//情感合成女生
Duyaya
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
Application.Quit();
}
}
}
using Ai.Olami.Example;
using Baidu.Aip.Speech;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
using static Json_ZH;
///
/// 人工智能语音播放
///
public class ASR_ZH : MonoBehaviour
{
[Header("文字显示")]
public Text _ASRText;
[Header("ASR Toggle")]
public Toggle _Toggle;
[Header("ASR Json")]
private Root _JsonDataWeb;
[Header("ASR Json 故事")]
private Root02 _JsonDataWeb02;
[Header("ASR Json 百度百科")]
private Root03 _JsonDataWeb03;
[Header("ASR Json 选择")]
private Root04 _JsonDataWeb04;
[Header("ASR Json 菜肴")]
private Root05 _JsonDataWeb05;
[Header("ASR Json 搜索")]
private Root06 _JsonDataWeb06;
[Header("ASR Json 股票")]
private Root07 _JsonDataWeb07;
[Header("ASR Json 电视节目")]
private Root08 _JsonDataWeb08;
[Header("ASR Json 天气")]
private Root09 _JsonDataWeb09;
[Header("ASR Json 诗集选择")]
private Root10 _JsonDataWeb10;
[Header("ASR Json 菜肴选择")]
private Root11 _JsonDataWeb11;
[Header("ASR Json 酒店选择")]
private Root12 _JsonDataWeb12;
[Header("ASR Json 诗集")]
private Root13 _JsonDataWeb13;
//测试文本
private string _Str;
//欧拉密 Key 值
private string _Key= "需要自己去欧拉密 官方网站申请";
//欧拉密 Secret 值
private string _Secret = "需要自己去欧拉密 官方网站申请";
//欧拉密访问网址
private string _ApiBaseUrl = "http://cn.olami.ai/cloudservice/api";
//语音片段
private AudioClip _RecordClip;
//访问AIP需要用的Token
private string _AccessToken;
//百度语音 ID
private string _ASR_ID = "需要自己去百度 官方网站申请";
//百度语音 Key
private string _API_Key = "需要自己去百度 官方网站申请";
//百度语音 Secret
private string _Secret_Key = "需要自己去百度 官方网站申请";
//百度语音 访问网址
private string _AuthHost = "https://aip.baidubce.com/oauth/2.0/token";
//百度语音识别SDK
private Asr _AipClient;
void Start()
{
// 创建SDK的实例
_AipClient = new Asr(_ASR_ID, _API_Key, _Secret_Key);
//超时时长为6000毫秒
_AipClient.Timeout = 6000;
//保存当前应用的Token
_AccessToken = GetAccessToken();
//Toggle 事件添加
_Toggle.onValueChanged.AddListener((bool ison) => { ToggleIs(_Toggle); });
}
///
/// 点击按下说话开始录音
///
public void StartRecord()
{
//麦克风查询
if (Microphone.devices.Length > 0)
{
//麦克风获取
string _Device = Microphone.devices[0];
print(_Device);
//确认音频格式 麦克风 超过录音时长是否继续录音 录音时间(秒) 由录音产生的AudioClip的采样率
_RecordClip = Microphone.Start(_Device, true, 60, 16000);//8000 16000 16000
}
else
{
_ASRText.text = "没有音频输入模块。";
print("没有音频输入模块。");
}
}
///
/// 松开按下说话停止录音并发送识别
///
private void StopRecord()
{
//麦克风停止响应
Microphone.End(Microphone.devices[0]);
//开始识别
StartCoroutine(Recognition(_RecordClip));
}
///
/// 设置识别文本
///
/// param >
private void SetRecognizeText(string _Result)
{
_ASRText.text = _Result;
}
///
/// 访问令牌获取
///
///
private string GetAccessToken()
{
//百度AI 里面的
HttpClient _Client = new HttpClient();
List<KeyValuePair<string, string>> _ParaList = new List<KeyValuePair<string, string>>();
_ParaList.Add(new KeyValuePair<string, string>("grant_type", "client_credentials"));
_ParaList.Add(new KeyValuePair<string, string>("client_id", _API_Key));
_ParaList.Add(new KeyValuePair<string, string>("client_secret", _Secret_Key));
HttpResponseMessage _Response = _Client.PostAsync(_AuthHost, new FormUrlEncodedContent(_ParaList)).Result;
string _Result = _Response.Content.ReadAsStringAsync().Result;
Debug.Log("result is " + _Result);
return _Result;
}
///
/// 语音识别
///
/// param >
/// < returns > returns >
private IEnumerator Recognition(AudioClip _Clip)
{
//开放 音频 长度
float[] _Sample = new float[_Clip.samples];
//用片段中的样本数据填充数组
_Clip.GetData(_Sample, 0);
//数据转换
short[] _IntData = new short[_Sample.Length];
byte[] _ByteData = new byte[_IntData.Length * 2];
for (int i = 0; i < _Sample.Length; i++)
{
_IntData[i] = (short)(_Sample[i] * short.MaxValue);
}
Buffer.BlockCopy(_IntData, 0, _ByteData, 0, _ByteData.Length);
//返回Json数据 (数据 格式 码率)
var _Result = _AipClient.Recognize(_ByteData, "pcm", 16000);
//获取Json 数据中的 讲话内容
var _Speaking = _Result.GetValue("result");
//检测是否有内容
if (_Speaking == null)
{
SetRecognizeText("没有录到声音");
StopAllCoroutines();
yield return null;
}
//讲话内容转换为 字符串
string _UsefulText = _Speaking.First.ToString();
print(_UsefulText);
//开启人工智能回答
StartCoroutine(OLAMIStr(_UsefulText));
yield return 0;
}
///
/// Toggle 控件
///
///
public void ToggleIs(Toggle _ToggleASR)
{
if (_ToggleASR.isOn)
{
//开始识别
StartRecord();
}
else
{
//停止录音
StopRecord();
}
}
///
/// 欧拉密 人工智能回答
///
/// param >
/// < returns > returns >
private IEnumerator OLAMIStr(string _ASRText)
{
//欧拉米返回Json数据
string _OLAMIStr = GetRecognitionResult("nli", _ASRText);
//Json 数据WebGL 数据加载
//Json 数据类 创建
_JsonDataWeb = new Root();
_JsonDataWeb = JsonUtility.FromJson<Root>(_OLAMIStr);
//确保J送数据不为空
if (_JsonDataWeb != null)
{
//如果欧拉密饭会数据 是error的话
if (_JsonDataWeb.status == "error")
{
SetRecognizeText("解析失败,请重试。");
//播放语音
StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip("解析失败,请重试。"));
}
else
{
//获取 欧拉密回答返回值
for (int i = 0; i < _JsonDataWeb.data.nli.Count; i++)
{
//欧拉密返回值 类型
switch (_JsonDataWeb.data.nli[i].type)
{
#region 故事模块
case "joke":
print("故事模块");
//Json 数据WebGL 数据加载
//Json 数据类 创建
_JsonDataWeb02 = new Root02();
_JsonDataWeb02 = JsonUtility.FromJson<Root02>(_OLAMIStr);
//字符串优化
StringBuilder _SpeciesJoke = new StringBuilder();
if (_JsonDataWeb02.data.nli.Count > 0)
{
for (int j = 0; j < _JsonDataWeb02.data.nli.Count; j++)
{
_SpeciesJoke.Append(_JsonDataWeb02.data.nli[j].desc_obj.result + "\n");
_SpeciesJoke.Append(_JsonDataWeb02.data.nli[j].data_obj[j].content);
//屏幕输出返回值
SetRecognizeText(_SpeciesJoke.ToString());
}
//播放人工智能语音
StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_SpeciesJoke.ToString()));
}
else
{
_SpeciesJoke.Append("你可以换个说法哟。");
//播放人工智能语音
StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_SpeciesJoke.ToString()));
}
break;
#endregion
#region 百度百科模块
case "baike":
print("百度百科模块");
//Json 数据WebGL 数据加载
//Json 数据类 创建
_JsonDataWeb03 = new Root03();
_JsonDataWeb03 = JsonUtility.FromJson<Root03>(_OLAMIStr);
for (int k = 0; k < _JsonDataWeb03.data.nli.Count; k++)
{
//字符串优化
StringBuilder _SpeciesBaike = new StringBuilder();
//如果是 [生物] 物种 类
if (_JsonDataWeb03.data.nli[k].data_obj[k].type == "species")
{
_SpeciesBaike.Append(_JsonDataWeb03.data.nli[k].desc_obj.result + "\n" + "\n");
//确保数据存在
if (_JsonDataWeb03.data.nli[k].data_obj[k].field_value.Count>0)
{
//具体信息
for (int j = 0; j < _JsonDataWeb03.data.nli[k].data_obj[k].field_value.Count; j++)
{
//名称 + 内容
_SpeciesBaike.Append(_JsonDataWeb03.data.nli[k].data_obj[k].field_name[j] + ":" + _JsonDataWeb03.data.nli[k].data_obj[k].field_value[j] + "\n");
}
}
else
{
_SpeciesBaike.Append("没有找到具体数据");
}
_SpeciesBaike.Append("\n" + "详细信息:" + _JsonDataWeb03.data.nli[k].data_obj[k].description);
//百度百科具体内容
SetRecognizeText(_SpeciesBaike.ToString());
播放人工智能语音
//StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_JsonDataWeb03.data.nli[k].desc_obj.result));
延时执行
//yield return new WaitForSeconds(2.5f);
//播放人工智能语音
StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_SpeciesBaike.ToString()));
}
else
{
//欧拉密回答
_SpeciesBaike.Append(_JsonDataWeb03.data.nli[k].desc_obj.result + "\n");
//确保数据存在
if (_JsonDataWeb03.data.nli[k].data_obj[k].field_value.Count > 0)
{
//具体信息
for (int j = 0; j < _JsonDataWeb03.data.nli[k].data_obj[k].field_value.Count; j++)
{
//名称 + 内容
_SpeciesBaike.Append(_JsonDataWeb03.data.nli[k].data_obj[k].field_name[j] + ":" + _JsonDataWeb03.data.nli[k].data_obj[k].field_value[j] + "\n");
}
}
else
{
_SpeciesBaike.Append("没有找到具体数据");
}
//详细信息
_SpeciesBaike.Append(_JsonDataWeb03.data.nli[k].data_obj[k].description);
//百度百科具体内容
SetRecognizeText(_SpeciesBaike.ToString());
播放人工智能语音
//StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_JsonDataWeb03.data.nli[k].desc_obj.result));
延时执行
//yield return new WaitForSeconds(2.5f);
//播放人工智能语音
StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_SpeciesBaike.ToString()));
}
}
break;
#endregion
#region 选择模块
case "selection":
print("选择模块");
#region 多轮对话选择模块
switch (_JsonDataWeb.data.nli[i].desc_obj.type)
{
case "poem":
print("诗集模块");
//Json 数据WebGL 数据加载
//Json 数据类 创建
_JsonDataWeb10 = new Root10();
_JsonDataWeb10 = JsonUtility.FromJson<Root10>(_OLAMIStr);
//字符串优化
StringBuilder _SpeciesSelectionPoem = new StringBuilder();
_SpeciesSelectionPoem.Append(_JsonDataWeb10.data.nli[i].desc_obj.result + "\n\n");
//确保数据存在
if (_JsonDataWeb10.data.nli[i].data_obj.Count > 0)
{
for (int j = 0; j < _JsonDataWeb10.data.nli[i].data_obj.Count; j++)
{
_SpeciesSelectionPoem.Append("《" + _JsonDataWeb10.data.nli[i].data_obj[j].poem_name + "》" + "\n");
_SpeciesSelectionPoem.Append("作者:" + _JsonDataWeb10.data.nli[i].data_obj[j].author + "\n\n");
}
}
else
{
_SpeciesSelectionPoem.Append("没有找到哟");
}
//百度百科具体内容 第一次对话
SetRecognizeText(_SpeciesSelectionPoem.ToString());
//播放人工智能语音
StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_SpeciesSelectionPoem.ToString()));
break;
case "cooking":
print("菜肴选择模块");
//Json 数据WebGL 数据加载
//Json 数据类 创建
_JsonDataWeb11 = new Root11();
_JsonDataWeb11 = JsonUtility.FromJson<Root11>(_OLAMIStr);
//字符串优化
StringBuilder _SpeciesSelectionCooking = new StringBuilder();
_SpeciesSelectionCooking.Append(_JsonDataWeb11.data.nli[i].desc_obj.result + "\n\n");
//确保数据存在
if (_JsonDataWeb11.data.nli[i].data_obj.Count > 0)
{
for (int j = 0; j < _JsonDataWeb11.data.nli[i].data_obj.Count; j++)
{
_SpeciesSelectionCooking.Append("名称:" + _JsonDataWeb11.data.nli[i].data_obj[j].name + "\n\n");
}
}
else
{
_SpeciesSelectionCooking.Append("没有找到这道菜,可以换一个说法。");
}
//百度百科具体内容 第一次对话
SetRecognizeText(_SpeciesSelectionCooking.ToString());
//播放人工智能语音
StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_SpeciesSelectionCooking.ToString()));
break;
case "hotel":
print("酒店选择模块");
//Json 数据WebGL 数据加载
//Json 数据类 创建
_JsonDataWeb12 = new Root12();
_JsonDataWeb12 = JsonUtility.FromJson<Root12>(_OLAMIStr);
//字符串优化
StringBuilder _SpeciesHotel = new StringBuilder();
_SpeciesHotel.Append(_JsonDataWeb12.data.nli[i].desc_obj.result + "\n\n");
//确保数据存在
if (_JsonDataWeb12.data.nli[i].data_obj.Count > 0)
{
for (int j = 0; j < _JsonDataWeb12.data.nli[i].data_obj.Count; j++)
{
_SpeciesHotel.Append("酒店名字:" + _JsonDataWeb12.data.nli[i].data_obj[j].hotel_name + "\n");
_SpeciesHotel.Append("酒店描述:" + _JsonDataWeb12.data.nli[i].data_obj[j].description + "\n");
_SpeciesHotel.Append("酒店地址:" + _JsonDataWeb12.data.nli[i].data_obj[j].hotel_address + "\n");
_SpeciesHotel.Append("酒店形象:" + _JsonDataWeb12.data.nli[i].data_obj[j].hotel_image + "\n");
_SpeciesHotel.Append("平均价格:" + _JsonDataWeb12.data.nli[i].data_obj[j].max_price + "\n");
_SpeciesHotel.Append("最低价格:" + _JsonDataWeb12.data.nli[i].data_obj[j].floor_price + "\n");
_SpeciesHotel.Append("酒店网站:" + _JsonDataWeb12.data.nli[i].data_obj[j].description_url + "\n");
_SpeciesHotel.Append("携程评级:" + _JsonDataWeb12.data.nli[i].data_obj[j].ctrip_rating + "\n");
_SpeciesHotel.Append("用户评级:" + _JsonDataWeb12.data.nli[i].data_obj[j].user_rating + "\n\n");
}
}
else
{
_SpeciesHotel.Append("可以尝试再说一遍。");
}
//百度百科具体内容 第一次对话
SetRecognizeText(_SpeciesHotel.ToString());
//播放人工智能语音
StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_SpeciesHotel.ToString()));
break;
default:
//百度百科具体内容 第一次对话
SetRecognizeText("对不起,我没有明白你说的是什么意思?");
//播放人工智能语音
StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip("对不起,我没有明白你说的是什么意思?"));
break;
}
#endregion
break;
#endregion
#region 菜肴模块
case "cooking":
print("菜肴模块");
//Json 数据WebGL 数据加载
//Json 数据类 创建
_JsonDataWeb05 = new Root05();
_JsonDataWeb05 = JsonUtility.FromJson<Root05>(_OLAMIStr);
//字符串优化
StringBuilder _SpeciesCooking = new StringBuilder();
if (_JsonDataWeb05.data.nli.Count > 0)
{
for (int j = 0; j < _JsonDataWeb05.data.nli.Count; j++)
{
//欧拉密响应
_SpeciesCooking.Append(_JsonDataWeb05.data.nli[j].desc_obj.result + "\n");
//具体菜肴做法
_SpeciesCooking.Append(_JsonDataWeb05.data.nli[j].data_obj[j].content);
}
}
else
{
_SpeciesCooking.Append("没有听清你在说什么。");
}
//屏幕输出返回值
SetRecognizeText(_SpeciesCooking.ToString());
//播放人工智能语音
StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_SpeciesCooking.ToString()));
break;
#endregion
#region 搜索模块
case "openweb":
print("搜索模块");
//Json 数据WebGL 数据加载
//Json 数据类 创建
_JsonDataWeb06 = new Root06();
_JsonDataWeb06 = JsonUtility.FromJson<Root06>(_OLAMIStr);
//字符串优化
StringBuilder _SpeciesOpenweb = new StringBuilder();
if (_JsonDataWeb06.data.nli.Count > 0)
{
for (int j = 0; j < _JsonDataWeb06.data.nli.Count; j++)
{
//欧拉密响应
_SpeciesOpenweb.Append(_JsonDataWeb06.data.nli[j].desc_obj.result + "\n");
//具体搜索信息
_SpeciesOpenweb.Append(_JsonDataWeb06.data.nli[j].data_obj[j].url);
//播放人工智能语音
StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_JsonDataWeb06.data.nli[j].desc_obj.result));
}
}
else
{
_SpeciesOpenweb.Append("可以描述的再具体一点。");
}
//屏幕输出返回值
SetRecognizeText(_SpeciesOpenweb.ToString());
break;
#endregion
#region 股票模块
case "stock":
print("股票模块");
//Json 数据WebGL 数据加载
//Json 数据类 创建
_JsonDataWeb07 = new Root07();
_JsonDataWeb07 = JsonUtility.FromJson<Root07>(_OLAMIStr);
//字符串优化
StringBuilder _SpeciesStock = new StringBuilder();
if (_JsonDataWeb07.data.nli.Count > 0)
{
for (int j = 0; j < _JsonDataWeb07.data.nli.Count; j++)
{
//如果有股票数据的话
if (_JsonDataWeb07.data.nli[j].data_obj.Count > 0)
{
//欧拉密响应
_SpeciesStock.Append(_JsonDataWeb07.data.nli[j].desc_obj.result + "\n");
_SpeciesStock.Append("股票名称:" + _JsonDataWeb07.data.nli[j].data_obj[j].name + "\n");
_SpeciesStock.Append("股票代码:" + _JsonDataWeb07.data.nli[j].data_obj[j].id + "\n");
_SpeciesStock.Append("最高点:" + _JsonDataWeb07.data.nli[j].data_obj[j].price_high + "\n");
_SpeciesStock.Append("最低点:" + _JsonDataWeb07.data.nli[j].data_obj[j].price_low + "\n");
_SpeciesStock.Append("今开:" + _JsonDataWeb07.data.nli[j].data_obj[j].price_start + "\n");
_SpeciesStock.Append("昨收:" + _JsonDataWeb07.data.nli[j].data_obj[j].price_end + "\n");
_SpeciesStock.Append("变化率:" + _JsonDataWeb07.data.nli[j].data_obj[j].change_rate + "\n");
_SpeciesStock.Append("最低交易:" + _JsonDataWeb07.data.nli[j].data_obj[j].cur_price + "\n");
_SpeciesStock.Append("成交量:" + _JsonDataWeb07.data.nli[j].data_obj[j].volume + "\n");
}
else
{
_SpeciesStock.Append(_JsonDataWeb07.data.nli[j].desc_obj.result + "\n");
}
//播放人工智能语音
StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_JsonDataWeb07.data.nli[0].desc_obj.result));
}
//屏幕输出返回值
SetRecognizeText(_SpeciesStock.ToString());
//播放人工智能语音
//StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_SpeciesStock.ToString()));
}
break;
#endregion
#region 电视模块
case "tvprogram":
print("电视模块");
//Json 数据WebGL 数据加载
//Json 数据类 创建
_JsonDataWeb08 = new Root08();
_JsonDataWeb08 = JsonUtility.FromJson<Root08>(_OLAMIStr);
//字符串优化
StringBuilder _SpeciesTvprogram = new StringBuilder();
if (_JsonDataWeb08.data.nli.Count > 0)
{
for (int j = 0; j < _JsonDataWeb08.data.nli.Count; j++)
{
//欧拉密响应
_SpeciesTvprogram.Append(_JsonDataWeb08.data.nli[j].desc_obj.result + "\n");
//节目单数据填充
for (int k = 0; k < _JsonDataWeb08.data.nli[j].data_obj.Count; k++)
{
//具体搜索信息
_SpeciesTvprogram.Append(_JsonDataWeb08.data.nli[j].data_obj[k].name + "\n");
_SpeciesTvprogram.Append("播出时间是:" + _JsonDataWeb08.data.nli[j].data_obj[k].time + "\n" + "\n");
}
}
}
//屏幕输出返回值
SetRecognizeText(_SpeciesTvprogram.ToString());
//播放人工智能语音
StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_SpeciesTvprogram.ToString()));
break;
#endregion
#region 天气模块
case "weather":
print("天气模块");
//Json 数据WebGL 数据加载
//Json 数据类 创建
_JsonDataWeb09 = new Root09();
_JsonDataWeb09 = JsonUtility.FromJson<Root09>(_OLAMIStr);
//字符串优化
StringBuilder _SpeciesWeather = new StringBuilder();
if (_JsonDataWeb09.data.nli.Count > 0)
{
for (int j = 0; j < _JsonDataWeb09.data.nli.Count; j++)
{
//欧拉密响应
_SpeciesWeather.Append(_JsonDataWeb09.data.nli[j].desc_obj.result + "\n");
//节目单数据填充
for (int k = 0; k < _JsonDataWeb09.data.nli[j].data_obj.Count; k++)
{
//具体搜索信息
_SpeciesWeather.Append(_JsonDataWeb09.data.nli[j].data_obj[k].description + "\n");
}
}
}
else
{
_SpeciesWeather.Append("你的声音太小了,我没听清楚。");
}
//屏幕输出返回值
SetRecognizeText(_SpeciesWeather.ToString());
//播放人工智能语音
StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_SpeciesWeather.ToString()));
break;
#endregion
#region 诗集模块
case "poem":
print("诗集模块");
//Json 数据WebGL 数据加载
//Json 数据类 创建
_JsonDataWeb13 = new Root13();
_JsonDataWeb13 = JsonUtility.FromJson<Root13>(_OLAMIStr);
//字符串优化
StringBuilder _SpeciesPoem = new StringBuilder();
if (_JsonDataWeb13.data.nli.Count > 0)
{
for (int j = 0; j < _JsonDataWeb13.data.nli.Count; j++)
{
//确保数据存在
if (_JsonDataWeb13.data.nli[j].data_obj.Count > 0)
{
for (int k = 0; k < _JsonDataWeb13.data.nli[j].data_obj.Count; k++)
{
//具体搜索信息
_SpeciesPoem.Append("《" + _JsonDataWeb13.data.nli[j].data_obj[k].title + "》" + "\n");
_SpeciesPoem.Append("作者:" + _JsonDataWeb13.data.nli[j].data_obj[k].author + "\n\n");
_SpeciesPoem.Append(_JsonDataWeb13.data.nli[j].data_obj[k].content + "\n");
}
}
else
{
_SpeciesPoem.Append("我没有找到哦,你可以再说一遍。");
}
}
}
else
{
_SpeciesPoem.Append("你的声音太小了,我没听清楚。");
}
//屏幕输出返回值
SetRecognizeText(_SpeciesPoem.ToString());
//播放人工智能语音
//播放人工智能语音
StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_SpeciesPoem.ToString()));
break;
#endregion
default:
print("基础模块");
//屏幕输出返回值
SetRecognizeText(_JsonDataWeb.data.nli[i].desc_obj.result);
//播放人工智能语音
StartCoroutine(VoiceSynthesis_ZH._World.GetAudioClip(_JsonDataWeb.data.nli[i].desc_obj.result));
break;
}
}
}
}
yield return 0;
}
private void Update()
{
//if (Input.GetKeyDown(KeyCode.E))
//{
// StartCoroutine(OLAMIStr(_Str));
//}
}
///
/// 欧拉密令牌访问 和数据返回
///
/// HTTP参数“API = nli”的API名称
/// 你想要识别的文本
/// 识别结果
private string GetRecognitionResult(string _ApiName, string _InputText)
{
string _Result;
double _Timestamp = Convert.ToInt64((DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds);
// 准备消息以生成MD5摘要
StringBuilder _SignMsg = new StringBuilder()
.Append(_Secret)
.Append("api=")
.Append(_ApiName)
.Append("appkey=")
.Append(_Key)
.Append("timestamp=")
.Append(_Timestamp)
.Append(_Secret);
// 生成MD5摘要
MD5 _Md5 = MD5.Create();
StringBuilder _Sign = new StringBuilder();
byte[] hash = _Md5.ComputeHash(Encoding.Default.GetBytes(_SignMsg.ToString()));
for (int i = 0; i < hash.Length; i++)
{
_Sign.Append(hash[i].ToString("X2"));
}
// 通过HTTP POST请求NLU服务
using (WebClient _Client = new WebClient())
{
print(("发送'POST'请求到URL" + _ApiBaseUrl));
NameValueCollection _ApiParam = null;
//如果 HTTP API 为 seg
if (_ApiName == NluApiSample.API_NAME_SEG)
{
_ApiParam = new NameValueCollection()
{
{ "appkey", _Key },
{ "api", NluApiSample.API_NAME_SEG },
{ "timestamp", _Timestamp.ToString() },
{ "sign", _Sign.ToString() },
{ "rq", _InputText }
};
}
//如果 HTTP API 为 nli
else if (_ApiName == NluApiSample.API_NAME_NLI)
{
_ApiParam = new NameValueCollection()
{
{ "appkey", _Key },
{ "api", NluApiSample.API_NAME_NLI },
{ "timestamp", _Timestamp.ToString() },
{ "sign", _Sign.ToString() },
{ "rq", "{\"data_type\":\"stt\", \"data\":{\"input_type\":1,\"text\":\"" + _InputText + "\"}}" }
};
}
//获取网页数据
byte[] _Response = _Client.UploadValues(_ApiBaseUrl, _ApiParam);
//byte 数组 转换为 文字
_Result = Encoding.UTF8.GetString(_Response);
}
print(_Result);
//返回欧拉密 Json 数据
return _Result;
}
#region 百度令牌访问弃用
private IEnumerator GetAccessToken02()
{
WWWForm wWWForm = new WWWForm();
wWWForm.AddField("grant_type", "client_credentials");
wWWForm.AddField("client_id", _API_Key);
wWWForm.AddField("client_secret", _Secret_Key);
UnityWebRequest unityWebRequest = UnityWebRequest.Post(_AuthHost, wWWForm);
yield return unityWebRequest.SendWebRequest();
if (unityWebRequest.isNetworkError)
{
print("网络错误");
}
else
{
if (unityWebRequest.responseCode == 200)
{
string re = unityWebRequest.downloadHandler.text;
print("获取:" + re);
//onGet
}
}
}
#endregion
}
using System;
using System.Collections.Generic;
///
/// Json 数据存储
///
[Serializable]
public static class Json_ZH
{
#region 基础模块返回数据
///
/// 详细描述
///
[Serializable]
public class Desc_obj
{
//返回值
public string result;
//状态
public int status;
//类型
public string type;
}
///
/// 语言项
///
[Serializable]
public class NliItem
{
public Desc_obj desc_obj;
//执行的模块 比如 日期(date)或者 闲聊(nonsense)
public string type;
}
///
/// 自然语言
///
[Serializable]
public class Data
{
public List<NliItem> nli;
}
///
/// 根节点
///
[Serializable]
public class Root
{
//成功:ok ,失败:error
public string status;
//语义理解结果的 JSON 数据
public Data data;
}
#endregion
#region 故事模块返回数据 joke story 讲个故事吧
///
/// 故事模块
///
[Serializable]
public class Desc_obj02
{
///
/// 基础返回值
///
public string result;
///
/// 故事名称
///
public string name;
///
/// 所属类型
///
public string type;
public int status;
}
[Serializable]
public class Data_objItem02
{
///
/// 具体故事内容
///
public string content;
}
[Serializable]
public class NliItem02
{
public Desc_obj02 desc_obj;
public List<Data_objItem02> data_obj;
public string type;
}
[Serializable]
public class Data02
{
public List<NliItem02> nli;
}
[Serializable]
public class Root02
{
//成功:ok ,失败:error
public string status;
//语义理解结果的 JSON 数据
public Data02 data;
}
#endregion
#region 百度百科模块返回数据 baike 什么是海豹
[Serializable]
public class Desc_obj03
{
///
/// 基础返回值
///
public string result;
///
///
///
public int status;
}
[Serializable]
public class Data_objItem03
{
///
///
///
public List<int> highlight;
///
/// 简略信息
///
public List<string> field_value;
///
/// 具体描述
///
public string description;
///
/// 印象照片网址
///
public string photo_url;
public string type;
///
/// 类别列表
///
public List<string> categorylist;
///
/// 字段名称
///
public List<string> field_name;
}
[Serializable]
public class NliItem03
{
///
///
///
public Desc_obj03 desc_obj;
///
///
///
public List<Data_objItem03> data_obj;
///
///
///
public string type;
}
[Serializable]
public class Data03
{
///
///
///
public List<NliItem03> nli;
}
[Serializable]
public class Root03
{
///
///
///
public string status;
///
///
///
public Data03 data;
}
#endregion
#region 选择模块 返回数据 selection 新闻联播在哪
[Serializable]
public class Desc_obj04
{
///
///
///
public string type;
///
///
///
public int status;
}
[Serializable]
public class Data_objItem04
{
///
/// 中国
///
public string name;
///
/// [文化, 书籍]
///
public string desc;
}
[Serializable]
public class NliItem04
{
///
///
///
public Desc_obj04 desc_obj;
///
///
///
public List<Data_objItem04> data_obj;
///
///
///
public string type;
}
[Serializable]
public class Data04
{
///
///
///
public List<NliItem04> nli;
}
[Serializable]
public class Root04
{
///
///
///
public string status;
///
///
///
public Data04 data;
}
#endregion
#region 菜肴模块返回数据 cooking 糖醋排骨怎么做
[Serializable]
public class Desc_obj05
{
///
/// 菜肴返回值
///
public string result;
///
///
///
public int status;
}
[Serializable]
public class Data_objItem05
{
///
///
///
public string name;
///
/// 红烧排骨
///
public string content;
}
[Serializable]
public class NliItem05
{
///
///
///
public Desc_obj05 desc_obj;
///
///
///
public List<Data_objItem05> data_obj;
///
///
///
public string type;
}
[Serializable]
public class Data05
{
///
///
///
public List<NliItem05> nli;
}
[Serializable]
public class Root05
{
///
///
///
public string status;
///
///
///
public Data05 data;
}
#endregion
#region 搜索模块返回数据 openweb 搜索西瓜
[Serializable]
public class Desc_obj06
{
public string result;
///
///
///
public string type;
///
///
///
public int status;
}
[Serializable]
public class Data_objItem06
{
///
///
///
public string url;
}
[Serializable]
public class NliItem06
{
///
///
///
public Desc_obj06 desc_obj;
///
///
///
public List<Data_objItem06> data_obj;
///
///
public string type;
}
[Serializable]
public class Data06
{
///
///
///
public List<NliItem06> nli;
}
[Serializable]
public class Root06
{
///
///
///
public string status;
///
///
///
public Data06 data;
}
#endregion
#region 股票模块返回数据 stock 中国石油股票
[Serializable]
public class Desc_obj07
{
///
/// 主人,为你找到中国石油的最新股票行情。
///
public string result;
///
///
///
public int status;
}
[Serializable]
public class Data_objItem07
{
///
/// 股票数量
///
public string amount;
///
/// 最低交易
///
public string cur_price;
///
/// 今开
///
public string price_start;
///
/// 意图
///
public string intent;
///
/// 最低
///
public string price_low;
///
/// 变化率
///
public string change_rate;
///
/// 成交量
///
public string volume;
///
/// 变化量
///
public string change_amount;
///
/// 历史
///
public int is_history;
///
/// 昨收
///
public string price_end;
///
/// 股票名称
///
public string name;
///
/// 股票代码
///
public string id;
///
/// 查询时间
///
public string time;
///
/// 最高点
///
public string price_high;
///
/// 受喜爱的
///
public string favorite;
}
[Serializable]
public class NliItem07
{
///
///
///
public Desc_obj07 desc_obj;
///
///
///
public List<Data_objItem07> data_obj;
///
///
///
public string type;
}
[Serializable]
public class Data07
{
///
///
///
public List<NliItem07> nli;
}
[Serializable]
public class Root07
{
///
///
///
public string status;
///
///
///
public Data07 data;
}
#endregion
#region 电视节目模块返回数据 tvprogram 电视节目 CCTV1
[Serializable]
public class Data_objItem08
{
///
///
///
public int highlight;
///
/// 节目名字
///
public string name;
///
/// 播出时间
///
public string time;
}
[Serializable]
public class Desc_obj08
{
///
/// 请问你想要看哪个频道?
///
public string result;
///
///
///
public string type;
///
///
///
public int status;
}
[Serializable]
public class NliItem08
{
///
///
///
public Desc_obj08 desc_obj;
///
///
///
public List<Data_objItem08> data_obj;
///
///
///
public string type;
}
[Serializable]
public class Data08
{
///
///
///
public List<NliItem08> nli;
}
[Serializable]
public class Root08
{
///
///
///
public string status;
///
///
///
public Data08 data;
}
#endregion
#region 天气模块返回数据 weather 上海的天气
[Serializable]
public class Desc_obj09
{
///
/// 上海今天小雨转阴,最高温度33℃,最低温度27℃,南风3-4级。
///
public string result;
///
///
///
public int status;
}
[Serializable]
public class Data_objItem09
{
///
///
///
public int date;
///
///
///
public int weather_end;
///
///
///
public int pm25;
///
/// 上海
///
public string city;
///
///
///
public string temperature_low;
///
///
///
public int weather_start;
///
///
///
public string temperature_high;
///
/// 2021年07月29日,小雨转阴,南风3-4级,最高温度33℃,最低温度27℃。
///
public string description;
///
///
///
public int is_querying;
///
///
///
public int real_date;
///
/// 南风3-4级
///
public string wind;
}
[Serializable]
public class NliItem09
{
///
///
///
public Desc_obj09 desc_obj;
///
///
///
public List<Data_objItem09> data_obj;
///
///
///
public string type;
}
[Serializable]
public class Data09
{
///
///
///
public List<NliItem09> nli;
}
[Serializable]
public class Root09
{
///
///
///
public string status;
///
///
///
public Data09 data;
}
#endregion
#region 诗集选择模块 poem selection 水调歌头 苏轼
[Serializable]
public class Desc_obj10
{
///
/// 有下面这些诗文,请从中选出一个,我来读
///
public string result;
///
///
///
public string type;
///
///
///
public int status;
}
[Serializable]
public class Data_objItem10
{
///
/// 水调歌头
///
public string poem_name;
///
/// 苏轼
///
public string author;
}
[Serializable]
public class NliItem10
{
///
///
///
public Desc_obj10 desc_obj;
///
///
///
public List<Data_objItem10> data_obj;
///
///
///
public string type;
}
[Serializable]
public class Data10
{
///
///
///
public List<NliItem10> nli;
}
[Serializable]
public class Root10
{
///
///
///
public string status;
///
///
///
public Data10 data;
}
#endregion
#region 菜肴选择模块 cooking selection 蛋糕怎么做
[Serializable]
public class Desc_obj11
{
///
/// 主人,为你精选了一些。你可以说:第几个,或者直接点击查看详情。
///
public string result;
///
///
///
public string type;
///
///
///
public int status;
}
[Serializable]
public class Data_objItem11
{
///
/// 烤蛋糕
///
public string name;
}
[Serializable]
public class NliItem11
{
///
///
///
public Desc_obj11 desc_obj;
///
///
///
public List<Data_objItem11> data_obj;
///
///
///
public string type;
}
[Serializable]
public class Data11
{
///
///
///
public List<NliItem11> nli;
}
[Serializable]
public class Root11
{
///
///
///
public string status;
///
///
///
public Data11 data;
}
#endregion
#region 酒店选择模块 hotel 预定酒店
[Serializable]
public class Desc_obj12
{
///
/// 主人,有以下酒店可以预订。你可以说:第几个,或者直接点击查看详情。
///
public string result;
///
///
///
public string type;
///
///
///
public int status;
}
[Serializable]
public class Data_objItem12
{
///
/// 酒店形象
///
public string hotel_image;
///
/// 平均价格
///
public string max_price;
///
/// 酒店网站
///
public string description_url;
///
/// 携程评级
///
public string ctrip_rating;
///
/// 酒店描述
///
public string description;
///
/// 酒店地址
///
public string hotel_address;
///
/// 最低价格
///
public string floor_price;
///
/// 酒店名字
///
public string hotel_name;
///
/// 用户评级
///
public string user_rating;
}
[Serializable]
public class NliItem12
{
///
///
///
public Desc_obj12 desc_obj;
///
///
///
public List<Data_objItem12> data_obj;
///
///
///
public string type;
}
[Serializable]
public class Data12
{
///
///
///
public List<NliItem12> nli;
}
[Serializable]
public class Root12
{
///
///
///
public string status;
///
///
///
public Data12 data;
}
#endregion
#region 诗集模块 poem 我要听长恨歌
[Serializable]
public class Desc_obj13
{
///
/// 明月几时有,把酒问青天。不知天上宫阙,今夕是何年?我欲乘风归去,又恐琼楼玉宇,高处不胜寒。起舞弄清影,何似在人间!转朱阁,低绮户,照无眠。不应有恨,何事长向别时圆?人有悲欢离合,月有阴晴圆缺,此事古难全。但愿人长久,千里共婵娟。
///
public string result;
///
///
///
public int status;
}
[Serializable]
public class Data_objItem13
{
///
/// 苏轼
///
public string author;
///
/// 水调歌头
///
public string title;
///
/// 明月几时有,把酒问青天。不知天上宫阙,今夕是何年?我欲乘风归去,又恐琼楼玉宇,高处不胜寒。起舞弄清影,何似在人间!转朱阁,低绮户,照无眠。不应有恨,何事长向别时圆?人有悲欢离合,月有阴晴圆缺,此事古难全。但愿人长久,千里共婵娟。
///
public string content;
}
[Serializable]
public class NliItem13
{
///
///
///
public Desc_obj13 desc_obj;
///
///
///
public List<Data_objItem13> data_obj;
///
///
///
public string type;
}
[Serializable]
public class Data13
{
///
///
///
public List<NliItem13> nli;
}
[Serializable]
public class Root13
{
///
///
///
public string status;
///
///
///
public Data13 data;
}
#endregion
//#region 欧拉密返回Json数据
{"status":"ok","data":{"nli":[{"desc_obj":{"result":"打开空调就好了。","status":0},"type":"nonsense"}]}}
//#endregion
}
基础运行
支持多轮对话
实时传输语音数据 并播放
暂时先这样吧,如果有时间的话就会更新,实在看不明白就留言,看到我会回复的。
路漫漫其修远兮,与君共勉。