我已将语音输入 api(Bing Speech API)集成到我正在开发的其中一个 BOT(MS BOT 框架-.net)中,但不确定如何测试它是否正常工作。 MS Bot 模拟器是否有助于使用麦克风对其进行测试?或者我应该使用像Skype这样的任何 channel 来测试它吗?
请帮忙。
谢谢
最佳答案
我使用 https://docs.botframework.com/en-us/skype/calling/#calling-conversation-object-model 中定义的记录操作创建了一个 Skype 机器人。录制来自用户的音频,然后在使用 soundfile 完成录制后使用 Bing 语音识别 API 执行语音到文本。
private async Task OnRecordCompleted(RecordOutcomeEvent recordOutcomeEvent)
{
string s = string.Empty;
string path = string.Empty;
if (recordOutcomeEvent.RecordOutcome.Outcome = Outcome.Success)
{
var record = await recordOutcomeEvent.RecordedContent;
path = HttpContext.Current.Server.MapPath($"~/{recordOutcomeEvent.RecordOutcome.Id}.wav");
using (var writer = new FileStream(path, FileMode.Create))
{
await record.CopyToAsync(writer);
}
Attachment att = new Attachment()
{
ContentUrl = "file:///" + path,
ContentType = "audio/wav",
};
s = DoSpeechReco(att);
关于speech-recognition - 如何在 Microsoft BOT 中测试语音输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38607871/