Skip to content

Commit

Permalink
Speech async examples (#612)
Browse files Browse the repository at this point in the history
* Adds async examples

* Adds link to Cloud Client.

* Changes sleep duration

* Adds GCS example.
  • Loading branch information
gguuss authored and lesv committed Apr 13, 2017
1 parent a9bc020 commit 2319947
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions speech/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ with Java.
- [grpc](grpc)

A sample for accessing Cloud Speech streaming and non streaming apis with [gRPC](http://www.grpc.io/).

- [Cloud Client](cloud-client)

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).
12 changes: 12 additions & 0 deletions speech/cloud-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,20 @@ You can then run a given `ClassName` via:
-Dexec.args="syncrecognize ./resources/audio.raw"
```

### Asynchronously transcribe a local audio file (using the recognize sample)
```
mvn exec:java -Dexec.mainClass=com.example.speech.Recognize \
-Dexec.args="asyncrecognize ./resources/audio.raw"
```

### Transcribe a remote audio file (using the recognize sample)
```
mvn exec:java -Dexec.mainClass=com.example.speech.Recognize \
-Dexec.args="syncrecognize 'gs://cloud-samples-tests/speech/brooklyn.flac'"
```

### Asynchronously transcribe a remote audio file (using the recognize sample)
```
mvn exec:java -Dexec.mainClass=com.example.speech.Recognize \
-Dexec.args="asyncrecognize 'gs://cloud-samples-tests/speech/brooklyn.flac'"
```
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public static void asyncRecognizeFile(String fileName) throws Exception, IOExcep
speech.longRunningRecognizeAsync(config, audio);
while (!response.isDone()) {
System.out.println("Waiting for response...");
Thread.sleep(200);
Thread.sleep(10000);
}

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

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

0 comments on commit 2319947

Please sign in to comment.