Can Bot Framework handle Facebook Audio Message

不羁岁月 提交于 2020-01-04 05:46:30

问题


How can my bot (Bot Framework Microsoft) handle an audio message from facebook.

How it's received in the Post Message in MessagesController? So I can call the SpeechToText API?

Does the data go all the way to


回答1:


Your Post controller takes an Activity as an argument. The Audio message will show up in the Attachment array as a link to the audio location provided by Facebook. You can pass that to the Bing Speech API. One thing to note that the ContentType provided by Facebook is "video/mp4" (which could be confusing).




回答2:


You get an attachment of the type "audio/aac". You need to access it via your activity object.

var sound = activity.Attachments?.FirstOrDefault(a => a.ContentType.Equals("audio/aac"));

Now you can easily access the actual message via sound.ContentUrl and have a URI to the file, which you then can put into an encoder to convert it to wav. Then you can put it into you Bing speech Api.



来源:https://stackoverflow.com/questions/40918731/can-bot-framework-handle-facebook-audio-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!