Skip to content

Commit dfb4142

Browse files
gguusslesv
authored andcommitted
Vision speech upgrade (GoogleCloudPlatform#641)
* Fixes dependencies and class package changes. * Guava exclusions so Truth doesn't conflict with Cloud Client * Upgrades vision to 0.17.1
1 parent 2182970 commit dfb4142

File tree

5 files changed

+59
-22
lines changed

5 files changed

+59
-22
lines changed

speech/cloud-client/README.md

+11-14
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,33 @@ Install [Maven](http://maven.apache.org/).
1515

1616
Build your project with:
1717

18-
mvn clean package -DskipTests
19-
20-
You can then run a given `ClassName` via:
21-
22-
mvn exec:java -Dexec.mainClass=com.example.speech.ClassName
18+
mvn clean compile assembly:single
2319

2420
### Transcribe a local audio file (using the quickstart sample)
2521

26-
mvn exec:java -Dexec.mainClass=com.example.speech.QuickstartSample
22+
java -cp target/speech-google-cloud-samples-1.0.0-jar-with-dependencies.jar \
23+
com.example.speech.QuickstartSample
2724

2825
### Transcribe a local audio file (using the recognize sample)
2926
```
30-
mvn exec:java -Dexec.mainClass=com.example.speech.Recognize \
31-
-Dexec.args="syncrecognize ./resources/audio.raw"
27+
java -cp target/speech-google-cloud-samples-1.0.0-jar-with-dependencies.jar \
28+
com.example.speech.Recognize syncrecognize ./resources/audio.raw
3229
```
3330

3431
### Asynchronously transcribe a local audio file (using the recognize sample)
3532
```
36-
mvn exec:java -Dexec.mainClass=com.example.speech.Recognize \
37-
-Dexec.args="asyncrecognize ./resources/audio.raw"
33+
java -cp target/speech-google-cloud-samples-1.0.0-jar-with-dependencies.jar \
34+
com.example.speech.Recognize asyncrecognize ./resources/audio.raw
3835
```
3936

4037
### Transcribe a remote audio file (using the recognize sample)
4138
```
42-
mvn exec:java -Dexec.mainClass=com.example.speech.Recognize \
43-
-Dexec.args="syncrecognize 'gs://cloud-samples-tests/speech/brooklyn.flac'"
39+
java -cp target/speech-google-cloud-samples-1.0.0-jar-with-dependencies.jar \
40+
com.example.speech.Recognize syncrecognize gs://cloud-samples-tests/speech/brooklyn.flac
4441
```
4542

4643
### Asynchronously transcribe a remote audio file (using the recognize sample)
4744
```
48-
mvn exec:java -Dexec.mainClass=com.example.speech.Recognize \
49-
-Dexec.args="asyncrecognize 'gs://cloud-samples-tests/speech/vr.flac'"
45+
java -cp target/speech-google-cloud-samples-1.0.0-jar-with-dependencies.jar \
46+
com.example.speech.Recognize asyncrecognize gs://cloud-samples-tests/speech/vr.flac
5047
```

speech/cloud-client/pom.xml

+44-4
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
</parent>
2929

3030
<properties>
31-
<maven.compiler.target>1.8</maven.compiler.target>
32-
<maven.compiler.source>1.8</maven.compiler.source>
31+
<maven.compiler.target>1.7</maven.compiler.target>
32+
<maven.compiler.source>1.7</maven.compiler.source>
3333
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3434
</properties>
3535

@@ -50,8 +50,30 @@
5050
<!-- [START dependencies] -->
5151
<dependency>
5252
<groupId>com.google.cloud</groupId>
53-
<artifactId>google-cloud</artifactId>
54-
<version>0.14.0-alpha</version>
53+
<artifactId>google-cloud-speech</artifactId>
54+
<version>0.17.1-alpha</version>
55+
</dependency>
56+
<dependency>
57+
<groupId>com.google.api</groupId>
58+
<artifactId>gax</artifactId>
59+
<version>1.0.0</version>
60+
<exclusions>
61+
<exclusion> <!-- exclude an old version of Guava -->
62+
<groupId>com.google.guava</groupId>
63+
<artifactId>*</artifactId>
64+
</exclusion>
65+
</exclusions>
66+
</dependency>
67+
<dependency>
68+
<groupId>com.google.api</groupId>
69+
<artifactId>gax-grpc</artifactId>
70+
<version>0.16.0</version>
71+
<exclusions>
72+
<exclusion> <!-- exclude an old version of Guava -->
73+
<groupId>com.google.guava</groupId>
74+
<artifactId>*</artifactId>
75+
</exclusion>
76+
</exclusions>
5577
</dependency>
5678
<!-- [END dependencies] -->
5779

@@ -69,4 +91,22 @@
6991
<scope>test</scope>
7092
</dependency>
7193
</dependencies>
94+
95+
<build>
96+
<plugins>
97+
<plugin>
98+
<artifactId>maven-assembly-plugin</artifactId>
99+
<configuration>
100+
<archive>
101+
<manifest>
102+
<mainClass>com.example.language.QuickstartSample</mainClass>
103+
</manifest>
104+
</archive>
105+
<descriptorRefs>
106+
<descriptorRef>jar-with-dependencies</descriptorRef>
107+
</descriptorRefs>
108+
</configuration>
109+
</plugin>
110+
</plugins>
111+
</build>
72112
</project>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package com.example.speech;
1818

19-
import com.google.api.gax.core.ApiStreamObserver;
19+
import com.google.api.gax.grpc.ApiStreamObserver;
2020
import com.google.api.gax.grpc.OperationFuture;
2121
import com.google.api.gax.grpc.StreamingCallable;
2222
import com.google.cloud.speech.spi.v1.SpeechClient;

vision/cloud-client/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<dependency>
3939
<groupId>com.google.cloud</groupId>
4040
<artifactId>google-cloud-vision</artifactId>
41-
<version>0.14.0-beta</version>
41+
<version>0.17.1-beta</version>
4242
</dependency>
4343
<!-- [END dependencies] -->
4444

vision/cloud-client/src/main/java/com/example/vision/Detect.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import com.google.cloud.vision.v1.WebDetection.WebPage;
4242
import com.google.cloud.vision.v1.Word;
4343
import com.google.protobuf.ByteString;
44-
import org.joda.time.Duration;
44+
import org.threeten.bp.Duration;
4545

4646
import java.io.FileInputStream;
4747
import java.io.IOException;
@@ -210,7 +210,7 @@ public static void detectFacesGcs(String gcsPath, PrintStream out) throws IOExce
210210
imageAnnotatorSettingsBuilder
211211
.batchAnnotateImagesSettings()
212212
.getRetrySettingsBuilder()
213-
.setTotalTimeout(Duration.standardSeconds(30));
213+
.setTotalTimeout(Duration.ofSeconds(30));
214214
ImageAnnotatorSettings settings = imageAnnotatorSettingsBuilder.build();
215215

216216
ImageSource imgSource = ImageSource.newBuilder().setGcsImageUri(gcsPath).build();

0 commit comments

Comments
 (0)