@@ -66,12 +66,9 @@ public static void main(String... args) throws Exception {
66
66
} else if (command .equals ("asyncrecognize" )) {
67
67
if (path .startsWith ("gs://" )) {
68
68
asyncRecognizeGcs (path );
69
- } else {
70
- asyncRecognizeFile (path );
71
69
}
72
70
} else if (command .equals ("streamrecognize" )) {
73
71
streamingRecognizeFile (path );
74
- //streamingRecognizeEasy(path);
75
72
}
76
73
77
74
}
@@ -143,50 +140,6 @@ public static void syncRecognizeGcs(String gcsUri) throws Exception, IOException
143
140
speech .close ();
144
141
}
145
142
146
- /*
147
- /**
148
- * Performs non-blocking speech recognition on raw PCM audio and prints
149
- * the transcription.
150
- *
151
- * @param fileName the path to a PCM audio file to transcribe.
152
- */
153
- public static void asyncRecognizeFile (String fileName ) throws Exception , IOException {
154
- // Instantiates a client with GOOGLE_APPLICATION_CREDENTIALS
155
- SpeechClient speech = SpeechClient .create ();
156
-
157
- Path path = Paths .get (fileName );
158
- byte [] data = Files .readAllBytes (path );
159
- ByteString audioBytes = ByteString .copyFrom (data );
160
-
161
- // Configure request with local raw PCM audio
162
- RecognitionConfig config = RecognitionConfig .newBuilder ()
163
- .setEncoding (AudioEncoding .LINEAR16 )
164
- .setLanguageCode ("en-US" )
165
- .setSampleRateHertz (16000 )
166
- .build ();
167
- RecognitionAudio audio = RecognitionAudio .newBuilder ()
168
- .setContent (audioBytes )
169
- .build ();
170
-
171
- // Use non-blocking call for getting file transcription
172
- OperationFuture <LongRunningRecognizeResponse > response =
173
- speech .longRunningRecognizeAsync (config , audio );
174
- while (!response .isDone ()) {
175
- System .out .println ("Waiting for response..." );
176
- Thread .sleep (200 );
177
- }
178
-
179
- List <SpeechRecognitionResult > results = response .get ().getResultsList ();
180
-
181
- for (SpeechRecognitionResult result : results ) {
182
- List <SpeechRecognitionAlternative > alternatives = result .getAlternativesList ();
183
- for (SpeechRecognitionAlternative alternative : alternatives ) {
184
- System .out .printf ("Transcription: %s%n" , alternative .getTranscript ());
185
- }
186
- }
187
- speech .close ();
188
- }
189
-
190
143
/**
191
144
* Performs non-blocking speech recognition on remote FLAC file and prints
192
145
* the transcription.
0 commit comments