Skip to content

Commit

Permalink
Vision speech upgrade (#641)
Browse files Browse the repository at this point in the history
* Fixes dependencies and class package changes.

* Guava exclusions so Truth doesn't conflict with Cloud Client

* Upgrades vision to 0.17.1
  • Loading branch information
gguuss authored and lesv committed May 2, 2017
1 parent 2182970 commit dfb4142
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 22 deletions.
25 changes: 11 additions & 14 deletions speech/cloud-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
48 changes: 44 additions & 4 deletions speech/cloud-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
</parent>

<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand All @@ -50,8 +50,30 @@
<!-- [START dependencies] -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud</artifactId>
<version>0.14.0-alpha</version>
<artifactId>google-cloud-speech</artifactId>
<version>0.17.1-alpha</version>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion> <!-- exclude an old version of Guava -->
<groupId>com.google.guava</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
<version>0.16.0</version>
<exclusions>
<exclusion> <!-- exclude an old version of Guava -->
<groupId>com.google.guava</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- [END dependencies] -->

Expand All @@ -69,4 +91,22 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.example.language.QuickstartSample</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion vision/cloud-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-vision</artifactId>
<version>0.14.0-beta</version>
<version>0.17.1-beta</version>
</dependency>
<!-- [END dependencies] -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit dfb4142

Please sign in to comment.