@@ -52,7 +52,7 @@ public static void tearDownClass() throws Exception {
5252
5353 @ Test
5454 public void syncRecognize () {
55- RecognizeResponse response = speechClient .recognize (config (), audio ());
55+ RecognizeResponse response = speechClient .recognize (config (2 ), audio ());
5656
5757 Truth .assertThat (response .getResultsCount ()).isGreaterThan (0 );
5858 Truth .assertThat (response .getResults (0 ).getAlternativesCount ()).isGreaterThan (0 );
@@ -63,7 +63,7 @@ public void syncRecognize() {
6363 @ Test
6464 public void longrunningRecognize () throws Exception {
6565 LongRunningRecognizeResponse response =
66- speechClient .longRunningRecognizeAsync (config (), audio ()).get ();
66+ speechClient .longRunningRecognizeAsync (config (2 ), audio ()).get ();
6767
6868 Truth .assertThat (response .getResultsCount ()).isGreaterThan (0 );
6969 Truth .assertThat (response .getResults (0 ).getAlternativesCount ()).isGreaterThan (0 );
@@ -78,7 +78,7 @@ public void streamingRecognize() throws Exception {
7878 .toByteArray ();
7979
8080 StreamingRecognitionConfig streamingConfig =
81- StreamingRecognitionConfig .newBuilder ().setConfig (config ()).build ();
81+ StreamingRecognitionConfig .newBuilder ().setConfig (config (1 )).build ();
8282
8383 ResponseApiStreamingObserver <StreamingRecognizeResponse > responseObserver =
8484 new ResponseApiStreamingObserver <>();
@@ -133,7 +133,7 @@ public SettableFuture<List<T>> future() {
133133 }
134134 }
135135
136- private RecognitionConfig config () {
136+ private RecognitionConfig config (int channels ) {
137137 String languageCode = "en-US" ;
138138 int sampleRateHertz = 44100 ;
139139 RecognitionConfig .AudioEncoding encoding = RecognitionConfig .AudioEncoding .FLAC ;
@@ -142,6 +142,7 @@ private RecognitionConfig config() {
142142 .setLanguageCode (languageCode )
143143 .setSampleRateHertz (sampleRateHertz )
144144 .setEncoding (encoding )
145+ .setAudioChannelCount (channels )
145146 .build ();
146147 return config ;
147148 }
@@ -151,6 +152,8 @@ public RecognitionAudio audio() {
151152 if (audio_gcs_uri != null ) {
152153 return RecognitionAudio .newBuilder ().setUri (audio_gcs_uri ).build ();
153154 }
154- return RecognitionAudio .newBuilder ().setUri ("gs://gapic-toolkit/hello.flac" ).build ();
155+ return RecognitionAudio .newBuilder ()
156+ .setUri ("gs://cloud-samples-data/speech/hello.flac" )
157+ .build ();
155158 }
156159}
0 commit comments