예제 #1
0
파일: aai_client.py 프로젝트: Rempage/Smart
    def SentenceRecognition(self, request):
        """识别60s内的短语音,当音频放在请求body中传输时整个请求大小不能超过1M,当音频以url方式传输时,音频时长不可超过60s。所有请求参数放在post的body中采用x-www-form-urlencoded(数据转换成一个字串(name1=value1&name2=value2…)进行urlencode后)编码传输。先暂只支持中文普通话识别,支持识别8k(16k)的16bit的mp3或者wav音频。

        :param request: 调用SentenceRecognition所需参数的结构体。
        :type request: :class:`tencentcloud.aai.v20180522.models.SentenceRecognitionRequest`
        :rtype: :class:`tencentcloud.aai.v20180522.models.SentenceRecognitionResponse`

        """
        try:
            params = request._serialize()
            body = self.call("SentenceRecognition", params)
            response = json.loads(body)
            if "Error" not in response["Response"]:
                model = models.SentenceRecognitionResponse()
                model._deserialize(response["Response"])
                return model
            else:
                code = response["Response"]["Error"]["Code"]
                message = response["Response"]["Error"]["Message"]
                reqid = response["Response"]["RequestId"]
                raise TencentCloudSDKException(code, message, reqid)
        except Exception as e:
            if isinstance(e, TencentCloudSDKException):
                raise e
            else:
                raise TencentCloudSDKException(e.message, e.message)
예제 #2
0
    def SentenceRecognition(self, request):
        """识别60s内的短语音。

        :param request: 调用SentenceRecognition所需参数的结构体。
        :type request: :class:`tencentcloud.aai.v20180522.models.SentenceRecognitionRequest`
        :rtype: :class:`tencentcloud.aai.v20180522.models.SentenceRecognitionResponse`

        """
        try:
            params = request._serialize()
            body = self.call("SentenceRecognition", params)
            response = json.loads(body)
            if "Error" not in response["Response"]:
                model = models.SentenceRecognitionResponse()
                model._deserialize(response["Response"])
                return model
            else:
                code = response["Response"]["Error"]["Code"]
                message = response["Response"]["Error"]["Message"]
                reqid = response["Response"]["RequestId"]
                raise TencentCloudSDKException(code, message, reqid)
        except Exception as e:
            if isinstance(e, TencentCloudSDKException):
                raise e
            else:
                raise TencentCloudSDKException(e.message, e.message)