Skip to content

Commit fc5cd9a

Browse files
authored
Merge pull request #322 from GoogleCloudPlatform/tswast-speech
2 parents b466427 + 103aaed commit fc5cd9a

File tree

4 files changed

+103
-70
lines changed

4 files changed

+103
-70
lines changed

speech/grpc/pom.xml

+40-19
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ limitations under the License.
4949
<properties>
5050
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5151
<codehaus-versions-maven-plugin-version>2.2</codehaus-versions-maven-plugin-version>
52-
<maven-compiler-plugin-version>3.1</maven-compiler-plugin-version>
52+
<grpc-protobuf-version>1.0.0</grpc-protobuf-version>
53+
<maven-compiler-plugin-version>3.5.1</maven-compiler-plugin-version>
5354
<xolstice-protobuf-maven-plugin-version>0.5.0</xolstice-protobuf-maven-plugin-version>
5455
</properties>
5556

@@ -126,6 +127,11 @@ limitations under the License.
126127
<artifactId>commons-cli</artifactId>
127128
<version>1.3.1</version>
128129
</dependency>
130+
<dependency>
131+
<groupId>com.google.auth</groupId>
132+
<artifactId>google-auth-library-credentials</artifactId>
133+
<version>0.4.0</version>
134+
</dependency>
129135
<dependency>
130136
<groupId>com.google.auth</groupId>
131137
<artifactId>google-auth-library-oauth2-http</artifactId>
@@ -144,31 +150,46 @@ limitations under the License.
144150
<artifactId>guava</artifactId>
145151
<version>19.0</version>
146152
</dependency>
153+
<dependency>
154+
<groupId>com.google.truth</groupId>
155+
<artifactId>truth</artifactId>
156+
<version>0.29</version>
157+
<scope>test</scope>
158+
</dependency>
159+
<dependency>
160+
<groupId>io.grpc</groupId>
161+
<artifactId>grpc-auth</artifactId>
162+
<version>1.0.0</version>
163+
</dependency>
147164
<dependency>
148165
<groupId>io.grpc</groupId>
149-
<artifactId>grpc-all</artifactId>
150-
<version>0.15.0</version>
166+
<artifactId>grpc-netty</artifactId>
167+
<version>1.0.0</version>
168+
</dependency>
169+
<dependency>
170+
<groupId>io.grpc</groupId>
171+
<artifactId>grpc-protobuf</artifactId>
172+
<version>${grpc-protobuf-version}</version>
173+
</dependency>
174+
<dependency>
175+
<groupId>io.grpc</groupId>
176+
<artifactId>grpc-stub</artifactId>
177+
<version>1.0.0</version>
151178
</dependency>
152179
<dependency>
153180
<!--
154-
It is recommended to use OpenSSL: Statically Linked Netty
155-
for transport security. These steps do not use the TLS that
156-
comes with JDK (Jetty APLN/NPN), which is not
157-
recommended. See
158-
https://github.com/grpc/grpc-java/blob/master/SECURITY.md
159-
for details.
160-
-->
181+
- It is recommended to use OpenSSL: Statically Linked Netty
182+
- for transport security. These steps do not use the TLS that
183+
- comes with JDK (Jetty APLN/NPN), which is not
184+
- recommended. See
185+
- https://github.com/grpc/grpc-java/blob/master/SECURITY.md
186+
- for details.
187+
- -->
161188
<groupId>io.netty</groupId>
162189
<artifactId>netty-tcnative-boringssl-static</artifactId>
163-
<version>1.1.33.Fork20</version>
190+
<version>1.1.33.Fork21</version>
164191
<classifier>${tcnative.classifier}</classifier>
165192
</dependency>
166-
<dependency>
167-
<groupId>com.google.truth</groupId>
168-
<artifactId>truth</artifactId>
169-
<version>0.29</version>
170-
<scope>test</scope>
171-
</dependency>
172193
<dependency>
173194
<groupId>log4j</groupId>
174195
<artifactId>log4j</artifactId>
@@ -216,10 +237,10 @@ limitations under the License.
216237
transitively depending on the protobuf-java version that
217238
grpc depends on.
218239
-->
219-
<protocArtifact>com.google.protobuf:protoc:3.0.0-beta-2:exe:${os.detected.classifier}</protocArtifact>
240+
<protocArtifact>com.google.protobuf:protoc:3.0.0:exe:${os.detected.classifier}</protocArtifact>
220241
<pluginId>grpc-java</pluginId>
221242
<protoSourceRoot>${basedir}/src/main/java/third_party</protoSourceRoot>
222-
<pluginArtifact>io.grpc:protoc-gen-grpc-java:0.13.2:exe:${os.detected.classifier}</pluginArtifact>
243+
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc-protobuf-version}:exe:${os.detected.classifier}</pluginArtifact>
223244
</configuration>
224245
<executions>
225246
<execution>

