Skip to content

Commit e513364

Browse files
committed
Removes deprecated async local file method
1 parent 8609ba6 commit e513364

File tree

2 files changed

+0
-54
lines changed

2 files changed

+0
-54
lines changed

speech/cloud-client/src/main/java/com/example/speech/Recognize.java

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,9 @@ public static void main(String... args) throws Exception {
6666
} else if (command.equals("asyncrecognize")) {
6767
if (path.startsWith("gs://")) {
6868
asyncRecognizeGcs(path);
69-
} else {
70-
asyncRecognizeFile(path);
7169
}
7270
} else if (command.equals("streamrecognize")) {
7371
streamingRecognizeFile(path);
74-
//streamingRecognizeEasy(path);
7572
}
7673

7774
}
@@ -143,50 +140,6 @@ public static void syncRecognizeGcs(String gcsUri) throws Exception, IOException
143140
speech.close();
144141
}
145142

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-
190143
/**
191144
* Performs non-blocking speech recognition on remote FLAC file and prints
192145
* the transcription.

speech/cloud-client/src/test/java/com/example/speech/RecognizeIT.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,6 @@ public void testRecognizeGcs() throws Exception {
6969
assertThat(got).contains("how old is the Brooklyn Bridge");
7070
}
7171

72-
@Test
73-
public void testAsyncRecognizeFile() throws Exception {
74-
Recognize.asyncRecognizeFile(fileName);
75-
String got = bout.toString();
76-
assertThat(got).contains("how old is the Brooklyn Bridge");
77-
}
78-
7972
@Test
8073
public void testAsyncRecognizeGcs() throws Exception {
8174
Recognize.asyncRecognizeGcs(gcsPath);

0 commit comments

Comments
 (0)