我正在使用以下代码发送我的视频,显然我没有错误。但是回应是空白的。我怎样才能阅读回复?
########### Python 2.7 #############
import httplib, urllib, base64, json
headers = {
# Request headers
'Ocp-Apim-Subscription-Key': 'xxxxxxxxxxxxxxxxxxxx',
'Content-Type': 'application/json'
}
video_filename = {"url":"https://fsarquivoeastus.blob.core.windows.net/public0/WhatsApp-Video-20160727.mp4"}
params = urllib.urlencode({})
try:
conn = httplib.HTTPSConnection('api.projectoxford.ai')
conn.request("POST", "/emotion/v1.0/recognizeinvideo?%s" % params, json.dumps(video_filename), headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
答案 0 :(得分:1)
认知服务视频API(包括Emotion)以异步方式运行,并且在POST成功时按设计返回空响应主体。你必须做的是从标题中检索操作URL,如下所示:
response = conn.getresponse()
location = response.getheader('operation-location');
print(location);
您在location
网址上调用GET以检查操作的状态。更多关于here。
答案 1 :(得分:0)