From dfb4142be432655fffccd60233eda49f336e3d0e Mon Sep 17 00:00:00 2001 From: Gus Class Date: Tue, 2 May 2017 15:46:41 -0700 Subject: [PATCH] Vision speech upgrade (#641) * Fixes dependencies and class package changes. * Guava exclusions so Truth doesn't conflict with Cloud Client * Upgrades vision to 0.17.1 --- speech/cloud-client/README.md | 25 +++++----- speech/cloud-client/pom.xml | 48 +++++++++++++++++-- .../java/com/example/speech/Recognize.java | 2 +- vision/cloud-client/pom.xml | 2 +- .../main/java/com/example/vision/Detect.java | 4 +- 5 files changed, 59 insertions(+), 22 deletions(-) diff --git a/speech/cloud-client/README.md b/speech/cloud-client/README.md index c9d1bae43b5..83565a21e04 100644 --- a/speech/cloud-client/README.md +++ b/speech/cloud-client/README.md @@ -15,36 +15,33 @@ Install [Maven](http://maven.apache.org/). Build your project with: - mvn clean package -DskipTests - -You can then run a given `ClassName` via: - - mvn exec:java -Dexec.mainClass=com.example.speech.ClassName + mvn clean compile assembly:single ### Transcribe a local audio file (using the quickstart sample) - mvn exec:java -Dexec.mainClass=com.example.speech.QuickstartSample + java -cp target/speech-google-cloud-samples-1.0.0-jar-with-dependencies.jar \ + com.example.speech.QuickstartSample ### Transcribe a local audio file (using the recognize sample) ``` - mvn exec:java -Dexec.mainClass=com.example.speech.Recognize \ - -Dexec.args="syncrecognize ./resources/audio.raw" + java -cp target/speech-google-cloud-samples-1.0.0-jar-with-dependencies.jar \ + com.example.speech.Recognize 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" + java -cp target/speech-google-cloud-samples-1.0.0-jar-with-dependencies.jar \ + com.example.speech.Recognize 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'" + java -cp target/speech-google-cloud-samples-1.0.0-jar-with-dependencies.jar \ + com.example.speech.Recognize 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/vr.flac'" + java -cp target/speech-google-cloud-samples-1.0.0-jar-with-dependencies.jar \ + com.example.speech.Recognize asyncrecognize gs://cloud-samples-tests/speech/vr.flac ``` diff --git a/speech/cloud-client/pom.xml b/speech/cloud-client/pom.xml index 88d87f58c28..0fdbc79c43e 100644 --- a/speech/cloud-client/pom.xml +++ b/speech/cloud-client/pom.xml @@ -28,8 +28,8 @@ - 1.8 - 1.8 + 1.7 + 1.7 UTF-8 @@ -50,8 +50,30 @@ com.google.cloud - google-cloud - 0.14.0-alpha + google-cloud-speech + 0.17.1-alpha + + + com.google.api + gax + 1.0.0 + + + com.google.guava + * + + + + + com.google.api + gax-grpc + 0.16.0 + + + com.google.guava + * + + @@ -69,4 +91,22 @@ test + + + + + maven-assembly-plugin + + + + com.example.language.QuickstartSample + + + + jar-with-dependencies + + + + + diff --git a/speech/cloud-client/src/main/java/com/example/speech/Recognize.java b/speech/cloud-client/src/main/java/com/example/speech/Recognize.java index 71659e7d396..9863d9bc1b4 100644 --- a/speech/cloud-client/src/main/java/com/example/speech/Recognize.java +++ b/speech/cloud-client/src/main/java/com/example/speech/Recognize.java @@ -16,7 +16,7 @@ package com.example.speech; -import com.google.api.gax.core.ApiStreamObserver; +import com.google.api.gax.grpc.ApiStreamObserver; import com.google.api.gax.grpc.OperationFuture; import com.google.api.gax.grpc.StreamingCallable; import com.google.cloud.speech.spi.v1.SpeechClient; diff --git a/vision/cloud-client/pom.xml b/vision/cloud-client/pom.xml index 80e5f9146df..9414105c807 100644 --- a/vision/cloud-client/pom.xml +++ b/vision/cloud-client/pom.xml @@ -38,7 +38,7 @@ com.google.cloud google-cloud-vision - 0.14.0-beta + 0.17.1-beta diff --git a/vision/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/cloud-client/src/main/java/com/example/vision/Detect.java index bf06b7a276d..c07bc70e7f6 100644 --- a/vision/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/cloud-client/src/main/java/com/example/vision/Detect.java @@ -41,7 +41,7 @@ import com.google.cloud.vision.v1.WebDetection.WebPage; import com.google.cloud.vision.v1.Word; import com.google.protobuf.ByteString; -import org.joda.time.Duration; +import org.threeten.bp.Duration; import java.io.FileInputStream; import java.io.IOException; @@ -210,7 +210,7 @@ public static void detectFacesGcs(String gcsPath, PrintStream out) throws IOExce imageAnnotatorSettingsBuilder .batchAnnotateImagesSettings() .getRetrySettingsBuilder() - .setTotalTimeout(Duration.standardSeconds(30)); + .setTotalTimeout(Duration.ofSeconds(30)); ImageAnnotatorSettings settings = imageAnnotatorSettingsBuilder.build(); ImageSource imgSource = ImageSource.newBuilder().setGcsImageUri(gcsPath).build();