Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
df5662a
修复: c# 由于函数签名不一致导致的崩溃问题
Aug 11, 2021
88bd80b
Merge pull request #1 from IflytekAIUI/master
zrmei Aug 11, 2021
28213b3
更新python demo, 添加origin
Oct 7, 2021
5ebf883
Merge branch 'IflytekAIUI:master' into master
zrmei Dec 1, 2021
c23fb8d
增加销毁操作
Dec 9, 2021
d637e50
修复 内存泄漏
Dec 30, 2021
c6fe64e
新增java调用示例
Mar 10, 2022
ea5f960
fix: c# 生成authid
Mar 18, 2022
68a6742
new: 添加aiui-sdk文档
Apr 11, 2022
74a8d7f
docs: 消息发送
Apr 21, 2022
038fe3a
docs: 命令发送
Apr 29, 2022
617bc23
docs: 字段名修改
May 4, 2022
366107e
更新 python
Jun 13, 2022
3469386
更新 python
Jun 15, 2022
fbe4282
更新 python 说明
Jun 15, 2022
db77699
更新 csharp 代码
Jun 15, 2022
553afca
更新 java
Jun 15, 2022
96ee311
fix nodejs
Jun 20, 2022
b7ad1dd
fix js 依赖
Jun 20, 2022
e7bdbd4
py websocket添加tts字段
Jun 21, 2022
f9ea845
fix: c
Jun 23, 2022
f8bba84
fix: doc 段落
Jul 1, 2022
403c75e
更新字段
Jul 12, 2022
8cdcfd5
fix: 设备唯一id
Jul 12, 2022
9f2bc71
new: 新增错误码
Jul 12, 2022
4e6c453
Merge branch 'IflytekAIUI:master' into master
zrmei Jul 13, 2022
bed39eb
fix: c# Read自带偏移
Jul 20, 2022
ac40c44
新增:语音端点检测EVad错误码
Jul 22, 2022
4635015
fix: java 示例 auth id
Jul 26, 2022
9c9b421
new: 补充文档
Jul 27, 2022
ae50512
fix: aiui cfg
Jul 27, 2022
bdf723a
fix: C# 音频读取问题
Aug 8, 2022
313e0fe
fix: c#编码问题
Aug 9, 2022
08d4609
更新文档说明
Aug 12, 2022
947eaf0
fix: 免唤醒默认配置
Aug 12, 2022
f45a556
修复文档描述
Sep 6, 2022
33d4c12
fix: 错误码说明
Sep 8, 2022
7e5b89f
fix: esr参数
Oct 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
AIUI demo code

国内用户可从 https://gitee.com/xiaosumay/DemoCode 镜像处下载

相关文档可查阅 https://democode.readthedocs.io/zh_CN/latest/
13 changes: 12 additions & 1 deletion aiui/c-sharp/aiui_csharp_demo/IAIUIEvent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Text;

namespace aiui
{
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
}
35 changes: 33 additions & 2 deletions aiui/c-sharp/aiui_csharp_demo/IDataBundle.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Text;

namespace aiui
{
Expand All @@ -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)
Expand All @@ -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);
}
}
24 changes: 13 additions & 11 deletions aiui/c-sharp/aiui_csharp_demo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ private static void onEvent(IAIUIEvent ev)

case AIUIConstant.EVENT_RESULT:
{

var info = JsonConvert.DeserializeObject<Dictionary<object, object>>(ev.GetInfo());

var datas = info["data"] as JArray;
var data = datas[0] as JObject;
var param = data["params"] as JObject;
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;

Expand Down
16 changes: 8 additions & 8 deletions aiui/c-sharp/aiui_csharp_demo/aiui_csharp_demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile />
<StartWorkingDirectory>..\..\..\</StartWorkingDirectory>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -27,7 +28,6 @@
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<StartWorkingDirectory>..\..\..\</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -39,7 +39,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<StartWorkingDirectory>..\..\..\</StartWorkingDirectory>
<StartWorkingDirectory>..\..\..\</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -50,7 +50,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<StartWorkingDirectory>..\..\..\</StartWorkingDirectory>
<StartWorkingDirectory>..\..\..\</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -62,7 +62,7 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
<StartWorkingDirectory>..\..\..\</StartWorkingDirectory>
<StartWorkingDirectory>..\..\..\</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
Expand All @@ -73,7 +73,7 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
<StartWorkingDirectory>..\..\..\</StartWorkingDirectory>
<StartWorkingDirectory>..\..\..\</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup>
<StartupObject>aiui_csharp_demo.Program</StartupObject>
Expand All @@ -88,7 +88,7 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
<StartWorkingDirectory>..\..\..\</StartWorkingDirectory>
<StartWorkingDirectory>..\..\..\</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
Expand All @@ -100,13 +100,13 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
<StartWorkingDirectory>..\..\..\</StartWorkingDirectory>
<StartWorkingDirectory>..\..\..\</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net20\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
Expand Down
2 changes: 1 addition & 1 deletion aiui/c/AIUI/cfg/aiui.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"log": {
"debug_log": "1",
"save_datalog": "0",
"datalog_path": ".",
"datalog_path": "",
"datalog_size": 1024,
"raw_audio_path": ""
}
Expand Down
Binary file added docs/_static/change_filter_new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/change_filter_old.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/change_mic_type.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/change_record.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/download_sdk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/open_sad_vad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/sad_vad_setting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/turing_setting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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',
Expand Down
5 changes: 3 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ AIUI语音SDK集成文档

.. toctree::
:maxdepth: 2
:glob:

src/*
src/index.rst
src/error_code.rst
src/engines.rst
8 changes: 8 additions & 0 deletions docs/src/engines.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
其他功能启用说明
#############################

.. toctree::
:maxdepth: 1
:glob:

engines/*
40 changes: 40 additions & 0 deletions docs/src/engines/multi_vtn.rst
Original file line number Diff line number Diff line change
@@ -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同级
25 changes: 25 additions & 0 deletions docs/src/engines/open_vad.rst
Original file line number Diff line number Diff line change
@@ -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 不用做其他处理,正常交互即可。
Loading