speech/grpc/src/main/java/com/examples/cloud/speech/AsyncRecognizeClient.java

+21-17
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import org.apache.commons.cli.CommandLine;
3636
import org.apache.commons.cli.CommandLineParser;
3737
import org.apache.commons.cli.DefaultParser;
38-
import org.apache.commons.cli.OptionBuilder;
38+
import org.apache.commons.cli.Option;
3939
import org.apache.commons.cli.Options;
4040
import org.apache.commons.cli.ParseException;
4141

@@ -166,29 +166,33 @@ public static void main(String[] args) throws Exception {
166166

167167
Options options = new Options();
168168
options.addOption(
169-
OptionBuilder.withLongOpt("uri")
170-
.withDescription("path to audio uri")
169+
Option.builder()
170+
.longOpt("uri")
171+
.desc("path to audio uri")
171172
.hasArg()
172-
.withArgName("FILE_PATH")
173-
.create());
173+
.argName("FILE_PATH")
174+
.build());
174175
options.addOption(
175-
OptionBuilder.withLongOpt("host")
176-
.withDescription("endpoint for api, e.g. speech.googleapis.com")
176+
Option.builder()
177+
.longOpt("host")
178+
.desc("endpoint for api, e.g. speech.googleapis.com")
177179
.hasArg()
178-
.withArgName("ENDPOINT")
179-
.create());
180+
.argName("ENDPOINT")
181+
.build());
180182
options.addOption(
181-
OptionBuilder.withLongOpt("port")
182-
.withDescription("SSL port, usually 443")
183+
Option.builder()
184+
.longOpt("port")
185+
.desc("SSL port, usually 443")
183186
.hasArg()
184-
.withArgName("PORT")
185-
.create());
187+
.argName("PORT")
188+
.build());
186189
options.addOption(
187-
OptionBuilder.withLongOpt("sampling")
188-
.withDescription("Sampling Rate, i.e. 16000")
190+
Option.builder()
191+
.longOpt("sampling")
192+
.desc("Sampling Rate, i.e. 16000")
189193
.hasArg()
190-
.withArgName("RATE")
191-
.create());
194+
.argName("RATE")
195+
.build());
192196

