diff --git a/README.md b/README.md index b0ecf7d..3f6d508 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,5 @@ AIUI demo code 国内用户可从 https://gitee.com/xiaosumay/DemoCode 镜像处下载 + +相关文档可查阅 https://democode.readthedocs.io/zh_CN/latest/ diff --git a/aiui/c-sharp/aiui_csharp_demo/IAIUIEvent.cs b/aiui/c-sharp/aiui_csharp_demo/IAIUIEvent.cs index 7212f8d..8a2e6a4 100644 --- a/aiui/c-sharp/aiui_csharp_demo/IAIUIEvent.cs +++ b/aiui/c-sharp/aiui_csharp_demo/IAIUIEvent.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.InteropServices; +using System.Text; namespace aiui { @@ -32,8 +33,15 @@ public int GetArg2() public string GetInfo() { IntPtr temp = aiui_event_info(mEvent); - string info = Marshal.PtrToStringAnsi(temp).ToString(); + int len = aiui_strlen(temp); + + byte[] managedArray = new byte[len]; + Marshal.Copy(temp, managedArray, 0, len); + + string info = Encoding.UTF8.GetString(managedArray); + temp = IntPtr.Zero; + managedArray = null; return info; } @@ -63,5 +71,8 @@ public IDataBundle GetData() [DllImport("aiui", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] private static extern IntPtr aiui_event_databundle(IntPtr ev); + + [DllImport("aiui", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + private static extern int aiui_strlen(IntPtr str); } } diff --git a/aiui/c-sharp/aiui_csharp_demo/IDataBundle.cs b/aiui/c-sharp/aiui_csharp_demo/IDataBundle.cs index e5253a5..f309d06 100644 --- a/aiui/c-sharp/aiui_csharp_demo/IDataBundle.cs +++ b/aiui/c-sharp/aiui_csharp_demo/IDataBundle.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.InteropServices; +using System.Text; namespace aiui { @@ -19,9 +20,36 @@ public int GetInt(string key, int defVal) public string GetString(string key, string defVal) { - IntPtr tmp = aiui_db_string(mDataBundle, Marshal.StringToHGlobalAnsi(key), Marshal.StringToHGlobalAnsi(defVal)); + IntPtr temp = aiui_db_string(mDataBundle, Marshal.StringToHGlobalAnsi(key), Marshal.StringToHGlobalAnsi(defVal)); - return Marshal.PtrToStringAnsi(tmp); + int len = aiui_strlen(temp); + + byte[] managedArray = new byte[len]; + Marshal.Copy(temp, managedArray, 0, len); + + string info = Encoding.UTF8.GetString(managedArray); + + temp = IntPtr.Zero; + + return info; + } + + public string GetBinaryStr(string key) + { + int len = 0; + IntPtr tmp = aiui_db_binary(mDataBundle, Marshal.StringToHGlobalAnsi(key), ref len); + + if (len == 0) return null; + + byte[] managedArray = new byte[len - 1]; + Marshal.Copy(tmp, managedArray, 0, len - 1); + + string info = Encoding.UTF8.GetString(managedArray); + + tmp = IntPtr.Zero; + managedArray = null; + + return info; } public byte[] GetBinary(string key, ref int len) @@ -47,5 +75,8 @@ public byte[] GetBinary(string key, ref int len) [DllImport("aiui", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] private static extern IntPtr aiui_db_binary(IntPtr db, IntPtr key, ref int len); + + [DllImport("aiui", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + private static extern int aiui_strlen(IntPtr str); } } diff --git a/aiui/c-sharp/aiui_csharp_demo/Program.cs b/aiui/c-sharp/aiui_csharp_demo/Program.cs index 1ef212b..513d726 100644 --- a/aiui/c-sharp/aiui_csharp_demo/Program.cs +++ b/aiui/c-sharp/aiui_csharp_demo/Program.cs @@ -74,8 +74,9 @@ private static void onEvent(IAIUIEvent ev) case AIUIConstant.EVENT_RESULT: { + var info = JsonConvert.DeserializeObject>(ev.GetInfo()); - + var datas = info["data"] as JArray; var data = datas[0] as JObject; var param = data["params"] as JObject; @@ -84,25 +85,21 @@ private static void onEvent(IAIUIEvent ev) string sub = param["sub"].ToString(); - if (sub == "nlp" || sub == "iat" || sub == "tts" || sub == "asr") + if (sub == "nlp" || sub == "iat" || sub== "tts" || sub == "asr") { Console.WriteLine("info: {0}", ev.GetInfo()); string cnt_id = content["cnt_id"].ToString(); - int dataLen = 0; - byte[] buffer = ev.GetData().GetBinary(cnt_id, ref dataLen); if (sub != "tts") { - if (dataLen != 0) + string resultStr = ev.GetData().GetBinaryStr(cnt_id); + + if (resultStr != null) { - string resultStr = Encoding.UTF8.GetString(buffer); Console.WriteLine("resultStr: {0}", resultStr); - resultStr = null; } } - - buffer = null; } datas = null; @@ -151,6 +148,8 @@ public static string GetMac() static void Main(string[] args) { + Console.OutputEncoding = System.Text.Encoding.GetEncoding("GBK"); + string version = IAIUIAgent.Version(); Console.WriteLine("aiui version is {0}", version); @@ -225,11 +224,14 @@ static void Main(string[] args) msg_write_audio = null; buf_1 = null; - pcm.Position += count; - Thread.Sleep(40); } + IAIUIMessage msg_stop_write_audio = IAIUIMessage.Create(AIUIConstant.CMD_STOP_WRITE, 0, 0, "data_type=audio", IBuffer.Zero); + agent.SendMessage(msg_stop_write_audio); + msg_stop_write_audio.Destroy(); + msg_stop_write_audio = null; + Console.WriteLine("finished!"); pcm.Position = 0; diff --git a/aiui/c-sharp/aiui_csharp_demo/aiui_csharp_demo.csproj b/aiui/c-sharp/aiui_csharp_demo/aiui_csharp_demo.csproj index 3a623ae..fd90a2c 100644 --- a/aiui/c-sharp/aiui_csharp_demo/aiui_csharp_demo.csproj +++ b/aiui/c-sharp/aiui_csharp_demo/aiui_csharp_demo.csproj @@ -13,6 +13,7 @@ true false + ..\..\..\ publish\ true Disk @@ -27,7 +28,6 @@ 1.0.0.%2a false true - ..\..\..\ AnyCPU @@ -39,7 +39,7 @@ prompt 4 false - ..\..\..\ + ..\..\..\ AnyCPU @@ -50,7 +50,7 @@ prompt 4 false - ..\..\..\ + ..\..\..\ true @@ -62,7 +62,7 @@ MinimumRecommendedRules.ruleset true false - ..\..\..\ + ..\..\..\ bin\x64\Release\ @@ -73,7 +73,7 @@ prompt MinimumRecommendedRules.ruleset false - ..\..\..\ + ..\..\..\ aiui_csharp_demo.Program @@ -88,7 +88,7 @@ prompt MinimumRecommendedRules.ruleset false - ..\..\..\ + ..\..\..\ bin\x86\Release\ @@ -100,13 +100,13 @@ prompt MinimumRecommendedRules.ruleset false - ..\..\..\ + ..\..\..\ true - + ..\packages\Newtonsoft.Json.13.0.1\lib\net20\Newtonsoft.Json.dll diff --git a/aiui/c/AIUI/cfg/aiui.cfg b/aiui/c/AIUI/cfg/aiui.cfg index 75151b1..cfc4c15 100644 --- a/aiui/c/AIUI/cfg/aiui.cfg +++ b/aiui/c/AIUI/cfg/aiui.cfg @@ -36,7 +36,7 @@ "log": { "debug_log": "1", "save_datalog": "0", - "datalog_path": ".", + "datalog_path": "", "datalog_size": 1024, "raw_audio_path": "" } diff --git a/docs/_static/change_filter_new.png b/docs/_static/change_filter_new.png new file mode 100644 index 0000000..3b154d1 Binary files /dev/null and b/docs/_static/change_filter_new.png differ diff --git a/docs/_static/change_filter_old.png b/docs/_static/change_filter_old.png new file mode 100644 index 0000000..fcee745 Binary files /dev/null and b/docs/_static/change_filter_old.png differ diff --git a/docs/_static/change_mic_type.png b/docs/_static/change_mic_type.png new file mode 100644 index 0000000..72221d8 Binary files /dev/null and b/docs/_static/change_mic_type.png differ diff --git a/docs/_static/change_record.png b/docs/_static/change_record.png new file mode 100644 index 0000000..aeff651 Binary files /dev/null and b/docs/_static/change_record.png differ diff --git a/docs/_static/download_sdk.png b/docs/_static/download_sdk.png new file mode 100644 index 0000000..cc6ba5f Binary files /dev/null and b/docs/_static/download_sdk.png differ diff --git a/docs/_static/open_sad_vad.png b/docs/_static/open_sad_vad.png new file mode 100644 index 0000000..428f45e Binary files /dev/null and b/docs/_static/open_sad_vad.png differ diff --git a/docs/_static/sad_vad_setting.png b/docs/_static/sad_vad_setting.png new file mode 100644 index 0000000..ed670c1 Binary files /dev/null and b/docs/_static/sad_vad_setting.png differ diff --git a/docs/_static/turing_setting.png b/docs/_static/turing_setting.png new file mode 100644 index 0000000..053b9b7 Binary files /dev/null and b/docs/_static/turing_setting.png differ diff --git a/docs/conf.py b/docs/conf.py index 0eeca1c..853b581 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -140,7 +140,7 @@ html_static_path = ['_static'] def setup(app): - app.add_css_file("aiui.css") + app.add_css_file("aiui.css") # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied @@ -192,7 +192,7 @@ def setup(app): # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -#html_search_language = 'en' +html_search_language = 'zh_CN' # A dictionary with options for the search language support, empty by default. # Now only 'ja' uses this config value @@ -209,7 +209,7 @@ def setup(app): latex_elements = { # The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', + 'papersize': 'a4paper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', diff --git a/docs/index.rst b/docs/index.rst index d31a404..4298b6e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -8,6 +8,7 @@ AIUI语音SDK集成文档 .. toctree:: :maxdepth: 2 - :glob: - src/* + src/index.rst + src/error_code.rst + src/engines.rst diff --git a/docs/src/engines.rst b/docs/src/engines.rst new file mode 100644 index 0000000..c2df934 --- /dev/null +++ b/docs/src/engines.rst @@ -0,0 +1,8 @@ +其他功能启用说明 +############################# + +.. toctree:: + :maxdepth: 1 + :glob: + + engines/* \ No newline at end of file diff --git a/docs/src/engines/multi_vtn.rst b/docs/src/engines/multi_vtn.rst new file mode 100644 index 0000000..44b2a8a --- /dev/null +++ b/docs/src/engines/multi_vtn.rst @@ -0,0 +1,40 @@ +AIUI接VTN多麦降噪引擎 +############################# + +1. 登录 https://aiui.xfyun.cn/ 平台,下载相应平台的sdk,此功能在 5.6.1069.1001 版本以上,之前版本的需重新下载sdk版本,以Windows为例 + +.. image:: ../../_static/download_sdk.png + +2. 文件结构如下 + +.. code-block:: bash + + ├── include + ├── libs + │ ├── x64 + │ └── x86 + ├── README.md + └── samples + ├── AIUI + ├── aiui_sample + ├── samples.sln + + +3. 修改 AIUI内配置参数 路径为:samples\AIUI\cfg\aiui.cfg (以线性4麦为参考) +1. 修改mic_type为mic4 + +.. image:: ../../_static/change_mic_type.png + +2. 修改wakeup_mode为 vtn,audio_captor为portaudio + +.. image:: ../../_static/change_record.png + +3. 修改channel_count和channel_filter (鱼亮科技提供的usb录音板为参考) + +.. image:: ../../_static/change_filter_old.png + +改为以下 + +.. image:: ../../_static/change_filter_new.png + +4. 将提供的库 vtn_mic4.dll (以线性4麦为参考)放置与aiui.dll同级 diff --git a/docs/src/engines/open_vad.rst b/docs/src/engines/open_vad.rst new file mode 100644 index 0000000..db912fa --- /dev/null +++ b/docs/src/engines/open_vad.rst @@ -0,0 +1,25 @@ +开启语义VAD +############################# + +1. 平台设置 +============================= + + 1.1. 在 aiui.xfyun.cn 平台 **我的应用** → **应用配置** → **语义理解** → **开启语义VAD** + +.. image:: ../../_static/open_sad_vad.png + +1.2 点击保存。(语义VAD 开启需要一定的时间,接下端上的操作请等候一两分钟)。 + +2. 端侧设置 +============================= + +2.1 在端上的SDK配置文件 aiui.cfg 中的vad 配置段添加一下内容 + + - vad_eos 这是本地的VAD后端点时长, 默认云端是 1.8s,所以本地可以设置为2s + - cloud_vad_info 接收云端VAD尾端点的配置 + +2.2 最终如下图所示: + +.. image:: ../../_static/sad_vad_setting.png + +2.3 不用做其他处理,正常交互即可。 \ No newline at end of file diff --git a/docs/src/engines/remote_wakeup.rst b/docs/src/engines/remote_wakeup.rst new file mode 100644 index 0000000..26d4096 --- /dev/null +++ b/docs/src/engines/remote_wakeup.rst @@ -0,0 +1,84 @@ +AIUI免唤醒方案 +############################# + + +免唤醒语音交互说明 +=================== + +免唤醒语音交互方案,利用讯飞唤醒引擎技术,让产品在离线场景下也可以交互,且能够做到直接说话就可以实现人机交互的效果。同时,需要在线交互时候也可以调用云端能力。 + +唤醒词作为离线命令,毫秒级响应速度可给用户带来酣畅的控制体验; 唤醒词直接打通云端语义结合使用,可以实现直接点播内容,同时有效地降低控制类命令的误触发。 + + +免唤醒支持的类型 +================= + +唤醒词支持以下几种用法,Demo示例的唤醒词说法配置见`电视远场免唤醒资源.xlsx` + + +普通唤醒类 +================= + +1) 同以往唤醒词效果:唤醒后,音频送云端语义理解。 + +2) 例如唤醒词是“小飞小飞”,用户说“小飞小飞,刘德华的冰雨”,小飞小飞唤醒机器,开始录音。“刘德华的冰雨”送云端来做识别和机器理解。 + + + +离线命令词 +================= + +1) 用户说出命令词后,端上获取命令词拼音信息,直接处理;如“声音大一点”“打开空调”; + +2) 该命令词属离线交互,音频不送云端,不会消耗云端交互; + + +云端命令词 +================= + +1. 该类唤醒词法命中后,会将唤醒词前1.5S的音频和唤醒词音频一起送入云端做识别和机器理解。如词是“暂停”,用户说“帮我暂停”,会将“帮 我+暂停”的音频一起送到云端。 + +2. 该类词结和云端语义一起使用,可以拓展更多的说法,满足用户随意控制。 + +3. 建议您将对体验影响较大的词语,如“切歌”、“暂停”、“下一首”等词语做成向前取音频的说法。这样当用户说“切歌”、“我要切歌”、 “帮我切歌”均可以使用云端语义技能来理解出用户真实意图是“切歌”。而唱歌的过程中出现了切歌两个字,则不会真正的触发“切歌”,这样能 够消除误触发对唱歌的影响。 + +4. 用法: 与云端语义结合:在AIUI技能工作室写一个与该类词相关的技能,配置到应用下。在语义理解为RC0的时候,端上响应对应意图,RC4不用响 应。 技能的语料结尾为该类词。如“我要切歌”,“切歌”。这样用户说与切歌相关的句子均可以被正常理解。 + + + +免唤醒入口词 +================= + +1. 该类唤醒词法命中后,会将唤醒词音频+唤醒后的音频送入云端识别,满足歌曲点播服务。如词是“来一首”,用户可以直接说“来一首刘德华的忘 情水”,我们会将“来一首+刘德华的忘情水“一起送云端,满足用户直接说就可以点歌。 + +2. 你在AIUI应用配置的商店技能里,可以直接添加讯飞的”音乐“技能,这样直接说就可以点个了。音乐技能讯飞会定期维护更新曲库和歌手。 + + +接入使用 +================= + +具体配置可以参考下面配置文件中的资源类型和资源路径的配置。 + +``aiui.cfg`` 中增加免唤醒词配置: + + +.. code-block:: json + + "speech":{ + "data_source":"user", + //配置AIUI内部录音方式,可选system(系统录音,AudioRecord),portaudio (录音) + "audio_captor": "system", + //配置AIUI内部使用的唤醒方式,可选配置vtn,off(关闭唤醒) + "wakeup_mode":"vtn", + "interact_mode":"oneshot", + "intent_engine_type":"cloud" + }, + "ivw":{ + //配置加载使用环形6mic免唤醒Vtn库 + "mic_type": "mic1", + //开启免唤醒 + "zeroshot_enable": "1", + "res_type":"path", + //免唤醒词资源及vtn引擎唤醒配置 + "res_path":"vtn/tv/res.bin;vtn/tv/hlw.cfg" + } diff --git a/docs/src/engines/turing.rst b/docs/src/engines/turing.rst new file mode 100644 index 0000000..3eb26f3 --- /dev/null +++ b/docs/src/engines/turing.rst @@ -0,0 +1,64 @@ +私有化Turing 接入指南 +############################# + +1. 简要说明,为了更好支持开发者快速的从AIUI公有云切换到私有化Turing。SDK内部做了大量的转换。私有化Turing的调用方式,接口等都与公有云AIUI保持一致。以下仅对不同的地方做下解释。 +2. 配置变化(仅Turing使用,红色字段为必填,其他可选) + + +1. 新增 turing_ssb 字段 + +========== ============================ ======================== + 字段名 取值 备注 +========== ============================ ======================== +turing_url ws://xxxxxxxxxxxxx/createRec 私有化部署地址 +---------- ---------------------------- ------------------------ +scheduler iat,nlp,tts 需要调用的能力,默认为空 +========== ============================ ======================== + +2. login 字段 + +========= ==== ====== + 字段名 取值 备注 +========= ==== ====== +client_id "" 设备id +========= ==== ====== + +3. iat 字段 + +=============== ==== ====================================== + 字段名 取值 备注 +=============== ==== ====================================== +iat.serviceName iat 默认为空,若有方言需求,可能为iat_en等 +--------------- ---- -------------------------------------- +iat.dwa pgs 是否开启流式识别 +--------------- ---- -------------------------------------- +iat.hotword "" 会话级热词 +=============== ==== ====================================== + +4. nlp 字段 + +=============== ========= ================ + 字段名 取值 备注 +=============== ========= ================ +sceneKey xxxxxxxxx 云端语义的场景名 +--------------- --------- ---------------- +nlp.serviceName nlp 默认为空 +=============== ========= ================ + +5. tts 字段 + +==================== ==== ======== + 字段名 取值 备注 +==================== ==== ======== +tts.speed 0 -500~500 +-------------------- ---- -------- +tts.volume 0 -20~20 +-------------------- ---- -------- +ts.native_voice_name "" 发言人 +==================== ==== ======== + +具体如下图, + +6. 结果解析(具体从接收到的数据) + +.. image:: ../../_static/turing_setting.png diff --git a/docs/src/error_code.rst b/docs/src/error_code.rst index 371f8d5..1933553 100644 --- a/docs/src/error_code.rst +++ b/docs/src/error_code.rst @@ -45,7 +45,7 @@ MSP_ERROR_TIME_OUT 10114 ---------------------------------------- ----- --------------------------------------- MSP_ERROR_OPEN_FILE 10115 ---------------------------------------- ----- --------------------------------------- -MSP_ERROR_NOT_FOUND 10116 +MSP_ERROR_NOT_FOUND 10116 资源路径错误,资源未找到 ---------------------------------------- ----- --------------------------------------- MSP_ERROR_NO_ENOUGH_BUFFER 10117 ---------------------------------------- ----- --------------------------------------- @@ -1087,4 +1087,111 @@ VPR_AUDIO_RECS_OVER_LIMIT 600519 待训练的音频以及超出需要的条 VPR_NOT_START_TRAIN 600520 未启动声纹训练 -------------------------- ------ ---------------------------------------- VPR_FUNC_NOT_INIT 600521 没有初始化训练引擎 -========================== ====== ======================================== \ No newline at end of file +========================== ====== ======================================== + +***************************** +3. 语音端点检测 EVAD +***************************** + + +========================================== ===== ================================== + 名称 值 说明 +========================================== ===== ================================== +VAD_ERROR_GENERAL 10001 EVad创建失败 +------------------------------------------ ----- ---------------------------------- +VAD_ERROR_ALREADY_INIT 10002 EVad实例已经存在 +------------------------------------------ ----- ---------------------------------- +VAD_ERROR_NOT_INIT 10003 EVad没有初始化 +------------------------------------------ ----- ---------------------------------- +VAD_ERROR_ALREADY_START 10004 EVad已经处在工作状态中 +------------------------------------------ ----- ---------------------------------- +VAD_ERROR_NOT_START 10005 EVad没有在工作,需调用start接口 +------------------------------------------ ----- ---------------------------------- +VAD_ERROR_INVALID_PARA 10006 提供的参数key无效 +------------------------------------------ ----- ---------------------------------- +VAD_ERROR_INVALID_PARA_VALUE 10006 提供的参数数值无效 +------------------------------------------ ----- ---------------------------------- +VAD_ERROR_NULL_HANDLE 10007 EVad没的句柄为空 +------------------------------------------ ----- ---------------------------------- +VAD_ERROR_INVALID_HANDLE 10008 传入到EVad中的句柄无效 +------------------------------------------ ----- ---------------------------------- +VAD_ERROR_NO_ENOUGH_BUFFER 10009 获取内存失败 +------------------------------------------ ----- ---------------------------------- +VAD_ERROR_CONTINUE_WRITE_REDAD_WHEN_FINISH 10010 EVad已停止工作,写数据无效 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_RESOURCE_NOT_EXIST 20001 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_RESOURCE_ALREADY_EXIST 20002 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_LOAD_FILE 20003 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_INVALID_PARA 20003 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_INVALID_PARA_VALUE 20004 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_FILE_MAPPING_EXCEPTION 20005 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_NULL_HANDLE 20007 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_DONNT_SUPPORT 20008 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_LOAD_LIBRARY 20009 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_RESOURCE_TOO_OLD 20010 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_RESOURCE_ADD 20011 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_RESOURCE_DELETE 20012 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_MD5MATCH_DATA 20013 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_RES_TYPE 20014 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_BUILD_WFST_FAILED 20015 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_RES_DAMAGED 20016 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_WRITE_LOCK_FAIL 20017 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_READ_LOCK_FAIL 20018 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_UPDATE_FAIL 20019 +------------------------------------------ ----- ---------------------------------- +RES_MGR_ERROR_SAVE_FAIL 20020 +------------------------------------------ ----- ---------------------------------- +PTR_IS_NULL 50000 +------------------------------------------ ----- ---------------------------------- +PARAM_STRUCT_SIZE_ERROR 50001 参数格式不对 +------------------------------------------ ----- ---------------------------------- +RES_FORMAT_ERROR 60001 资源格式不对,读取了非资源文件 +------------------------------------------ ----- ---------------------------------- +RES_SIZE_ERROR 60002 资源的长度不对 +------------------------------------------ ----- ---------------------------------- +WRITE_DATA_FAILE 60003 写数据失败 +------------------------------------------ ----- ---------------------------------- +READ_STATUS_FAILE 60004 读数据失败 +------------------------------------------ ----- ---------------------------------- +APPID_NOT_FOUND 70000 缺少appid参数 +------------------------------------------ ----- ---------------------------------- +APPID_NOT_MATCHED 70001 appid与资源中不匹配 +------------------------------------------ ----- ---------------------------------- +SN_NOT_FOUND 70002 缺少sn参数 +------------------------------------------ ----- ---------------------------------- +SN_FORMAT_ERROR 70003 sn格式不对,必须可见字符且小于64位 +------------------------------------------ ----- ---------------------------------- +AUTHOR_CODE_NO_AUTHOR 80001 当前应用无授权 +------------------------------------------ ----- ---------------------------------- +AUTHOR_CODE_OUT_LIMIT 80002 应用总授权超限 +------------------------------------------ ----- ---------------------------------- +AUTHOR_CODE_OUT_FRESH 80003 当前设备刷机次数超限 +------------------------------------------ ----- ---------------------------------- +AUTHOR_CODE_AUTHOR_DISABLE 80004 当前设备或应用授权已被禁止使用 +------------------------------------------ ----- ---------------------------------- +AUTHOR_CODE_PARAM_ERR 80005 设备参数异常或丢失 +------------------------------------------ ----- ---------------------------------- +AUTHOR_CODE_PARSE_ERR 80006 数据解析失败,秘钥不匹配 +------------------------------------------ ----- ---------------------------------- +AUTHOR_CODE_STREAM_LIMIT 80007 服务流控限制,请退避重试 +------------------------------------------ ----- ---------------------------------- +AUTHOR_CODE_NO_NETWORK 80008 无法访问授权服务 +========================================== ===== ================================== \ No newline at end of file diff --git a/docs/src/index.rst b/docs/src/index.rst index cbed00c..c638dfa 100644 --- a/docs/src/index.rst +++ b/docs/src/index.rst @@ -148,7 +148,7 @@ AIUI集成了众多能力,一般不可能全部都用得上,可以通过配 ent [#f2]_ * string xtts 否 设置离线TTS引擎,默认为 ``msc`` local_engine string cloud 是 切换离在线, ``local`` 为离线, ``cloud`` 为在线 res_type string path 否 ``assets`` 仅android使用,资源放在apk包中, ``path`` 为系统资源路径 - res_path string AIUI/xtts/xiaoxue.jet 是 设置离线引擎所需要的资源路径,可为AIUI工作路径的相对路径 + res_path string common.jet;xiaoxue.jet 是 设置离线引擎所需要的资源路径,多个资源以 ``;`` 分割 voice_name string xiaoxue 是 设置合成发言人 volume string "100" 否 设置合成音量 =========================== ======== ======================== ====== ================================== @@ -183,6 +183,8 @@ AIUI集成了众多能力,一般不可能全部都用得上,可以通过配 | | | | | | | | | }] | | | +------------+-------+----------------------------------+-----+--------------------------------------------------------------------------------+ + |threshold |string | "5000" | 否 | 置信度,和结果中的 ``score`` 对比,需要多次测试得出 | + +------------+-------+----------------------------------+-----+--------------------------------------------------------------------------------+ .. tip:: 线上版本不支持离线识别,如需请联系我司商务开通相关权限 @@ -438,7 +440,7 @@ STATE_WORKING **工作状态** 具体的转换关系如下图所示: -.. image::_static/screenshot_1519613427018.4507411a.png +.. image::../_static/screenshot_1519613427018.4507411a.png ============ ======== 操作名称 说明 diff --git a/websocket/c-sharp/aiui_ws_csharp_demo/Program.cs b/websocket/c-sharp/aiui_ws_csharp_demo/Program.cs index 5e437de..16c78a5 100644 --- a/websocket/c-sharp/aiui_ws_csharp_demo/Program.cs +++ b/websocket/c-sharp/aiui_ws_csharp_demo/Program.cs @@ -169,8 +169,6 @@ private void on_open(object sender, EventArgs e) while ((count = pcm.Read(buffur, 0, 1280)) != 0) { server.Send(buffur); - pcm.Position += count; - Thread.Sleep(40); } diff --git a/websocket/java/src/com/iflytek/aiui/websocketdemo/AiuiWsDemo.java b/websocket/java/src/com/iflytek/aiui/websocketdemo/AiuiWsDemo.java index f776054..24a1107 100644 --- a/websocket/java/src/com/iflytek/aiui/websocketdemo/AiuiWsDemo.java +++ b/websocket/java/src/com/iflytek/aiui/websocketdemo/AiuiWsDemo.java @@ -2,12 +2,15 @@ import java.io.RandomAccessFile; import java.io.UnsupportedEncodingException; +import java.net.NetworkInterface; +import java.net.SocketException; import java.net.URI; import java.nio.ByteBuffer; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; import java.util.Date; +import java.util.Enumeration; import java.util.concurrent.CountDownLatch; import org.apache.commons.codec.binary.Base64; @@ -39,7 +42,7 @@ public class AiuiWsDemo { // 结束数据发送标记(必传) private static final String END_FLAG = "--end--"; // 配置参数 - private static final String param = "{\"result_level\":\"plain\",\"auth_id\":\"894c985bf8b1111c6728db79d3479aef\",\"data_type\":\"audio\",\"aue\":\"raw\",\"scene\":\"main\",\"sample_rate\":\"16000\"}"; + private static final String param = "{\"result_level\":\"plain\",\"auth_id\":\"" + getLocalMac() +"\",\"data_type\":\"audio\",\"aue\":\"raw\",\"scene\":\"main_box\",\"sample_rate\":\"16000\"}"; // main()方法,直接运行,控制台输出服务端结果 public static void main(String[] args) throws Exception { @@ -48,10 +51,11 @@ public static void main(String[] args) throws Exception { CountDownLatch countDownLatch = new CountDownLatch(1); MyWebSocketClient client = new MyWebSocketClient(url, draft, countDownLatch); client.connect(); + while (!client.getReadyState().equals(READYSTATE.OPEN)) { - System.out.println("连接中"); - Thread.sleep(1000); + Thread.sleep(50); } + // 发送音频 byte[] bytes = new byte[CHUNCKED_SIZE]; try (RandomAccessFile raf = new RandomAccessFile(FILE_PATH, "r")) { @@ -147,4 +151,31 @@ private static String getSHA256Str(String str) { } return encdeStr; } + + private static String getLocalMac() { + StringBuilder sb = new StringBuilder(); + Enumeration allNetInterfaces = null; + + try { + allNetInterfaces = NetworkInterface.getNetworkInterfaces(); + byte[] mac = null; + while (allNetInterfaces.hasMoreElements()) { + NetworkInterface netInterface = allNetInterfaces.nextElement(); + if (netInterface.isLoopback() || netInterface.isVirtual() || netInterface.isPointToPoint() || !netInterface.isUp()) { + continue; + } else { + mac = netInterface.getHardwareAddress(); + if (mac != null) { + for (int i = 0; i < mac.length; i++) { + sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : "\n")); + } + } + } + } + } catch (SocketException e) { + e.printStackTrace(); + } + + return DigestUtils.md5DigestAsHex(sb.toString().getBytes(StandardCharsets.UTF_8)); + } } \ No newline at end of file