use of com.google.cloud.speech.v1beta1.SyncRecognizeResponse in project google-cloud-java by GoogleCloudPlatform.
the class SpeechClientTest method syncRecognizeTest.
@Test
@SuppressWarnings("all")
public void syncRecognizeTest() {
SyncRecognizeResponse expectedResponse = SyncRecognizeResponse.newBuilder().build();
mockSpeech.addResponse(expectedResponse);
RecognitionConfig.AudioEncoding encoding = RecognitionConfig.AudioEncoding.FLAC;
int sampleRate = 44100;
RecognitionConfig config = RecognitionConfig.newBuilder().setEncoding(encoding).setSampleRate(sampleRate).build();
String uri = "gs://bucket_name/file_name.flac";
RecognitionAudio audio = RecognitionAudio.newBuilder().setUri(uri).build();
SyncRecognizeResponse actualResponse = client.syncRecognize(config, audio);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockSpeech.getRequests();
Assert.assertEquals(1, actualRequests.size());
SyncRecognizeRequest actualRequest = (SyncRecognizeRequest) actualRequests.get(0);
Assert.assertEquals(config, actualRequest.getConfig());
Assert.assertEquals(audio, actualRequest.getAudio());
}
Aggregations