193197
try {
194198
CommandLine line = parser.parse(options, args);

speech/grpc/src/main/java/com/examples/cloud/speech/StreamingRecognizeClient.java

+21-17
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import org.apache.commons.cli.CommandLine;
3434
import org.apache.commons.cli.CommandLineParser;
3535
import org.apache.commons.cli.DefaultParser;
36-
import org.apache.commons.cli.OptionBuilder;
36+
import org.apache.commons.cli.Option;
3737
import org.apache.commons.cli.Options;
3838
import org.apache.commons.cli.ParseException;
3939
import org.apache.log4j.ConsoleAppender;
@@ -180,29 +180,33 @@ public static void main(String[] args) throws Exception {
180180

181181
Options options = new Options();
182182
options.addOption(
183-
OptionBuilder.withLongOpt("file")
184-
.withDescription("path to audio file")
183+
Option.builder()
184+
.longOpt("file")
185+
.desc("path to audio file")
185186
.hasArg()
186-
.withArgName("FILE_PATH")
187-
.create());
187+
.argName("FILE_PATH")
188+
.build());
188189
options.addOption(
189-
OptionBuilder.withLongOpt("host")
190-
.withDescription("endpoint for api, e.g. speech.googleapis.com")
190+
Option.builder()
191+
.longOpt("host")
192+
.desc("endpoint for api, e.g. speech.googleapis.com")
191193
.hasArg()
192-
.withArgName("ENDPOINT")
193-
.create());
194+
.argName("ENDPOINT")
195+
.build());
194196
options.addOption(
195-
OptionBuilder.withLongOpt("port")
196-
.withDescription("SSL port, usually 443")
197+
Option.builder()
198+
.longOpt("port")
199+
.desc("SSL port, usually 443")
197200
.hasArg()
198-
.withArgName("PORT")
199-
.create());
201+
.argName("PORT")
202+
.build());
200203
options.addOption(
201-
OptionBuilder.withLongOpt("sampling")
202-
.withDescription("Sampling Rate, i.e. 16000")
204+
Option.builder()
205+
.longOpt("sampling")
206+
.desc("Sampling Rate, i.e. 16000")
203207
.hasArg()
204-
.withArgName("RATE")
205-
.create());
208+
.argName("RATE")
209+
.build());
206210

207211
try {
208212
CommandLine line = parser.parse(options, args);

speech/grpc/src/main/java/com/examples/cloud/speech/SyncRecognizeClient.java

+21-17
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.apache.commons.cli.CommandLine;
3131
import org.apache.commons.cli.CommandLineParser;
3232
import org.apache.commons.cli.DefaultParser;
33-
import org.apache.commons.cli.OptionBuilder;
33+
import org.apache.commons.cli.Option;
3434
import org.apache.commons.cli.Options;
3535
import org.apache.commons.cli.ParseException;
3636

@@ -117,29 +117,33 @@ public static void main(String[] args) throws Exception {
117117

118118
Options options = new Options();
119119
options.addOption(
120-
OptionBuilder.withLongOpt("uri")
121-
.withDescription("path to audio uri")
120+
Option.builder()
121+
.longOpt("uri")
122+
.desc("path to audio uri")
122123
.hasArg()
123-
.withArgName("FILE_PATH")
124-
.create());
124+
.argName("FILE_PATH")
125+
.build());
125126
options.addOption(
126-
OptionBuilder.withLongOpt("host")
127-
.withDescription("endpoint for api, e.g. speech.googleapis.com")
127+
Option.builder()
128+
.longOpt("host")
129+
.desc("endpoint for api, e.g. speech.googleapis.com")
128130
.hasArg()
129-
.withArgName("ENDPOINT")
130-
.create());
131+
.argName("ENDPOINT")
132+
.build());
131133
options.addOption(
132-
OptionBuilder.withLongOpt("port")
133-
.withDescription("SSL port, usually 443")
134+
Option.builder()
135+
.longOpt("port")
136+
.desc("SSL port, usually 443")
134137
.hasArg()
135-
.withArgName("PORT")
136-
.create());
138+
.argName("PORT")
139+
.build());
137140
options.addOption(
138-
OptionBuilder.withLongOpt("sampling")
139-
.withDescription("Sampling Rate, i.e. 16000")
141+
Option.builder()
142+
.longOpt("sampling")
143+
.desc("Sampling Rate, i.e. 16000")
140144
.hasArg()
141-
.withArgName("RATE")
142-
.create());
145+
.argName("RATE")
146+
.build());
143147

144148
try {
145149
CommandLine line = parser.parse(options, args);

0 commit comments

Comments
 (0)