1
votes

I am currently receiving invalid JSON such as the following:

results { alternatives { transcript: " Brooklyn Bridge" } stability: 0.01 }

This is using the example code found here: https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/speech/cloud-client

I'd like to be able to parse the result, but I'm not sure how to.

Is there a way to force the result to return valid JSON or perhaps a way to parse the result?

1

1 Answers

1
votes

The problem is that the result isn't JSON, it's a Google Protobuf object. It looks like you've pasted the string representation of the object. You should be able to access the fields of this object directly.

This example from Google might help clear it up.

Try something like this and see if it works:

for result in your_response_from_google.results:
    print(result)

Based on your example, I think you're looking at a StreamingRecognizeResponse object.