Azure认知服务——滚筒



演讲服务是认知服务的一种,提供了语音转文本,文本转语音、语音翻译等,今天我们实战的是语音转文本(演讲文本)。


STT支持两种访问方式,1。是SDK, 2。是REST API .


其中:

SDK方式支持识别麦克风的语音流和语音文件;

REST API方式仅支持语音文件;


准备工作:创建认知服务之演讲服务:


创建完成后,两个重要的参数可以在页面查看:



<强>一。REST API方式将语音文件转换成文本:


Azure global的 Speech API 终结点请参考:

https://docs.microsoft.com/zh-cn/azure/cognitive-services/speech-service/rest-speech-to-text#regions-and-endpoints



Azure 中国区 的 Speech API 终结点:

截至到2020.2月,仅中国东部2区域已开通Speech服务,服务终结点为:

https://chinaeast2.stt.speech.azure.cn/speech/recognition/conversation/cognitiveservices/v1


对于Speech To Text来说,有两种身份验证方式:

Azure Cognitive Services- Spee

的方式。

注意:如果要实现文本转语音,按照上表,则必须使用 Authorization Token形式进行身份验证。


构建请求的其他注意事项:

  1. 文件格式:

    Azure Cognitive Services- Spee

  2. 请求头:

    Azure Cognitive Services- Spee

  3. 请求参数:

    Azure Cognitive Services- Spee

在Postman中的示例如下:


Azure Cognitive Services- Spee


Azure Cognitive Services- Spee


Azure Cognitive Services- Spee


如果要在REST API中使用 Authorization Token,则需要先获得Token:

Global 获取Token的终结点:

https://docs.microsoft.com/zh-cn/azure/cognitive-services/speech-service/rest-speech-to-text#authentication

中国区获取Token的终结点:

截至2020.02,只有中国东部2有Speech服务,其Token终结点为:

https://chinaeast2.api.cognitive.azure.cn/sts/v1.0/issuetoken


Postman获取Token 参考如下:

Azure Cognitive Services- Spee



二. SDK方式将语音文件转换成文本(Python示例):


在官网可以看到类似的代码,但需要注意的是,。

参数):

speech_recognizer=speechsdk.SpeechRecognizer (speech_config=speech_config)



公众号链接:https://mp.weixin.qq.com/s/NA9kQsVDfzTXEqHMTdDExA


语雀地址:https://www.yuque.com/seanyu/azure/blwb5i



Azure认知服务——滚筒