Skip to content

Commit f9ac582

Browse files
committed
added async response unpack
Author: puneith <puneith@google.com>
1 parent f221210 commit f9ac582

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

speech/grpc/src/main/java/com/google/cloud/speech/grpc/demos/AsyncRecognizeClient.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
package com.google.cloud.speech.grpc.demos;
2727

2828
import com.google.auth.oauth2.GoogleCredentials;
29+
import com.google.cloud.speech.v1beta1.AsyncRecognizeResponse;
2930
import com.google.cloud.speech.v1beta1.RecognitionAudio;
3031
import com.google.cloud.speech.v1beta1.RecognitionConfig;
3132
import com.google.cloud.speech.v1beta1.RecognitionConfig.AudioEncoding;
@@ -160,7 +161,13 @@ public void recognize() {
160161
}
161162
}
162163

163-
logger.info("Received response: " + status.getResponse());
164+
try {
165+
AsyncRecognizeResponse asyncRes = status.getResponse().unpack(AsyncRecognizeResponse.class);
166+
167+
logger.info("Received response: " + asyncRes);
168+
} catch(com.google.protobuf.InvalidProtocolBufferException ex) {
169+
logger.log(Level.WARNING, "Unpack error, {0}",ex.getMessage());
170+
}
164171
}
165172

166173
public static void main(String[] args) throws Exception {

0 commit comments

Comments
 (0)