8000 Speech async examples (#612) · SyCode7/java-docs-samples@2319947 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2319947

Browse files
gguusslesv
authored andcommitted
Speech async examples (GoogleCloudPlatform#612)
* Adds async examples * Adds link to Cloud Client. * Changes sleep duration * Adds GCS example.
1 parent a9bc020 commit 2319947

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

speech/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ with Java.
66
- [grpc](grpc)
77

88
A sample for accessing Cloud Speech streaming and non streaming apis with [gRPC](http://www.grpc.io/).
9+
10+
- [Cloud Client](cloud-client)
11+
12+
A sample for accessing Cloud Speech streaming and non streaming apis using the [Cloud Client Library for Java](https://github.com/GoogleCloudPlatform/google-cloud-java).

speech/cloud-client/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,20 @@ You can then run a given `ClassName` via:
3131
-Dexec.args="syncrecognize ./resources/audio.raw"
3232
```
3333

34+
### Asynchronously transcribe a local audio file (using the recognize sample)
35+
```
36+
mvn exec:java -Dexec.mainClass=com.example.speech.Recognize \
37+
-Dexec.args="asyncrecognize ./resources/audio.raw"
38+
```
39+
3440
### Transcribe a remote audio file (using the recognize sample)
3541
```
3642
mvn exec:java -Dexec.mainClass=com.example.speech.Recognize \
3743
-Dexec.args="syncrecognize 'gs://cloud-samples-tests/speech/brooklyn.flac'"
3844
```
45+
46+
### Asynchronously transcribe a remote audio file (using the recognize sample)
47+
```
48+
mvn exec:java -Dexec.mainClass=com.example.speech.Recognize \
49+
-Dexec.args="asyncrecognize 'gs://cloud-samples-tests/speech/brooklyn.flac'"
50+
```

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public static void asyncRecognizeFile(String fileName) throws Exception, IOExcep
172172
speech.longRunningRecognizeAsync(config, audio);
173173
while (!response.isDone()) {
174174
System.out.println("Waiting for response...");
175-
Thread.sleep(200);
175+
Thread.sleep(10000);
176176
}
177177

178178
List<SpeechRecognitionResult> results = response.get().getResultsList();
@@ -211,7 +211,7 @@ public static void asyncRecognizeGcs(String gcsUri) throws Exception, IOExceptio
211211
speech.longRunningRecognizeAsync(config, audio);
212212
while (!response.isDone()) {
213213
System.out.println("Waiting for response...");
214-
Thread.sleep(200);
214+
Thread.sleep(10000);
215215
}
216216

217217
List<SpeechRecognitionResult> results = response.get().getResultsList();

0 commit comments

Comments
 (0)
0