大佬教程收集整理的这篇文章主要介绍了Azure AI 服务之语音识别,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
》中简单介绍了 Azure 认知服务中的文本翻译 API,通过这些简单的 REST API 调用就可以轻松地进行机器翻译。如果能在程序中简单的集成语音转文本的功能会不会非常赞!本文我们就介绍如何使用必应的语音识别 API(Bing Speech API) 把语音转换成文本:
。
ShortPhrase 和 LongDictation 两种识别模式。Dictation 模式支持最长两分钟的语音。语音数据被分块发送到服务器,根据服务端分辨出的语句间的停顿,客户端会受到多个部分结果和多个最终结果。
例:
Dictation 模式。
</span><span style="color: #0000ff">try</span><span style="color: #000000">
{
</span><span style="color: #0000ff">do</span><span style="color: #000000">
{
</span><span style="color: #008000">//</span><span style="color: #008000"> 把文件数据读取到 buffer 中。</span>
bytesRead = fileStream.Read(buffer,<span style="color: #800080">0</span><span style="color: #000000">,buffer.Length);
</span><span style="color: #008000">//</span><span style="color: #008000"> 通过 DataRecognitionClient 类型的实例把语音数据发送到服务端。</span>
<span style="color: #0000ff">this</span><span style="color: #000000">.dataClient.SendAudio(buffer,bytesRead);
}
</span><span style="color: #0000ff">while</span> (bytesRead > <span style="color: #800080">0</span><span style="color: #000000">);
}
</span><span style="color: #0000ff">finally</span><span style="color: #000000">
{
</span><span style="color: #008000">//</span><span style="color: #008000"> 告诉服务端语音数据已经传送完了。</span>
<span style="color: #0000ff">this</span><span style="color: #000000">.dataClient.EndAudio();
}
}
}
在数据传送结束后需要通过 EndAudio() 方法显式的告诉服务端数据传送结束。
--- Partial result received by OnPartialResponseReceivedHandler() ---
<span style="color: #ff0000">what's
--- Partial result received by OnPartialResponseReceivedHandler() ---
<span style="color: #ff0000">what's the weather
--- Partial result received by OnPartialResponseReceivedHandler() ---
<span style="color: #ff0000">what's the weather like
则应用程序就具备了实时性。
title="Azure AI 服务之语音识别" alt="Azure AI 服务之语音识别" src="https://cn.js-code.com/res/2019/02-09/09/bc5fab0516a28c9cece2cb625ebc159c.png" >
Dictation 模式的识别,客户端事件 OnResponseReceived 会被触发多次,并返回分阶段的识别结果,结果中的内容和 ShortPhrase 模式类似。更详细的内容请大家直接看代码吧,很简单的。
全面的,现在支持的所有模式都支持中文。如果你还有其它需求,可以从查看详细的语言支持列表。
以上是大佬教程为你收集整理的Azure AI 服务之语音识别全部内容,希望文章能够帮你解决Azure AI 服务之语音识别所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。