bing_speech_api.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:respeaker_python_library 作者: respeaker 项目源码 文件源码
def authenticate(self):
        if self.expire_time is None or monotonic() > self.expire_time:  # first credential request, or the access token from the previous one expired
            # get an access token using OAuth
            credential_url = "https://api.cognitive.microsoft.com/sts/v1.0/issueToken"
            headers = {"Ocp-Apim-Subscription-Key": self.key}

            start_time = monotonic()
            response = self.session.post(credential_url, headers=headers)

            if response.status_code != 200:
                raise RequestError("http request error with status code {}".format(response.status_code))

            self.access_token = response.content
            expiry_seconds = 590 # document mentions the access token is expired in 10 minutes

            self.expire_time = start_time + expiry_seconds
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号