在哪里可以找到Google Cloud Speech中的错误代码?

时间:2018-11-29 13:25:35

标签: google-cloud-platform google-cloud-speech

我正在将python API用于Google Cloud Speech to Text。执行client.streaming_recognize

时出现以下错误

google.api_core.exceptions.InvalidArgument:400无法识别语音,代码= -73532,可能是识别配置错误。请更正配置,然后重试请求。

我搜索了错误代码,但未找到任何结果。

对于客户端应用程序,我遵循了this。 Web服务器基于Flask,下面是我处理客户端数据的部分。

@socketio.on('initRecording')
def init_recording(data):
    print('Initiated recording on server')

    config = types.RecognitionConfig(
        encoding='LINEAR16',
        sample_rate_hertz=16000,
        language_code='en-US')
    streaming_config = types.StreamingRecognitionConfig(
        config=config, interim_results=False)

    streaming_client = StreamingClient()
    streaming_client.configure(streaming_config)


@socketio.on('binaryData')
def process_recording(data):
    emit('speechData', streaming_client.write(data))


class StreamingClient():
    def __init__(self):
        self.client = speech.SpeechClient()
        self.buffer = []

    def configure(self, streaming_config):
        self.streaming_config = streaming_config

    def write(self, data):
        self.buffer.append(types.StreamingRecognizeRequest(audio_content=data))
        responses = self.client.streaming_recognize(
            self.streaming_config, self.buffer)

        for response in responses:
            if response.error:
                continue

            if not response.results:
                continue

            result = response.results[0]
            if not result.alternatives:
                continue

            if result.is_final:
                self.buffer = []
                return result.alternatives[0].transcript

1 个答案:

答案 0 :(得分:0)

错误代码是Google内部的,我不认为它们是共享的。您可以create a feature request在错误消息中询问信息。