最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】调用语言识别接口传递wav录音尝试翻译识别出的英文的效果

工作和技术 crifan 2834浏览 0评论

折腾:

【未解决】把语音识别集成到产品demo中

期间,需要去试试,语言识别的效果。

先去试试微软的Azure的

参考之前自己整理的:

【已解决】微软必应中必应语言和语音服务(预览版)的区别

继续去看看:

Use Speech to Text – Microsoft Cognitive Services | Microsoft Docs

Speech service REST APIs | Microsoft Docs

然后去写代码测试效果

【已解决】重新申请Azure的免费的语音服务

才有了token key可以用。

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

Get started with the Microsoft Speech Recognition API by using REST | Microsoft Docs

https://docs.microsoft.com/zh-cn/azure/cognitive-services/speech/concepts#recognition-modes

https://docs.microsoft.com/zh-cn/azure/cognitive-services/speech/concepts#recognition-languages

但是:

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

里没有说具体如何使用

而:

https://docs.microsoft.com/zh-cn/azure/cognitive-services/speech/getstarted/getstartedrest?tabs=Powershell

介绍了如何使用,但是api地址是:

<code>https://speech.platform.bing.com/speech/recognition/&lt;RECOGNITION_MODE&gt;/cognitiveservices/v1?language=&lt;LANGUAGE_TAG&gt;&amp;format=&lt;OUTPUT_FORMAT&gt;
</code>

好像是旧的的接口啊

Sample for Speech-to-Text – Microsoft Cognitive Services | Microsoft Docs

幸好有sample:

Azure-Samples/SpeechToText-REST: REST Samples of Speech To Text API

下载看看

结果是:

https://docs.microsoft.com/zh-cn/azure/cognitive-services/speech/getstarted/getstartedrest?tabs=Powershell

旧的接口:

speech.platform.bing.com

的例子,而不是最新的。

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

-》“Utterances are limited to 15 seconds or less when using the REST API.”

https://docs.microsoft.com/zh-cn/azure/cognitive-services/speech/concepts#using-the-speech-recognition-service-from-your-apps

“Convert a short spoken audio, for example, commands (audio length < 15 s) without interim results”

关于语音识别,传入禁区的wav录音,最大时长是:15秒

-》

https://docs.microsoft.com/zh-cn/azure/cognitive-services/speech/getstarted/getstartedrest?tabs=Powershell

如果想要去除时间限制,可以使用SDK(client library) 或Websocket协议

然后大致看懂了:

语音识别的:

最终,关于API如何使用,还是要去好好看看:

https://docs.microsoft.com/zh-cn/azure/cognitive-services/speech/getstarted/getstartedrest?tabs=Powershell

现在是:

已经知道了:

需要搞清楚:

-》

目前情况:

<code>POST https://westus.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?language=en-US&amp;format=simple

Headers:
Ocp-Apim-Subscription-Key: your_key
Content-type:audio/wav; codec=audio/pcm; samplerate=16000
Accept: application/json;
Transfer-Encoding: chunked
</code>

注意:

此处实际上自己的Content-type是:

audio/wav; codec=audio/pcm; samplerate=44100

但是先这么去试试,看看能否使用再说。

所以,此处先要去在服务器端Flask中封装出API接口,供浏览器客户端调用此语言识别接口。

其中,需要先去实现:

【已解决】Flask的REST API添加支持POST时body中分块传输二进制数据

转载请注明:在路上 » 【已解决】调用语言识别接口传递wav录音尝试翻译识别出的英文的效果

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
88 queries in 0.200 seconds, using 22.11MB memory