analyse.py 文件源码

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

项目:SDK-python 作者: RecastAI 项目源码 文件源码
def analyse_file(self, filename, token=None, language=None):
    token = token or self.token
    if token is None:
      raise RecastError("Token is missing")

    language = language or self.language

    filename = open(filename, 'rb') if not isinstance(filename, io.IOBase) else filename

    body = {'voice': filename}
    if language is not None:
      body['language'] = language

    response = requests.post(
      Utils.REQUEST_ENDPOINT,
      files=body,
      headers={'Authorization': "Token {}".format(token)}
    )
    if response.status_code != requests.codes.ok:
      raise RecastError(response.json().get('message', ''))

    return Response(response.json()['results'])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号