XiaomiAI.SDK
1.0.0.1
The project is support developer to easy convert Xaiomi AI server request and response json content.
Install-Package XiaomiAI.SDK -Version 1.0.0.1
dotnet add package XiaomiAI.SDK --version 1.0.0.1
<PackageReference Include="XiaomiAI.SDK" Version="1.0.0.1" />
paket add XiaomiAI.SDK --version 1.0.0.1
Xiaomi-ai-skill-converter
Download
Documents
If you aren't a Xiaomi AI developer, please visit the 水滴平台.
System requirement
XaiomiAI.SDK
-
RequestContent
Convert json from Xiaomi AI server to object.
-
ResponseContent
Convert object to response json to Xaimi AI server.
Example
[HttpPost]
public async Task<ResponseContent> Post([FromBody]string value)
{
using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
{
// read json content
string requestJson = await reader.ReadToEndAsync();
// convert to RequestContent
var requestContent = JsonConvert.DeserializeObject<RequestContent>(requestJson);
// identify request type to generate response content
switch (requestContent.Request.Type)
{
case RequestType.Intent:
string displayText = "是的,帮你朗读现在气象";
return new ResponseContent
{
IsSessionEnd = false,
Response = new ResponseData
{
ToSpeak = new ToSpeakData
{
Type = ToSpeakType.TTS,
Text = displayText
},
ToDisplay = new PlainTextToDisplayData
{
Text = displayText
},
Directives = new List<IDirectiveData>
{
new AudioDirectiveData
{
AudioItem = new AudioItemData
{
Stream = new StreamData
{
Url = "http://xxxxx.mp3"
}
}
},
new TTSDirectiveData
{
TTSItem = new TTSItemData
{
Text = displayText
}
}
}
}
};
case RequestType.End:
string endTxt = "期待您再次使用";
return new ResponseContent
{
IsSessionEnd = true,
Response = new ResponseData
{
ToSpeak = new ToSpeakData
{
Type = ToSpeakType.TTS,
Text = endTxt
},
ToDisplay = new PlainTextToDisplayData
{
Text = endTxt
},
}
};
default:
// None, Wakeup
string wakeupTxt = "請問您需要什么服務呢?";
return new ResponseContent
{
IsSessionEnd = false,
Response = new ResponseData
{
ToSpeak = new ToSpeakData
{
Type = ToSpeakType.TTS,
Text = wakeupTxt
},
ToDisplay = new PlainTextToDisplayData
{
Text = wakeupTxt
}
}
};
}
}
}
Enter develop mode of the Xiaomi AI Speaker
If the state of the custom skill is testing or during cerficiation process, you can test it on the Xiaomi AI Speaker.
Steps:
-
对音箱说:
进入开发者模式
--------------测试中-------------------
-
用你的技能
调用名称
进行测试,只有处于测试中或者审核中的技能都能够进行测试 -
想要退出请说:
进入用户模式
Xiaomi-ai-skill-converter
Download
Documents
If you aren't a Xiaomi AI developer, please visit the 水滴平台.
System requirement
XaiomiAI.SDK
-
RequestContent
Convert json from Xiaomi AI server to object.
-
ResponseContent
Convert object to response json to Xaimi AI server.
Example
[HttpPost]
public async Task<ResponseContent> Post([FromBody]string value)
{
using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
{
// read json content
string requestJson = await reader.ReadToEndAsync();
// convert to RequestContent
var requestContent = JsonConvert.DeserializeObject<RequestContent>(requestJson);
// identify request type to generate response content
switch (requestContent.Request.Type)
{
case RequestType.Intent:
string displayText = "是的,帮你朗读现在气象";
return new ResponseContent
{
IsSessionEnd = false,
Response = new ResponseData
{
ToSpeak = new ToSpeakData
{
Type = ToSpeakType.TTS,
Text = displayText
},
ToDisplay = new PlainTextToDisplayData
{
Text = displayText
},
Directives = new List<IDirectiveData>
{
new AudioDirectiveData
{
AudioItem = new AudioItemData
{
Stream = new StreamData
{
Url = "http://xxxxx.mp3"
}
}
},
new TTSDirectiveData
{
TTSItem = new TTSItemData
{
Text = displayText
}
}
}
}
};
case RequestType.End:
string endTxt = "期待您再次使用";
return new ResponseContent
{
IsSessionEnd = true,
Response = new ResponseData
{
ToSpeak = new ToSpeakData
{
Type = ToSpeakType.TTS,
Text = endTxt
},
ToDisplay = new PlainTextToDisplayData
{
Text = endTxt
},
}
};
default:
// None, Wakeup
string wakeupTxt = "請問您需要什么服務呢?";
return new ResponseContent
{
IsSessionEnd = false,
Response = new ResponseData
{
ToSpeak = new ToSpeakData
{
Type = ToSpeakType.TTS,
Text = wakeupTxt
},
ToDisplay = new PlainTextToDisplayData
{
Text = wakeupTxt
}
}
};
}
}
}
Enter develop mode of the Xiaomi AI Speaker
If the state of the custom skill is testing or during cerficiation process, you can test it on the Xiaomi AI Speaker.
Steps:
-
对音箱说:
进入开发者模式
--------------测试中-------------------
-
用你的技能
调用名称
进行测试,只有处于测试中或者审核中的技能都能够进行测试 -
想要退出请说:
进入用户模式
Release Notes
1.0.0.1: modify some json tag for new version of Xiaomi AI request/response.
Dependencies
-
.NETFramework 4.5.2
- Newtonsoft.Json (>= 12.0.2)
-
.NETFramework 4.6.1
- Newtonsoft.Json (>= 12.0.2)
-
.NETStandard 2.0
- Newtonsoft.Json (>= 12.0.2)
GitHub Usage
This package is not used by any popular GitHub repositories.