diff --git a/pom.xml b/pom.xml
index 21c270794d4..f8c1c03c096 100644
--- a/pom.xml
+++ b/pom.xml
@@ -69,6 +69,7 @@
managed_vms/twilio
monitoring/v2
monitoring/v3
+ speech/grpc
storage/json-api
storage/storage-transfer
storage/xml-api/cmdline-sample
diff --git a/speech/README.md b/speech/README.md
new file mode 100644
index 00000000000..b18c66d1909
--- /dev/null
+++ b/speech/README.md
@@ -0,0 +1,8 @@
+# Cloud Pub/Sub samples for Java
+
+This directory contains several samples for the [Cloud Speech API](https://cloud.google.com/speech/)
+with Java.
+
+- [grpc](grpc)
+
+ A sample for accessing Cloud Speech streaming and non streaming apis with [gRPC](http://www.grpc.io/).
diff --git a/speech/grpc/README.md b/speech/grpc/README.md
new file mode 100644
index 00000000000..68c66975fa4
--- /dev/null
+++ b/speech/grpc/README.md
@@ -0,0 +1,100 @@
+# Cloud Speech API gRPC samples for Java
+
+This is a sample repo for accessing the [Google Cloud Speech API](http://cloud.google.com/speech) with
+[gRPC](http://www.grpc.io/) client library.
+
+
+## Prerequisites
+
+### Enable the Speech API
+
+If you have not already done so, [enable the Google Cloud Speech API for your project](https://console.developers.google.com/apis/api/speech.googleapis.com/overview).
+You must be whitelisted to do this.
+
+
+### Download and install Java and Maven
+
+Install [Java7 or
+higher](http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html).
+
+This sample uses the [Apache Maven][maven] build system. Before getting started, be
+sure to [download][maven-download] and [install][maven-install] it. When you use
+Maven as described here, it will automatically download the needed client
+libraries.
+
+[maven]: https://maven.apache.org
+[maven-download]: https://maven.apache.org/download.cgi
+[maven-install]: https://maven.apache.org/install.html
+
+
+### Set Up to Authenticate With Your Project's Credentials
+
+The example uses a service account for OAuth2 authentication.
+So next, set up to authenticate with the Speech API using your project's
+service account credentials.
+
+Visit the [Cloud Console](https://console.developers.google.com), and navigate to:
+`API Manager > Credentials > Create credentials >
+Service account key > New service account`.
+Create a new service account, and download the json credentials file.
+
+Then, set
+the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to point to your
+downloaded service account credentials before running this example:
+
+ export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/credentials-key.json
+
+If you do not do this, you will see an error that looks something like this when
+you run the example scripts:
+`WARNING: RPC failed: Status{code=PERMISSION_DENIED, description=Request had insufficient authentication scopes., cause=null}`.
+See the
+[Cloud Platform Auth Guide](https://cloud.google.com/docs/authentication#developer_workflow)
+for more information.
+
+## Build the application
+
+Then, build the program:
+
+```sh
+$ mvn package
+```
+
+or
+
+```sh
+$ mvn compile
+$ mvn assembly:single
+```
+
+## Run the clients
+
+These programs return the transcription of the audio file you provided. Please
+note that the audio file must be in RAW format. You can use `sox`
+(available, e.g. via [http://sox.sourceforge.net/](http://sox.sourceforge.net/)
+or [homebrew](http://brew.sh/)) to convert audio files to raw format.
+
+### Run the non-streaming client
+
+You can run the batch client like this:
+
+```sh
+$ bin/speech-sample-nonstreaming.sh --host=speech.googleapis.com --port=443 \
+--file= --sampling=
+```
+
+Try a streaming rate of 16000 and the included sample audio file, as follows:
+
+```sh
+$ bin/speech-sample-nonstreaming.sh --host=speech.googleapis.com --port=443 \
+--file=resources/audio.raw --sampling=16000
+```
+
+### Run the streaming client
+
+You can run the streaming client as follows:
+
+```sh
+$ bin/speech-sample-streaming.sh --host=speech.googleapis.com --port=443 \
+--file=resources/audio.raw --sampling=16000
+```
+
diff --git a/speech/grpc/bin/speech-sample-nonstreaming.sh b/speech/grpc/bin/speech-sample-nonstreaming.sh
new file mode 100755
index 00000000000..8ee85a008f5
--- /dev/null
+++ b/speech/grpc/bin/speech-sample-nonstreaming.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Copyright 2016 Google Inc. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+SRC_DIR=$(cd "$(dirname "$0")/.."; pwd)
+java -cp ${SRC_DIR}/target/grpc-sample-1.0-jar-with-dependencies.jar \
+ com.google.cloud.speech.grpc.demos.NonStreamingRecognizeClient "$@"
diff --git a/speech/grpc/bin/speech-sample-streaming.sh b/speech/grpc/bin/speech-sample-streaming.sh
new file mode 100755
index 00000000000..351c17e6cd5
--- /dev/null
+++ b/speech/grpc/bin/speech-sample-streaming.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Copyright 2016 Google Inc. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+SRC_DIR=$(cd "$(dirname "$0")/.."; pwd)
+java -cp ${SRC_DIR}/target/grpc-sample-1.0-jar-with-dependencies.jar \
+ com.google.cloud.speech.grpc.demos.RecognizeClient "$@"
diff --git a/speech/grpc/pom.xml b/speech/grpc/pom.xml
new file mode 100644
index 00000000000..c1853902515
--- /dev/null
+++ b/speech/grpc/pom.xml
@@ -0,0 +1,248 @@
+
+
+ 4.0.0
+
+ com.google.cloud.speech
+ grpc-sample
+ 1.0
+ jar
+
+ speech-grpc-sample
+ https://cloud.google.com/speech/
+ 2016
+
+
+
+ Apache 2
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
+
+
+ Google
+ http://www.google.com
+
+
+
+ com.google.cloud
+ doc-samples
+ 1.0.0
+ ../..
+
+
+
+ UTF-8
+
+
+
+
+ staged
+
+
+ snapshots-repo
+ https://oss.sonatype.org/content/repositories/snapshots
+
+ false
+
+
+ true
+
+
+
+
+
+ jdk7
+
+ 1.7
+
+
+ 1.7
+
+
+
+ jdk8
+
+ 1.8
+
+
+ 1.8
+
+
+
+ fedora
+
+
+ os.detected.classifier
+ os.detected.release.fedora
+
+
+
+ ${os.detected.classifier}-fedora
+
+
+
+ non-fedora
+
+
+ os.detected.classifier
+ !os.detected.release.fedora
+
+
+
+ ${os.detected.classifier}
+
+
+
+
+
+
+
+ commons-cli
+ commons-cli
+ 1.3.1
+
+
+ com.google.guava
+ guava
+ 19.0
+
+
+ io.grpc
+ grpc-all
+ 0.13.2
+
+
+ com.google.oauth-client
+ google-oauth-client
+ 1.21.0
+
+
+
+ io.netty
+ netty-tcnative-boringssl-static
+ 1.1.33.Fork14
+ ${tcnative.classifier}
+
+
+
+
+
+
+
+ never
+
+
+ false
+
+ central
+ Central Repository
+ https://repo.maven.apache.org/maven2
+
+
+ protoc-plugin
+ https://dl.bintray.com/sergei-ivanov/maven/
+
+
+
+
+
+
+ kr.motd.maven
+ os-maven-plugin
+ 1.4.1.Final
+
+
+
+
+
+ org.xolstice.maven.plugins
+ protobuf-maven-plugin
+ 0.5.0
+
+
+ com.google.protobuf:protoc:3.0.0-beta-2:exe:${os.detected.classifier}
+ grpc-java
+ io.grpc:protoc-gen-grpc-java:0.13.2:exe:${os.detected.classifier}
+
+
+
+
+ compile
+ compile-custom
+
+
+
+
+
+ org.codehaus.mojo
+ versions-maven-plugin
+ 2.1
+
+
+ compile
+
+ display-dependency-updates
+
+
+
+
+
+ maven-compiler-plugin
+ 3.1
+
+ ${jdk.version}
+ ${jdk.version}
+ true
+ false
+ -Xlint:-options
+
+
+
+ maven-assembly-plugin
+
+
+ jar-with-dependencies
+
+
+
+
+ simple-command
+ package
+
+ attached
+
+
+
+
+
+
+
+
+
diff --git a/speech/grpc/resources/audio.raw b/speech/grpc/resources/audio.raw
new file mode 100644
index 00000000000..5ebf79d3c9c
Binary files /dev/null and b/speech/grpc/resources/audio.raw differ
diff --git a/speech/grpc/src/main/java/com/google/cloud/speech/grpc/demos/NonStreamingRecognizeClient.java b/speech/grpc/src/main/java/com/google/cloud/speech/grpc/demos/NonStreamingRecognizeClient.java
new file mode 100644
index 00000000000..3e413a71fa3
--- /dev/null
+++ b/speech/grpc/src/main/java/com/google/cloud/speech/grpc/demos/NonStreamingRecognizeClient.java
@@ -0,0 +1,213 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Client that sends audio to Speech.NonStreamingRecognize via gRPC and returns transcription.
+//
+// Uses a service account for OAuth2 authentication, which you may obtain at
+// https://console.developers.google.com
+// API Manager > Google Cloud Speech API > Enable
+// API Manager > Credentials > Create credentials > Service account key > New service account.
+//
+// Then set environment variable GOOGLE_APPLICATION_CREDENTIALS to the full path of that file.
+
+package com.google.cloud.speech.grpc.demos;
+
+import com.google.auth.oauth2.GoogleCredentials;
+import com.google.cloud.speech.v1.AudioRequest;
+import com.google.cloud.speech.v1.InitialRecognizeRequest;
+import com.google.cloud.speech.v1.InitialRecognizeRequest.AudioEncoding;
+import com.google.cloud.speech.v1.NonStreamingRecognizeResponse;
+import com.google.cloud.speech.v1.RecognizeRequest;
+import com.google.cloud.speech.v1.SpeechGrpc;
+import com.google.protobuf.ByteString;
+import com.google.protobuf.TextFormat;
+
+import io.grpc.ManagedChannel;
+import io.grpc.StatusRuntimeException;
+import io.grpc.auth.ClientAuthInterceptor;
+import io.grpc.netty.NegotiationType;
+import io.grpc.netty.NettyChannelBuilder;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Client that sends audio to Speech.NonStreamingRecognize and returns transcript.
+ */
+public class NonStreamingRecognizeClient {
+
+ private static final Logger logger =
+ Logger.getLogger(NonStreamingRecognizeClient.class.getName());
+
+ private static final List OAUTH2_SCOPES =
+ Arrays.asList("https://www.googleapis.com/auth/xapi.zoo");
+
+ private final String host;
+ private final int port;
+ private final String file;
+ private final int samplingRate;
+
+ private final ManagedChannel channel;
+ private final SpeechGrpc.SpeechBlockingStub blockingStub;
+
+ /**
+ * Construct client connecting to Cloud Speech server at {@code host:port}.
+ */
+ public NonStreamingRecognizeClient(String host, int port, String file, int samplingRate)
+ throws IOException {
+ this.host = host;
+ this.port = port;
+ this.file = file;
+ this.samplingRate = samplingRate;
+
+ GoogleCredentials creds = GoogleCredentials.getApplicationDefault();
+ creds = creds.createScoped(OAUTH2_SCOPES);
+ channel = NettyChannelBuilder.forAddress(host, port)
+ .negotiationType(NegotiationType.TLS)
+ .intercept(new ClientAuthInterceptor(creds, Executors.newSingleThreadExecutor()))
+ .build();
+ blockingStub = SpeechGrpc.newBlockingStub(channel);
+ logger.info("Created blockingStub for " + host + ":" + port);
+ }
+
+ private AudioRequest createAudioRequest() throws IOException {
+ Path path = Paths.get(file);
+ return AudioRequest.newBuilder()
+ .setContent(ByteString.copyFrom(Files.readAllBytes(path)))
+ .build();
+ }
+
+ public void shutdown() throws InterruptedException {
+ channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
+ }
+
+ /** Send a non-streaming-recognize request to server. */
+ public void recognize() {
+ AudioRequest audio;
+ try {
+ audio = createAudioRequest();
+ } catch (IOException e) {
+ logger.log(Level.WARNING, "Failed to read audio file: " + file);
+ return;
+ }
+ logger.info("Sending " + audio.getContent().size() + " bytes from audio file: " + file);
+ InitialRecognizeRequest initial = InitialRecognizeRequest.newBuilder()
+ .setEncoding(AudioEncoding.LINEAR16)
+ .setSampleRate(samplingRate)
+ .build();
+ RecognizeRequest request = RecognizeRequest.newBuilder()
+ .setInitialRequest(initial)
+ .setAudioRequest(audio)
+ .build();
+ NonStreamingRecognizeResponse response;
+ try {
+ response = blockingStub.nonStreamingRecognize(request);
+ } catch (StatusRuntimeException e) {
+ logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus());
+ return;
+ }
+ logger.info("Received response: " + TextFormat.printToString(response));
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ String audioFile = "";
+ String host = "speech.googleapis.com";
+ Integer port = 443;
+ Integer sampling = 16000;
+
+ CommandLineParser parser = new DefaultParser();
+
+ Options options = new Options();
+ options.addOption(OptionBuilder.withLongOpt("file")
+ .withDescription("path to audio file")
+ .hasArg()
+ .withArgName("FILE_PATH")
+ .create());
+ options.addOption(OptionBuilder.withLongOpt("host")
+ .withDescription("endpoint for api, e.g. speech.googleapis.com")
+ .hasArg()
+ .withArgName("ENDPOINT")
+ .create());
+ options.addOption(OptionBuilder.withLongOpt("port")
+ .withDescription("SSL port, usually 443")
+ .hasArg()
+ .withArgName("PORT")
+ .create());
+ options.addOption(OptionBuilder.withLongOpt("sampling")
+ .withDescription("Sampling Rate, i.e. 16000")
+ .hasArg()
+ .withArgName("RATE")
+ .create());
+
+ try {
+ CommandLine line = parser.parse(options, args);
+ if (line.hasOption("file")) {
+ audioFile = line.getOptionValue("file");
+ } else {
+ System.err.println("An Audio file path must be specified (e.g. /foo/baz.raw).");
+ System.exit(1);
+ }
+
+ if (line.hasOption("host")) {
+ host = line.getOptionValue("host");
+ } else {
+ System.err.println("An API enpoint must be specified (typically speech.googleapis.com).");
+ System.exit(1);
+ }
+
+ if (line.hasOption("port")) {
+ port = Integer.parseInt(line.getOptionValue("port"));
+ } else {
+ System.err.println("An SSL port must be specified (typically 443).");
+ System.exit(1);
+ }
+
+ if (line.hasOption("sampling")) {
+ sampling = Integer.parseInt(line.getOptionValue("sampling"));
+ } else {
+ System.err.println("An Audio sampling rate must be specified.");
+ System.exit(1);
+ }
+ } catch (ParseException exp) {
+ System.err.println("Unexpected exception:" + exp.getMessage());
+ System.exit(1);
+ }
+
+ NonStreamingRecognizeClient client =
+ new NonStreamingRecognizeClient(host, port, audioFile, sampling);
+ try {
+ client.recognize();
+ } finally {
+ client.shutdown();
+ }
+ }
+}
diff --git a/speech/grpc/src/main/java/com/google/cloud/speech/grpc/demos/RecognizeClient.java b/speech/grpc/src/main/java/com/google/cloud/speech/grpc/demos/RecognizeClient.java
new file mode 100644
index 00000000000..e6cd8dd737b
--- /dev/null
+++ b/speech/grpc/src/main/java/com/google/cloud/speech/grpc/demos/RecognizeClient.java
@@ -0,0 +1,247 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Client sends streaming audio to Speech.Recognize via gRPC and returns streaming transcription.
+//
+// Uses a service account for OAuth2 authentication, which you may obtain at
+// https://console.developers.google.com
+// API Manager > Google Cloud Speech API > Enable
+// API Manager > Credentials > Create credentials > Service account key > New service account.
+//
+// Then set environment variable GOOGLE_APPLICATION_CREDENTIALS to the full path of that file.
+
+package com.google.cloud.speech.grpc.demos;
+
+import com.google.auth.oauth2.GoogleCredentials;
+import com.google.cloud.speech.v1.AudioRequest;
+import com.google.cloud.speech.v1.InitialRecognizeRequest;
+import com.google.cloud.speech.v1.InitialRecognizeRequest.AudioEncoding;
+import com.google.cloud.speech.v1.RecognizeRequest;
+import com.google.cloud.speech.v1.RecognizeResponse;
+import com.google.cloud.speech.v1.SpeechGrpc;
+import com.google.protobuf.ByteString;
+import com.google.protobuf.TextFormat;
+
+import io.grpc.ManagedChannel;
+import io.grpc.Status;
+import io.grpc.auth.ClientAuthInterceptor;
+import io.grpc.netty.NegotiationType;
+import io.grpc.netty.NettyChannelBuilder;
+import io.grpc.stub.StreamObserver;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Client that sends streaming audio to Speech.Recognize and returns streaming transcript.
+ */
+public class RecognizeClient {
+
+ private final String host;
+ private final int port;
+ private final String file;
+ private final int samplingRate;
+
+ private static final Logger logger =
+ Logger.getLogger(RecognizeClient.class.getName());
+
+ private final ManagedChannel channel;
+
+ private final SpeechGrpc.SpeechStub stub;
+
+ private static final List OAUTH2_SCOPES =
+ Arrays.asList("https://www.googleapis.com/auth/xapi.zoo");
+
+ /**
+ * Construct client connecting to Cloud Speech server at {@code host:port}.
+ */
+ public RecognizeClient(String host, int port, String file, int samplingRate) throws IOException {
+ this.host = host;
+ this.port = port;
+ this.file = file;
+ this.samplingRate = samplingRate;
+
+ GoogleCredentials creds = GoogleCredentials.getApplicationDefault();
+ creds = creds.createScoped(OAUTH2_SCOPES);
+ channel = NettyChannelBuilder.forAddress(host, port)
+ .negotiationType(NegotiationType.TLS)
+ .intercept(new ClientAuthInterceptor(creds, Executors.newSingleThreadExecutor()))
+ .build();
+ stub = SpeechGrpc.newStub(channel);
+ logger.info("Created stub for " + host + ":" + port);
+ }
+
+ public void shutdown() throws InterruptedException {
+ channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
+ }
+
+ /** Send streaming recognize requests to server. */
+ public void recognize() throws InterruptedException, IOException {
+ final CountDownLatch finishLatch = new CountDownLatch(1);
+ StreamObserver responseObserver = new StreamObserver() {
+ @Override
+ public void onNext(RecognizeResponse response) {
+ logger.info("Received response: " + TextFormat.printToString(response));
+ }
+
+ @Override
+ public void onError(Throwable error) {
+ Status status = Status.fromThrowable(error);
+ logger.log(Level.WARNING, "recognize failed: {0}", status);
+ finishLatch.countDown();
+ }
+
+ @Override
+ public void onCompleted() {
+ logger.info("recognize completed.");
+ finishLatch.countDown();
+ }
+ };
+
+ StreamObserver requestObserver = stub.recognize(responseObserver);
+ try {
+ // Build and send a RecognizeRequest containing the parameters for processing the audio.
+ InitialRecognizeRequest initial = InitialRecognizeRequest.newBuilder()
+ .setEncoding(AudioEncoding.LINEAR16)
+ .setSampleRate(samplingRate)
+ .setInterimResults(true)
+ .build();
+ RecognizeRequest firstRequest = RecognizeRequest.newBuilder()
+ .setInitialRequest(initial)
+ .build();
+ requestObserver.onNext(firstRequest);
+
+ // Open audio file. Read and send sequential buffers of audio as additional RecognizeRequests.
+ FileInputStream in = new FileInputStream(new File(file));
+ // For LINEAR16 at 16000 Hz sample rate, 3200 bytes corresponds to 100 milliseconds of audio.
+ byte[] buffer = new byte[3200];
+ int bytesRead;
+ int totalBytes = 0;
+ while ((bytesRead = in.read(buffer)) != -1) {
+ totalBytes += bytesRead;
+ AudioRequest audio = AudioRequest.newBuilder()
+ .setContent(ByteString.copyFrom(buffer, 0, bytesRead))
+ .build();
+ RecognizeRequest request = RecognizeRequest.newBuilder()
+ .setAudioRequest(audio)
+ .build();
+ requestObserver.onNext(request);
+ // To simulate real-time audio, sleep after sending each audio buffer.
+ // For 16000 Hz sample rate, sleep 100 milliseconds.
+ Thread.sleep(samplingRate / 160);
+ }
+ logger.info("Sent " + totalBytes + " bytes from audio file: " + file);
+ } catch (RuntimeException e) {
+ // Cancel RPC.
+ requestObserver.onError(e);
+ throw e;
+ }
+ // Mark the end of requests.
+ requestObserver.onCompleted();
+
+ // Receiving happens asynchronously.
+ finishLatch.await(1, TimeUnit.MINUTES);
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ String audioFile = "";
+ String host = "speech.googleapis.com";
+ Integer port = 443;
+ Integer sampling = 16000;
+
+ CommandLineParser parser = new DefaultParser();
+
+ Options options = new Options();
+ options.addOption(OptionBuilder.withLongOpt("file")
+ .withDescription("path to audio file")
+ .hasArg()
+ .withArgName("FILE_PATH")
+ .create());
+ options.addOption(OptionBuilder.withLongOpt("host")
+ .withDescription("endpoint for api, e.g. speech.googleapis.com")
+ .hasArg()
+ .withArgName("ENDPOINT")
+ .create());
+ options.addOption(OptionBuilder.withLongOpt("port")
+ .withDescription("SSL port, usually 443")
+ .hasArg()
+ .withArgName("PORT")
+ .create());
+ options.addOption(OptionBuilder.withLongOpt("sampling")
+ .withDescription("Sampling Rate, i.e. 16000")
+ .hasArg()
+ .withArgName("RATE")
+ .create());
+
+ try {
+ CommandLine line = parser.parse(options, args);
+ if (line.hasOption("file")) {
+ audioFile = line.getOptionValue("file");
+ } else {
+ System.err.println("An Audio file must be specified (e.g. /foo/baz.raw).");
+ System.exit(1);
+ }
+
+ if (line.hasOption("host")) {
+ host = line.getOptionValue("host");
+ } else {
+ System.err.println("An API enpoint must be specified (typically speech.googleapis.com).");
+ System.exit(1);
+ }
+
+ if (line.hasOption("port")) {
+ port = Integer.parseInt(line.getOptionValue("port"));
+ } else {
+ System.err.println("An SSL port must be specified (typically 443).");
+ System.exit(1);
+ }
+
+ if (line.hasOption("sampling")) {
+ sampling = Integer.parseInt(line.getOptionValue("sampling"));
+ } else {
+ System.err.println("An Audio sampling rate must be specified.");
+ System.exit(1);
+ }
+ } catch (ParseException exp) {
+ System.err.println("Unexpected exception:" + exp.getMessage());
+ System.exit(1);
+ }
+
+ RecognizeClient client =
+ new RecognizeClient(host, port, audioFile, sampling);
+ try {
+ client.recognize();
+ } finally {
+ client.shutdown();
+ }
+ }
+}
diff --git a/speech/grpc/src/main/proto/.gitignore b/speech/grpc/src/main/proto/.gitignore
new file mode 100644
index 00000000000..65267c8e5d7
--- /dev/null
+++ b/speech/grpc/src/main/proto/.gitignore
@@ -0,0 +1,4 @@
+OWNERS
+README.google
+google/internal
+google/protobuf
diff --git a/speech/grpc/src/main/proto/google/api/annotations.proto b/speech/grpc/src/main/proto/google/api/annotations.proto
new file mode 100644
index 00000000000..cbd18b847f3
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/api/annotations.proto
@@ -0,0 +1,29 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/api/http.proto";
+import "google/protobuf/descriptor.proto";
+
+option java_multiple_files = true;
+option java_outer_classname = "AnnotationsProto";
+option java_package = "com.google.api";
+
+extend google.protobuf.MethodOptions {
+ // See `HttpRule`.
+ HttpRule http = 72295728;
+}
diff --git a/speech/grpc/src/main/proto/google/api/http.proto b/speech/grpc/src/main/proto/google/api/http.proto
new file mode 100644
index 00000000000..4bbadbb76d0
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/api/http.proto
@@ -0,0 +1,245 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.api;
+
+option java_multiple_files = true;
+option java_outer_classname = "HttpProto";
+option java_package = "com.google.api";
+
+
+// `HttpRule` defines the mapping of an RPC method to one or more HTTP
+// REST APIs. The mapping determines what portions of the request
+// message are populated from the path, query parameters, or body of
+// the HTTP request. The mapping is typically specified as an
+// `google.api.http` annotation, see "google/api/annotations.proto"
+// for details.
+//
+// The mapping consists of a field specifying the path template and
+// method kind. The path template can refer to fields in the request
+// message, as in the example below which describes a REST GET
+// operation on a resource collection of messages:
+//
+// ```proto
+// service Messaging {
+// rpc GetMessage(GetMessageRequest) returns (Message) {
+// option (google.api.http).get = "/v1/messages/{message_id}";
+// }
+// }
+// message GetMessageRequest {
+// string message_id = 1; // mapped to the URL
+// }
+// message Message {
+// string text = 1; // content of the resource
+// }
+// ```
+//
+// This definition enables an automatic, bidrectional mapping of HTTP
+// JSON to RPC. Example:
+//
+// HTTP | RPC
+// -----|-----
+// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`
+//
+// In general, not only fields but also field paths can be referenced
+// from a path pattern. Fields mapped to the path pattern cannot be
+// repeated and must have a primitive (non-message) type.
+//
+// Any fields in the request message which are not bound by the path
+// pattern automatically become (optional) HTTP query
+// parameters. Assume the following definition of the request message:
+//
+// ```proto
+// message GetMessageRequest {
+// string message_id = 1; // mapped to the URL
+// int64 revision = 2; // becomes a parameter
+// }
+// ```
+//
+// This enables a HTTP JSON to RPC mapping as below:
+//
+// HTTP | RPC
+// -----|-----
+// `GET /v1/messages/123456?revision=2` | `GetMessage(message_id: "123456" revision: 2)`
+//
+// Note that fields which are mapped to HTTP parameters must have a
+// primitive type or a repeated primitive type. Message types are not
+// allowed. In the case of a repeated type, the parameter can be
+// repeated in the URL, as in `...?param=A¶m=B`.
+//
+// For HTTP method kinds which allow a request body, the `body` field
+// specifies the mapping. Consider a REST update method on the
+// message resource collection:
+//
+// ```proto
+// service Messaging {
+// rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
+// option (google.api.http) = {
+// put: "/v1/messages/{message_id}"
+// body: "message"
+// }
+// }
+// message UpdateMessageRequest {
+// string message_id = 1; // mapped to the URL
+// Message message = 2; // mapped to the body
+// }
+// ```
+//
+// The following HTTP JSON to RPC mapping is enabled, where the
+// representation of the JSON in the request body is determined by
+// protos JSON encoding:
+//
+// HTTP | RPC
+// -----|-----
+// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })`
+//
+// The special name `*` can be used in the body mapping to define that
+// every field not bound by the path template should be mapped to the
+// request body. This enables the following alternative definition of
+// the update method:
+//
+// ```proto
+// service Messaging {
+// rpc UpdateMessage(Message) returns (Message) {
+// option (google.api.http) = {
+// put: "/v1/messages/{message_id}"
+// body: "*"
+// }
+// }
+// message Message {
+// string message_id = 2;
+// string text = 2;
+// }
+// ```
+//
+// The following HTTP JSON to RPC mapping is enabled:
+//
+// HTTP | RPC
+// -----|-----
+// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")`
+//
+// Note that when using `*` in the body mapping, it is not possible to
+// have HTTP parameters, as all fields not bound by the path end in
+// the body. This makes this option more rarely used in practice of
+// defining REST APIs. The common usage of `*` is in custom methods
+// which don't use the URL at all for transferring data.
+//
+// It is possible to define multiple HTTP methods for one RPC by using
+// the `additional_bindings` option. Example:
+//
+// ```proto
+// service Messaging {
+// rpc GetMessage(GetMessageRequest) returns (Message) {
+// option (google.api.http) = {
+// get: "/v1/messages/{message_id}"
+// additional_bindings {
+// get: "/v1/users/{user_id}/messages/{message_id}"
+// }
+// }
+// }
+// message GetMessageRequest {
+// string message_id = 1;
+// string user_id = 2;
+// }
+// ```
+//
+// This enables the following two alternative HTTP JSON to RPC
+// mappings:
+//
+// HTTP | RPC
+// -----|-----
+// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`
+// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")`
+//
+// # Rules for HTTP mapping
+// The rules for mapping HTTP path, query parameters, and body fields
+// to the request message are as follows:
+//
+// 1. The `body` field specifies either `*` or a field path, or is
+// omitted. If omitted, it assumes there is no HTTP body.
+// 2. Leaf fields (recursive expansion of nested messages in the
+// request) can be classified into three types:
+// (a) Matched in the URL template.
+// (b) Covered by body (if body is `*`, everything except (a) fields;
+// else everything under the body field)
+// (c) All other fields.
+// 3. URL query parameters found in the HTTP request are mapped to (c) fields.
+// 4. Any body sent with an HTTP request can contain only (b) fields.
+//
+// The syntax of the path template is as follows:
+//
+// Template = "/" Segments [ Verb ] ;
+// Segments = Segment { "/" Segment } ;
+// Segment = "*" | "**" | LITERAL | Variable ;
+// Variable = "{" FieldPath [ "=" Segments ] "}" ;
+// FieldPath = IDENT { "." IDENT } ;
+// Verb = ":" LITERAL ;
+//
+// `*` matches a single path component, `**` zero or more path components, and
+// `LITERAL` a constant. A `Variable` can match an entire path as specified
+// again by a template; this nested template must not contain further variables.
+// If no template is given with a variable, it matches a single path component.
+// The notation `{var}` is henceforth equivalent to `{var=*}`. NOTE: the field
+// paths in variables and in the `body` must not refer to repeated fields.
+//
+// Use CustomHttpPattern to specify any HTTP method that is not included in the
+// pattern field, such as HEAD, or "*" to leave the HTTP method unspecified for
+// a given URL path rule. The wild-card rule is useful for services that provide
+// content to Web (HTML) clients.
+message HttpRule {
+
+ // Determines the URL pattern is matched by this rules. This pattern can be
+ // used with any of the {get|put|post|delete|patch} methods. A custom method
+ // can be defined using the 'custom' field.
+ oneof pattern {
+ // Used for listing and getting information about resources.
+ string get = 2;
+
+ // Used for updating a resource.
+ string put = 3;
+
+ // Used for creating a resource.
+ string post = 4;
+
+ // Used for deleting a resource.
+ string delete = 5;
+
+ // Used for updating a resource.
+ string patch = 6;
+
+ // Custom pattern is used for defining custom verbs.
+ CustomHttpPattern custom = 8;
+ }
+
+ // The name of the request field whose value is mapped to the HTTP body, or
+ // `*` for mapping all fields not captured by the path pattern to the HTTP
+ // body. NOTE: the referred field must not be a repeated field.
+ string body = 7;
+
+ // Additional HTTP bindings for the selector. Nested bindings must
+ // not contain an `additional_bindings` field themselves (that is,
+ // the nesting may only be one level deep).
+ repeated HttpRule additional_bindings = 11;
+}
+
+// A custom pattern is used for defining custom HTTP verb.
+message CustomHttpPattern {
+ // The name of this custom HTTP verb.
+ string kind = 1;
+
+ // The path matched by this custom verb.
+ string path = 2;
+}
diff --git a/speech/grpc/src/main/proto/google/api/label.proto b/speech/grpc/src/main/proto/google/api/label.proto
new file mode 100644
index 00000000000..680bf119423
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/api/label.proto
@@ -0,0 +1,46 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.api;
+
+option java_multiple_files = true;
+option java_outer_classname = "LabelProto";
+option java_package = "com.google.api";
+
+
+// A description of a label.
+message LabelDescriptor {
+ // Value types that can be used as label values.
+ enum ValueType {
+ // A variable-length string. This is the default.
+ STRING = 0;
+
+ // Boolean; true or false.
+ BOOL = 1;
+
+ // A 64-bit signed integer.
+ INT64 = 2;
+ }
+
+ // The label key.
+ string key = 1;
+
+ // The type of data that can be assigned to the label.
+ ValueType value_type = 2;
+
+ // A human-readable description for the label.
+ string description = 3;
+}
diff --git a/speech/grpc/src/main/proto/google/api/monitored_resource.proto b/speech/grpc/src/main/proto/google/api/monitored_resource.proto
new file mode 100644
index 00000000000..16ac9fad3c0
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/api/monitored_resource.proto
@@ -0,0 +1,64 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.api;
+
+import "google/api/label.proto";
+
+option java_multiple_files = true;
+option java_outer_classname = "MonitoredResourceProto";
+option java_package = "com.google.api";
+
+
+// A descriptor that describes the schema of [MonitoredResource][google.api.MonitoredResource].
+message MonitoredResourceDescriptor {
+ // The monitored resource type. For example, the type `"cloudsql_database"`
+ // represents databases in Google Cloud SQL.
+ string type = 1;
+
+ // A concise name for the monitored resource type that can be displayed in
+ // user interfaces. For example, `"Google Cloud SQL Database"`.
+ string display_name = 2;
+
+ // A detailed description of the monitored resource type that can be used in
+ // documentation.
+ string description = 3;
+
+ // A set of labels that can be used to describe instances of this monitored
+ // resource type. For example, Google Cloud SQL databases can be labeled with
+ // their `"database_id"` and their `"zone"`.
+ repeated LabelDescriptor labels = 4;
+}
+
+// A monitored resource describes a resource that can be used for monitoring
+// purpose. It can also be used for logging, billing, and other purposes. Each
+// resource has a `type` and a set of `labels`. The labels contain information
+// that identifies the resource and describes attributes of it. For example,
+// you can use monitored resource to describe a normal file, where the resource
+// has `type` as `"file"`, the label `path` identifies the file, and the label
+// `size` describes the file size. The monitoring system can use a set of
+// monitored resources of files to generate file size distribution.
+message MonitoredResource {
+ // The monitored resource type. This field must match the corresponding
+ // [MonitoredResourceDescriptor.type][google.api.MonitoredResourceDescriptor.type] to this resource.. For example,
+ // `"cloudsql_database"` represents Cloud SQL databases.
+ string type = 1;
+
+ // Values for some or all of the labels listed in the associated monitored
+ // resource descriptor. For example, you specify a specific Cloud SQL database
+ // by supplying values for both the `"database_id"` and `"zone"` labels.
+ map labels = 2;
+}
diff --git a/speech/grpc/src/main/proto/google/logging/README.md b/speech/grpc/src/main/proto/google/logging/README.md
new file mode 100644
index 00000000000..6a414eb07b7
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/logging/README.md
@@ -0,0 +1,2 @@
+# Introduction
+The Google logging service.
diff --git a/speech/grpc/src/main/proto/google/logging/type/http_request.proto b/speech/grpc/src/main/proto/google/logging/type/http_request.proto
new file mode 100644
index 00000000000..bd28a36057c
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/logging/type/http_request.proto
@@ -0,0 +1,69 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.logging.type;
+
+import "google/api/annotations.proto";
+
+option java_multiple_files = true;
+option java_outer_classname = "HttpRequestProto";
+option java_package = "com.google.logging.type";
+
+
+// A common proto for logging HTTP requests.
+//
+message HttpRequest {
+ // The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`.
+ string request_method = 1;
+
+ // The scheme (http, https), the host name, the path and the query
+ // portion of the URL that was requested.
+ // Example: `"http://example.com/some/info?color=red"`.
+ string request_url = 2;
+
+ // The size of the HTTP request message in bytes, including the request
+ // headers and the request body.
+ int64 request_size = 3;
+
+ // The response code indicating the status of response.
+ // Examples: 200, 404.
+ int32 status = 4;
+
+ // The size of the HTTP response message sent back to the client, in bytes,
+ // including the response headers and the response body.
+ int64 response_size = 5;
+
+ // The user agent sent by the client. Example:
+ // `"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET CLR 1.0.3705)"`.
+ string user_agent = 6;
+
+ // The IP address (IPv4 or IPv6) of the client that issued the HTTP
+ // request. Examples: `"192.168.1.1"`, `"FE80::0202:B3FF:FE1E:8329"`.
+ string remote_ip = 7;
+
+ // The referer URL of the request, as defined in
+ // [HTTP/1.1 Header Field Definitions](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
+ string referer = 8;
+
+ // Whether or not an entity was served from cache
+ // (with or without validation).
+ bool cache_hit = 9;
+
+ // Whether or not the response was validated with the origin server before
+ // being served from cache. This field is only meaningful if `cache_hit` is
+ // True.
+ bool validated_with_origin_server = 10;
+}
diff --git a/speech/grpc/src/main/proto/google/logging/type/log_severity.proto b/speech/grpc/src/main/proto/google/logging/type/log_severity.proto
new file mode 100644
index 00000000000..77bdeeac981
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/logging/type/log_severity.proto
@@ -0,0 +1,62 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.logging.type;
+
+import "google/api/annotations.proto";
+
+option java_multiple_files = true;
+option java_outer_classname = "LogSeverityProto";
+option java_package = "com.google.logging.type";
+
+
+// The severity of the event described in a log entry. These guideline severity
+// levels are ordered, with numerically smaller levels treated as less severe
+// than numerically larger levels. If the source of the log entries uses a
+// different set of severity levels, the client should select the closest
+// corresponding `LogSeverity` value. For example, Java's FINE, FINER, and
+// FINEST levels might all map to `LogSeverity.DEBUG`. If the original severity
+// code must be preserved, it can be stored in the payload.
+//
+enum LogSeverity {
+ // The log entry has no assigned severity level.
+ DEFAULT = 0;
+
+ // Debug or trace information.
+ DEBUG = 100;
+
+ // Routine information, such as ongoing status or performance.
+ INFO = 200;
+
+ // Normal but significant events, such as start up, shut down, or
+ // configuration.
+ NOTICE = 300;
+
+ // Warning events might cause problems.
+ WARNING = 400;
+
+ // Error events are likely to cause problems.
+ ERROR = 500;
+
+ // Critical events cause more severe problems or brief outages.
+ CRITICAL = 600;
+
+ // A person must take an action immediately.
+ ALERT = 700;
+
+ // One or more systems are unusable.
+ EMERGENCY = 800;
+}
diff --git a/speech/grpc/src/main/proto/google/logging/v2/log_entry.proto b/speech/grpc/src/main/proto/google/logging/v2/log_entry.proto
new file mode 100644
index 00000000000..5fb8e8e2783
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/logging/v2/log_entry.proto
@@ -0,0 +1,114 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.logging.v2;
+
+import "google/api/annotations.proto";
+import "google/api/monitored_resource.proto";
+import "google/logging/type/http_request.proto";
+import "google/logging/type/log_severity.proto";
+import "google/protobuf/any.proto";
+import "google/protobuf/struct.proto";
+import "google/protobuf/timestamp.proto";
+
+option java_multiple_files = true;
+option java_outer_classname = "LogEntryProto";
+option java_package = "com.google.logging.v2";
+
+
+// An individual entry in a log.
+message LogEntry {
+ // Required. The resource name of the log to which this log entry
+ // belongs. The format of the name is
+ // `projects/<project-id>/logs/<log-id%gt;`. Examples:
+ // `"projects/my-projectid/logs/syslog"`,
+ // `"projects/1234567890/logs/library.googleapis.com%2Fbook_log"`.
+ //
+ // The log ID part of resource name must be less than 512 characters
+ // long and can only include the following characters: upper and
+ // lower case alphanumeric characters: [A-Za-z0-9]; and punctuation
+ // characters: forward-slash, underscore, hyphen, and period.
+ // Forward-slash (`/`) characters in the log ID must be URL-encoded.
+ string log_name = 12;
+
+ // Required. The monitored resource associated with this log entry.
+ // Example: a log entry that reports a database error would be
+ // associated with the monitored resource designating the particular
+ // database that reported the error.
+ google.api.MonitoredResource resource = 8;
+
+ // Required. The log entry payload, which can be one of multiple types.
+ oneof payload {
+ // The log entry payload, represented as a protocol buffer.
+ // You can only use `protoPayload` values that belong to a set of approved
+ // types.
+ google.protobuf.Any proto_payload = 2;
+
+ // The log entry payload, represented as a Unicode string (UTF-8).
+ string text_payload = 3;
+
+ // The log entry payload, represented as a structure that
+ // is expressed as a JSON object.
+ google.protobuf.Struct json_payload = 6;
+ }
+
+ // Optional. The time the event described by the log entry occurred. If
+ // omitted, Cloud Logging will use the time the log entry is written.
+ google.protobuf.Timestamp timestamp = 9;
+
+ // Optional. The severity of the log entry. The default value is
+ // `LogSeverity.DEFAULT`.
+ google.logging.type.LogSeverity severity = 10;
+
+ // Optional. A unique ID for the log entry. If you provide this field, the
+ // logging service considers other log entries in the same log with the same
+ // ID as duplicates which can be removed.
+ // If omitted, Cloud Logging will generate a unique ID for this log entry.
+ string insert_id = 4;
+
+ // Optional. Information about the HTTP request associated with this log entry,
+ // if applicable.
+ google.logging.type.HttpRequest http_request = 7;
+
+ // Optional. A set of user-defined (key, value) data that provides additional
+ // information about the log entry.
+ map labels = 11;
+
+ // Optional. Information about an operation associated with the log entry, if
+ // applicable.
+ LogEntryOperation operation = 15;
+}
+
+// Additional information about a potentially long-running operation with which
+// a log entry is associated.
+message LogEntryOperation {
+ // Required. An arbitrary operation identifier. Log entries with the
+ // same identifier are assumed to be part of the same operation.
+ //
+ string id = 1;
+
+ // Required. An arbitrary producer identifier. The combination of
+ // `id` and `producer` must be globally unique. Examples for `producer`:
+ // `"MyDivision.MyBigCompany.com"`, "github.com/MyProject/MyApplication"`.
+ //
+ string producer = 2;
+
+ // Optional. Set this to True if this is the first log entry in the operation.
+ bool first = 3;
+
+ // Optional. Set this to True if this is the last log entry in the operation.
+ bool last = 4;
+}
diff --git a/speech/grpc/src/main/proto/google/logging/v2/logging.proto b/speech/grpc/src/main/proto/google/logging/v2/logging.proto
new file mode 100644
index 00000000000..44230fcde70
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/logging/v2/logging.proto
@@ -0,0 +1,167 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.logging.v2;
+
+import "google/api/annotations.proto";
+import "google/api/monitored_resource.proto";
+import "google/logging/v2/log_entry.proto";
+import "google/protobuf/empty.proto";
+import "google/rpc/status.proto";
+
+option cc_enable_arenas = true;
+option java_multiple_files = true;
+option java_outer_classname = "LoggingProto";
+option java_package = "com.google.logging.v2";
+
+
+// Service for ingesting and querying logs.
+service LoggingServiceV2 {
+ // Deletes a log and all its log entries.
+ // The log will reappear if it receives new entries.
+ //
+ rpc DeleteLog(DeleteLogRequest) returns (google.protobuf.Empty) {
+ option (google.api.http) = { delete: "/v2beta1/{log_name=projects/*/logs/*}" };
+ }
+
+ // Writes log entries to Cloud Logging.
+ // All log entries in Cloud Logging are written by this method.
+ //
+ rpc WriteLogEntries(WriteLogEntriesRequest) returns (WriteLogEntriesResponse) {
+ option (google.api.http) = { post: "/v2beta1/entries:write" body: "*" };
+ }
+
+ // Lists log entries. Use this method to retrieve log entries from Cloud
+ // Logging. For ways to export log entries, see
+ // [Exporting Logs](/logging/docs/export).
+ //
+ rpc ListLogEntries(ListLogEntriesRequest) returns (ListLogEntriesResponse) {
+ option (google.api.http) = { post: "/v2beta1/entries:list" body: "*" };
+ }
+
+ // Lists monitored resource descriptors that are used by Cloud Logging.
+ rpc ListMonitoredResourceDescriptors(ListMonitoredResourceDescriptorsRequest) returns (ListMonitoredResourceDescriptorsResponse) {
+ option (google.api.http) = { get: "/v2beta1/monitoredResourceDescriptors" };
+ }
+}
+
+// The parameters to DeleteLog.
+message DeleteLogRequest {
+ // Required. The resource name of the log to delete. Example:
+ // `"projects/my-project/logs/syslog"`.
+ string log_name = 1;
+}
+
+// The parameters to WriteLogEntries.
+message WriteLogEntriesRequest {
+ // Optional. A default log resource name for those log entries in `entries`
+ // that do not specify their own `logName`. Example:
+ // `"projects/my-project/logs/syslog"`. See
+ // [LogEntry][google.logging.v2.LogEntry].
+ string log_name = 1;
+
+ // Optional. A default monitored resource for those log entries in `entries`
+ // that do not specify their own `resource`.
+ google.api.MonitoredResource resource = 2;
+
+ // Optional. User-defined `key:value` items that are added to
+ // the `labels` field of each log entry in `entries`, except when a log
+ // entry specifies its own `key:value` item with the same key.
+ // Example: `{ "size": "large", "color":"red" }`
+ map labels = 3;
+
+ // Required. The log entries to write. The log entries must have values for
+ // all required fields.
+ repeated LogEntry entries = 4;
+}
+
+// Result returned from WriteLogEntries.
+message WriteLogEntriesResponse {
+
+}
+
+// The parameters to `ListLogEntries`.
+message ListLogEntriesRequest {
+ // Required. One or more project IDs or project numbers from which to retrieve
+ // log entries. Examples of a project ID: `"my-project-1A"`, `"1234567890"`.
+ repeated string project_ids = 1;
+
+ // Optional. An [advanced logs filter](/logging/docs/view/advanced_filters).
+ // The filter is compared against all log entries in the projects specified by
+ // `projectIds`. Only entries that match the filter are retrieved. An empty
+ // filter matches all log entries.
+ string filter = 2;
+
+ // Optional. How the results should be sorted. Presently, the only permitted
+ // values are `"timestamp"` (default) and `"timestamp desc"`. The first
+ // option returns entries in order of increasing values of
+ // `LogEntry.timestamp` (oldest first), and the second option returns entries
+ // in order of decreasing timestamps (newest first). Entries with equal
+ // timestamps are returned in order of `LogEntry.insertId`.
+ string order_by = 3;
+
+ // Optional. The maximum number of results to return from this request. Fewer
+ // results might be returned. You must check for the `nextPageToken` result to
+ // determine if additional results are available, which you can retrieve by
+ // passing the `nextPageToken` value in the `pageToken` parameter to the next
+ // request.
+ int32 page_size = 4;
+
+ // Optional. If the `pageToken` request parameter is supplied, then the next
+ // page of results in the set are retrieved. The `pageToken` parameter must
+ // be set with the value of the `nextPageToken` result parameter from the
+ // previous request. The values of `projectIds`, `filter`, and `orderBy` must
+ // be the same as in the previous request.
+ string page_token = 5;
+}
+
+// Result returned from `ListLogEntries`.
+message ListLogEntriesResponse {
+ // A list of log entries.
+ repeated LogEntry entries = 1;
+
+ // If there are more results than were returned, then `nextPageToken` is
+ // given a value in the response. To get the next batch of results, call
+ // this method again using the value of `nextPageToken` as `pageToken`.
+ string next_page_token = 2;
+}
+
+// The parameters to ListMonitoredResourceDescriptors
+message ListMonitoredResourceDescriptorsRequest {
+ // Optional. The maximum number of results to return from this request. Fewer
+ // results might be returned. You must check for the `nextPageToken` result to
+ // determine if additional results are available, which you can retrieve by
+ // passing the `nextPageToken` value in the `pageToken` parameter to the next
+ // request.
+ int32 page_size = 1;
+
+ // Optional. If the `pageToken` request parameter is supplied, then the next
+ // page of results in the set are retrieved. The `pageToken` parameter must
+ // be set with the value of the `nextPageToken` result parameter from the
+ // previous request.
+ string page_token = 2;
+}
+
+// Result returned from ListMonitoredResourceDescriptors.
+message ListMonitoredResourceDescriptorsResponse {
+ // A list of resource descriptors.
+ repeated google.api.MonitoredResourceDescriptor resource_descriptors = 1;
+
+ // If there are more results than were returned, then `nextPageToken` is
+ // returned in the response. To get the next batch of results, call this
+ // method again using the value of `nextPageToken` as `pageToken`.
+ string next_page_token = 2;
+}
diff --git a/speech/grpc/src/main/proto/google/logging/v2/logging_config.proto b/speech/grpc/src/main/proto/google/logging/v2/logging_config.proto
new file mode 100644
index 00000000000..5fdc407af84
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/logging/v2/logging_config.proto
@@ -0,0 +1,171 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.logging.v2;
+
+import "google/api/annotations.proto";
+import "google/protobuf/empty.proto";
+import "google/protobuf/timestamp.proto";
+
+option java_multiple_files = true;
+option java_outer_classname = "LoggingConfig";
+option java_package = "com.google.logging.v2";
+
+
+service ConfigServiceV2 {
+ // Lists sinks.
+ rpc ListSinks(ListSinksRequest) returns (ListSinksResponse) {
+ option (google.api.http) = { get: "/v2beta1/{project_name=projects/*}/sinks" };
+ }
+
+ // Gets a sink.
+ rpc GetSink(GetSinkRequest) returns (LogSink) {
+ option (google.api.http) = { get: "/v2beta1/{sink_name=projects/*/sinks/*}" };
+ }
+
+ // Creates a sink.
+ rpc CreateSink(CreateSinkRequest) returns (LogSink) {
+ option (google.api.http) = { post: "/v2beta1/{project_name=projects/*}/sinks" body: "sink" };
+ }
+
+ // Creates or updates a sink.
+ rpc UpdateSink(UpdateSinkRequest) returns (LogSink) {
+ option (google.api.http) = { put: "/v2beta1/{sink_name=projects/*/sinks/*}" body: "sink" };
+ }
+
+ // Deletes a sink.
+ rpc DeleteSink(DeleteSinkRequest) returns (google.protobuf.Empty) {
+ option (google.api.http) = { delete: "/v2beta1/{sink_name=projects/*/sinks/*}" };
+ }
+}
+
+// Describes a sink used to export log entries outside Cloud Logging.
+message LogSink {
+ // Available log entry formats. Log entries can be written to Cloud
+ // Logging in either format and can be exported in either format.
+ // Version 2 is the preferred format.
+ enum VersionFormat {
+ // An unspecified version format will default to V2.
+ VERSION_FORMAT_UNSPECIFIED = 0;
+
+ // `LogEntry` version 2 format.
+ V2 = 1;
+
+ // `LogEntry` version 1 format.
+ V1 = 2;
+ }
+
+ // Required. The client-assigned sink identifier. Example:
+ // `"my-severe-errors-to-pubsub"`.
+ // Sink identifiers are limited to 1000 characters
+ // and can include only the following characters: `A-Z`, `a-z`,
+ // `0-9`, and the special characters `_-.`.
+ string name = 1;
+
+ // The export destination. See
+ // [Exporting Logs With Sinks](/logging/docs/api/tasks/exporting-logs).
+ // Examples: `"storage.googleapis.com/a-bucket"`,
+ // `"bigquery.googleapis.com/projects/a-project-id/datasets/a-dataset"`.
+ string destination = 3;
+
+ // An [advanced logs filter](/logging/docs/view/advanced_filters)
+ // that defines the log entries to be exported. The filter must be
+ // consistent with the log entry format designed by the
+ // `outputVersionFormat` parameter, regardless of the format of the
+ // log entry that was originally written to Cloud Logging.
+ // Example: `"logName:syslog AND severity>=ERROR"`.
+ string filter = 5;
+
+ // The log entry version used when exporting log entries from this
+ // sink. This version does not have to correspond to the version of
+ // the log entry when it was written to Cloud Logging.
+ VersionFormat output_version_format = 6;
+}
+
+// The parameters to `ListSinks`.
+message ListSinksRequest {
+ // Required. The resource name of the project containing the sinks.
+ // Example: `"projects/my-logging-project"`, `"projects/01234567890"`.
+ string project_name = 1;
+
+ // Optional. If the `pageToken` request parameter is supplied, then the next
+ // page of results in the set are retrieved. The `pageToken` parameter must
+ // be set with the value of the `nextPageToken` result parameter from the
+ // previous request. The value of `projectName` must be the same as in the
+ // previous request.
+ string page_token = 2;
+
+ // Optional. The maximum number of results to return from this request. Fewer
+ // results might be returned. You must check for the `nextPageToken` result to
+ // determine if additional results are available, which you can retrieve by
+ // passing the `nextPageToken` value in the `pageToken` parameter to the next
+ // request.
+ int32 page_size = 3;
+}
+
+// Result returned from `ListSinks`.
+message ListSinksResponse {
+ // A list of sinks.
+ repeated LogSink sinks = 1;
+
+ // If there are more results than were returned, then `nextPageToken` is
+ // given a value in the response. To get the next batch of results, call this
+ // method again using the value of `nextPageToken` as `pageToken`.
+ string next_page_token = 2;
+}
+
+// The parameters to `GetSink`.
+message GetSinkRequest {
+ // The resource name of the sink to return.
+ // Example: `"projects/my-project-id/sinks/my-sink-id"`.
+ string sink_name = 1;
+}
+
+// The parameters to `CreateSink`.
+message CreateSinkRequest {
+ // The resource name of the project in which to create the sink.
+ // Example: `"projects/my-project-id"`.
+ //
+ // The new sink must be provided in the request.
+ string project_name = 1;
+
+ // The new sink, which must not have an identifier that already
+ // exists.
+ LogSink sink = 2;
+}
+
+// The parameters to `UpdateSink`.
+message UpdateSinkRequest {
+ // The resource name of the sink to update.
+ // Example: `"projects/my-project-id/sinks/my-sink-id"`.
+ //
+ // The updated sink must be provided in the request and have the
+ // same name that is specified in `sinkName`. If the sink does not
+ // exist, it is created.
+ string sink_name = 1;
+
+ // The updated sink, whose name must be the same as the sink
+ // identifier in `sinkName`. If `sinkName` does not exist, then
+ // this method creates a new sink.
+ LogSink sink = 2;
+}
+
+// The parameters to `DeleteSink`.
+message DeleteSinkRequest {
+ // The resource name of the sink to delete.
+ // Example: `"projects/my-project-id/sinks/my-sink-id"`.
+ string sink_name = 1;
+}
diff --git a/speech/grpc/src/main/proto/google/logging/v2/logging_metrics.proto b/speech/grpc/src/main/proto/google/logging/v2/logging_metrics.proto
new file mode 100644
index 00000000000..638cbc377ab
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/logging/v2/logging_metrics.proto
@@ -0,0 +1,146 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.logging.v2;
+
+import "google/api/annotations.proto";
+import "google/protobuf/empty.proto";
+
+option java_multiple_files = true;
+option java_package = "com.google.logging.v2";
+
+
+service MetricsServiceV2 {
+ // Lists logs-based metrics.
+ rpc ListLogMetrics(ListLogMetricsRequest) returns (ListLogMetricsResponse) {
+ option (google.api.http) = { get: "/v2beta1/{project_name=projects/*}/metrics" };
+ }
+
+ // Gets a logs-based metric.
+ rpc GetLogMetric(GetLogMetricRequest) returns (LogMetric) {
+ option (google.api.http) = { get: "/v2beta1/{metric_name=projects/*/metrics/*}" };
+ }
+
+ // Creates a logs-based metric.
+ rpc CreateLogMetric(CreateLogMetricRequest) returns (LogMetric) {
+ option (google.api.http) = { post: "/v2beta1/{project_name=projects/*}/metrics" body: "metric" };
+ }
+
+ // Creates or updates a logs-based metric.
+ rpc UpdateLogMetric(UpdateLogMetricRequest) returns (LogMetric) {
+ option (google.api.http) = { put: "/v2beta1/{metric_name=projects/*/metrics/*}" body: "metric" };
+ }
+
+ // Deletes a logs-based metric.
+ rpc DeleteLogMetric(DeleteLogMetricRequest) returns (google.protobuf.Empty) {
+ option (google.api.http) = { delete: "/v2beta1/{metric_name=projects/*/metrics/*}" };
+ }
+}
+
+// Describes a logs-based metric. The value of the metric is the
+// number of log entries that match a logs filter.
+message LogMetric {
+ // Required. The client-assigned metric identifier. Example:
+ // `"severe_errors"`. Metric identifiers are limited to 1000
+ // characters and can include only the following characters: `A-Z`,
+ // `a-z`, `0-9`, and the special characters `_-.,+!*',()%/\`. The
+ // forward-slash character (`/`) denotes a hierarchy of name pieces,
+ // and it cannot be the first character of the name.
+ string name = 1;
+
+ // A description of this metric, which is used in documentation.
+ string description = 2;
+
+ // An [advanced logs filter](/logging/docs/view/advanced_filters).
+ // Example: `"logName:syslog AND severity>=ERROR"`.
+ string filter = 3;
+}
+
+// The parameters to ListLogMetrics.
+message ListLogMetricsRequest {
+ // Required. The resource name of the project containing the metrics.
+ // Example: `"projects/my-project-id"`.
+ string project_name = 1;
+
+ // Optional. If the `pageToken` request parameter is supplied, then the next
+ // page of results in the set are retrieved. The `pageToken` parameter must
+ // be set with the value of the `nextPageToken` result parameter from the
+ // previous request. The value of `projectName` must
+ // be the same as in the previous request.
+ string page_token = 2;
+
+ // Optional. The maximum number of results to return from this request. Fewer
+ // results might be returned. You must check for the `nextPageToken` result to
+ // determine if additional results are available, which you can retrieve by
+ // passing the `nextPageToken` value in the `pageToken` parameter to the next
+ // request.
+ int32 page_size = 3;
+}
+
+// Result returned from ListLogMetrics.
+message ListLogMetricsResponse {
+ // A list of logs-based metrics.
+ repeated LogMetric metrics = 1;
+
+ // If there are more results than were returned, then `nextPageToken` is given
+ // a value in the response. To get the next batch of results, call this
+ // method again using the value of `nextPageToken` as `pageToken`.
+ string next_page_token = 2;
+}
+
+// The parameters to GetLogMetric.
+message GetLogMetricRequest {
+ // The resource name of the desired metric.
+ // Example: `"projects/my-project-id/metrics/my-metric-id"`.
+ string metric_name = 1;
+}
+
+// The parameters to CreateLogMetric.
+message CreateLogMetricRequest {
+ // The resource name of the project in which to create the metric.
+ // Example: `"projects/my-project-id"`.
+ //
+ // The new metric must be provided in the request.
+ string project_name = 1;
+
+ // The new logs-based metric, which must not have an identifier that
+ // already exists.
+ LogMetric metric = 2;
+}
+
+// The parameters to UpdateLogMetric.
+//
+message UpdateLogMetricRequest {
+ // The resource name of the metric to update.
+ // Example: `"projects/my-project-id/metrics/my-metric-id"`.
+ //
+ // The updated metric must be provided in the request and have the
+ // same identifier that is specified in `metricName`.
+ // If the metric does not exist, it is created.
+ string metric_name = 1;
+
+ // The updated metric, whose name must be the same as the
+ // metric identifier in `metricName`. If `metricName` does not
+ // exist, then a new metric is created.
+ LogMetric metric = 2;
+}
+
+// The parameters to DeleteLogMetric.
+message DeleteLogMetricRequest {
+ // The resource name of the metric to delete.
+ // Example: `"projects/my-project-id/metrics/my-metric-id"`.
+ string metric_name = 1;
+}
diff --git a/speech/grpc/src/main/proto/google/rpc/README.md b/speech/grpc/src/main/proto/google/rpc/README.md
new file mode 100644
index 00000000000..aa8877db842
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/rpc/README.md
@@ -0,0 +1,5 @@
+# Google RPC
+
+This package contains type definitions for general RPC systems. While
+[gRPC](https://github.com/grpc) is using these defintions, but they
+are not designed specifically to support gRPC.
diff --git a/speech/grpc/src/main/proto/google/rpc/code.proto b/speech/grpc/src/main/proto/google/rpc/code.proto
new file mode 100644
index 00000000000..f9ceddcbc10
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/rpc/code.proto
@@ -0,0 +1,190 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.rpc;
+
+option java_multiple_files = true;
+option java_outer_classname = "CodeProto";
+option java_package = "com.google.rpc";
+
+
+// The canonical error codes for Google APIs.
+// Warnings:
+//
+// - Do not change any numeric assignments.
+// - Changes to this list should be made only if there is a compelling
+// need that can't be satisfied in another way.
+//
+// Sometimes multiple error codes may apply. Services should return
+// the most specific error code that applies. For example, prefer
+// `OUT_OF_RANGE` over `FAILED_PRECONDITION` if both codes apply.
+// Similarly prefer `NOT_FOUND` or `ALREADY_EXISTS` over `FAILED_PRECONDITION`.
+enum Code {
+ // Not an error; returned on success
+ //
+ // HTTP Mapping: 200 OK
+ OK = 0;
+
+ // The operation was cancelled, typically by the caller.
+ //
+ // HTTP Mapping: 499 Client Closed Request
+ CANCELLED = 1;
+
+ // Unknown error. For example, this error may be returned when
+ // a `Status` value received from another address space belongs to
+ // an error space that is not known in this address space. Also
+ // errors raised by APIs that do not return enough error information
+ // may be converted to this error.
+ //
+ // HTTP Mapping: 500 Internal Server Error
+ UNKNOWN = 2;
+
+ // The client specified an invalid argument. Note that this differs
+ // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments
+ // that are problematic regardless of the state of the system
+ // (e.g., a malformed file name).
+ //
+ // HTTP Mapping: 400 Bad Request
+ INVALID_ARGUMENT = 3;
+
+ // The deadline expired before the operation could complete. For operations
+ // that change the state of the system, this error may be returned
+ // even if the operation has completed successfully. For example, a
+ // successful response from a server could have been delayed long
+ // enough for the deadline to expire.
+ //
+ // HTTP Mapping: 504 Gateway Timeout
+ DEADLINE_EXCEEDED = 4;
+
+ // Some requested entity (e.g., file or directory) was not found.
+ // For privacy reasons, this code *might* be returned when the client
+ // does not have the access rights to the entity.
+ //
+ // HTTP Mapping: 404 Not Found
+ NOT_FOUND = 5;
+
+ // The entity that a client attempted to create (e.g., file or directory)
+ // already exists.
+ //
+ // HTTP Mapping: 409 Conflict
+ ALREADY_EXISTS = 6;
+
+ // The caller does not have permission to execute the specified
+ // operation. `PERMISSION_DENIED` must not be used for rejections
+ // caused by exhausting some resource (use `RESOURCE_EXHAUSTED`
+ // instead for those errors). `PERMISSION_DENIED` must not be
+ // used if the caller can not be identified (use `UNAUTHENTICATED`
+ // instead for those errors).
+ //
+ // HTTP Mapping: 403 Forbidden
+ PERMISSION_DENIED = 7;
+
+ // The request does not have valid authentication credentials for the
+ // operation.
+ //
+ // HTTP Mapping: 401 Unauthorized
+ UNAUTHENTICATED = 16;
+
+ // Some resource has been exhausted, perhaps a per-user quota, or
+ // perhaps the entire file system is out of space.
+ //
+ // HTTP Mapping: 429 Too Many Requests
+ RESOURCE_EXHAUSTED = 8;
+
+ // The operation was rejected because the system is not in a state
+ // required for the operation's execution. For example, the directory
+ // to be deleted is non-empty, an rmdir operation is applied to
+ // a non-directory, etc.
+ //
+ // Service implementors can use the following guidelines to decide
+ // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:
+ // (a) Use `UNAVAILABLE` if the client can retry just the failing call.
+ // (b) Use `ABORTED` if the client should retry at a higher level
+ // (e.g., restarting a read-modify-write sequence).
+ // (c) Use `FAILED_PRECONDITION` if the client should not retry until
+ // the system state has been explicitly fixed. E.g., if an "rmdir"
+ // fails because the directory is non-empty, `FAILED_PRECONDITION`
+ // should be returned since the client should not retry unless
+ // the files are deleted from the directory.
+ // (d) Use `FAILED_PRECONDITION` if the client performs conditional
+ // REST Get/Update/Delete on a resource and the resource on the
+ // server does not match the condition. E.g., conflicting
+ // read-modify-write on the same resource.
+ //
+ // HTTP Mapping: 400 Bad Request
+ //
+ // NOTE: HTTP spec says `412 Precondition Failed` should be used only if
+ // the request contains Etag-related headers. So if the server does see
+ // Etag-related headers in the request, it may choose to return 412
+ // instead of 400 for this error code.
+ FAILED_PRECONDITION = 9;
+
+ // The operation was aborted, typically due to a concurrency issue such as
+ // a sequencer check failure or transaction abort.
+ //
+ // See the guidelines above for deciding between `FAILED_PRECONDITION`,
+ // `ABORTED`, and `UNAVAILABLE`.
+ //
+ // HTTP Mapping: 409 Conflict
+ ABORTED = 10;
+
+ // The operation was attempted past the valid range. E.g., seeking or
+ // reading past end-of-file.
+ //
+ // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may
+ // be fixed if the system state changes. For example, a 32-bit file
+ // system will generate `INVALID_ARGUMENT` if asked to read at an
+ // offset that is not in the range [0,2^32-1], but it will generate
+ // `OUT_OF_RANGE` if asked to read from an offset past the current
+ // file size.
+ //
+ // There is a fair bit of overlap between `FAILED_PRECONDITION` and
+ // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific
+ // error) when it applies so that callers who are iterating through
+ // a space can easily look for an `OUT_OF_RANGE` error to detect when
+ // they are done.
+ //
+ // HTTP Mapping: 400 Bad Request
+ OUT_OF_RANGE = 11;
+
+ // The operation is not implemented or is not supported/enabled in this
+ // service.
+ //
+ // HTTP Mapping: 501 Not Implemented
+ UNIMPLEMENTED = 12;
+
+ // Internal errors. This means that some invariants expected by the
+ // underlying system have been broken. This error code is reserved
+ // for serious errors.
+ //
+ // HTTP Mapping: 500 Internal Server Error
+ INTERNAL = 13;
+
+ // The service is currently unavailable. This is most likely a
+ // transient condition, which can be corrected by retrying with
+ // a backoff.
+ //
+ // See the guidelines above for deciding between `FAILED_PRECONDITION`,
+ // `ABORTED`, and `UNAVAILABLE`.
+ //
+ // HTTP Mapping: 503 Service Unavailable
+ UNAVAILABLE = 14;
+
+ // Unrecoverable data loss or corruption.
+ //
+ // HTTP Mapping: 500 Internal Server Error
+ DATA_LOSS = 15;
+}
diff --git a/speech/grpc/src/main/proto/google/rpc/error_details.proto b/speech/grpc/src/main/proto/google/rpc/error_details.proto
new file mode 100644
index 00000000000..82472b8b2e6
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/rpc/error_details.proto
@@ -0,0 +1,157 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.rpc;
+
+import "google/protobuf/duration.proto";
+
+option java_multiple_files = true;
+option java_outer_classname = "ErrorDetailsProto";
+option java_package = "com.google.rpc";
+
+
+// Describes when the clients can retry a failed request. Clients could ignore
+// the recommendation here or retry when this information is missing from error
+// responses.
+//
+// It's always recommended that clients should use exponential backoff when
+// retrying.
+//
+// Clients should wait until `retry_delay` amount of time has passed since
+// receiving the error response before retrying. If retrying requests also
+// fail, clients should use an exponential backoff scheme to gradually increase
+// the delay between retries based on `retry_delay`, until either a maximum
+// number of retires have been reached or a maximum retry delay cap has been
+// reached.
+message RetryInfo {
+ // Clients should wait at least this long between retrying the same request.
+ google.protobuf.Duration retry_delay = 1;
+}
+
+// Describes additional debugging info.
+message DebugInfo {
+ // The stack trace entries indicating where the error occurred.
+ repeated string stack_entries = 1;
+
+ // Additional debugging information provided by the server.
+ string detail = 2;
+}
+
+// Describes how a quota check failed.
+//
+// For example if a daily limit was exceeded for the calling project,
+// a service could respond with a QuotaFailure detail containing the project
+// id and the description of the quota limit that was exceeded. If the
+// calling project hasn't enabled the service in the developer console, then
+// a service could respond with the project id and set `service_disabled`
+// to true.
+//
+// Also see RetryDetail and Help types for other details about handling a
+// quota failure.
+message QuotaFailure {
+ // A message type used to describe a single quota violation. For example, a
+ // daily quota or a custom quota that was exceeded.
+ message Violation {
+ // The subject on which the quota check failed.
+ // For example, "clientip:" or "project:".
+ string subject = 1;
+
+ // A description of how the quota check failed. Clients can use this
+ // description to find more about the quota configuration in the service's
+ // public documentation, or find the relevant quota limit to adjust through
+ // developer console.
+ //
+ // For example: "Service disabled" or "Daily Limit for read operations
+ // exceeded".
+ string description = 2;
+ }
+
+ // Describes all quota violations.
+ repeated Violation violations = 1;
+}
+
+// Describes violations in a client request. This error type focuses on the
+// syntactic aspects of the request.
+message BadRequest {
+ // A message type used to describe a single bad request field.
+ message FieldViolation {
+ // A path leading to a field in the request body. The value will be a
+ // sequence of dot-separated identifiers that identify a protocol buffer
+ // field. E.g., "violations.field" would identify this field.
+ string field = 1;
+
+ // A description of why the request element is bad.
+ string description = 2;
+ }
+
+ // Describes all violations in a client request.
+ repeated FieldViolation field_violations = 1;
+}
+
+// Contains metadata about the request that clients can attach when filing a bug
+// or providing other forms of feedback.
+message RequestInfo {
+ // An opaque string that should only be interpreted by the service generating
+ // it. For example, it can be used to identify requests in the service's logs.
+ string request_id = 1;
+
+ // Any data that was used to serve this request. For example, an encrypted
+ // stack trace that can be sent back to the service provider for debugging.
+ string serving_data = 2;
+}
+
+// Describes the resource that is being accessed.
+message ResourceInfo {
+ // A name for the type of resource being accessed, e.g. "sql table",
+ // "cloud storage bucket", "file", "Google calendar"; or the type URL
+ // of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
+ string resource_type = 1;
+
+ // The name of the resource being accessed. For example, a shared calendar
+ // name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
+ // error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
+ string resource_name = 2;
+
+ // The owner of the resource (optional).
+ // For example, "user:" or "project:".
+ string owner = 3;
+
+ // Describes what error is encountered when accessing this resource.
+ // For example, updating a cloud project may require the `writer` permission
+ // on the developer console project.
+ string description = 4;
+}
+
+// Provides links to documentation or for performing an out of band action.
+//
+// For example, if a quota check failed with an error indicating the calling
+// project hasn't enabled the accessed service, this can contain a URL pointing
+// directly to the right place in the developer console to flip the bit.
+message Help {
+ // Describes a URL link.
+ message Link {
+ // Describes what the link offers.
+ string description = 1;
+
+ // The URL of the link.
+ string url = 2;
+ }
+
+ // URL(s) pointing to additional information on handling the current error.
+ repeated Link links = 1;
+}
diff --git a/speech/grpc/src/main/proto/google/rpc/status.proto b/speech/grpc/src/main/proto/google/rpc/status.proto
new file mode 100644
index 00000000000..8fca6ab22d9
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/rpc/status.proto
@@ -0,0 +1,90 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.rpc;
+
+import "google/protobuf/any.proto";
+
+option java_multiple_files = true;
+option java_outer_classname = "StatusProto";
+option java_package = "com.google.rpc";
+
+
+// The `Status` type defines a logical error model that is suitable for different
+// programming environments, including REST APIs and RPC APIs. It is used by
+// [gRPC](https://github.com/grpc). The error model is designed to be:
+//
+// - Simple to use and understand for most users
+// - Flexible enough to meet unexpected needs
+//
+// # Overview
+//
+// The `Status` message contains three pieces of data: error code, error message,
+// and error details. The error code should be an enum value of
+// [google.rpc.Code][google.rpc.Code], but it may accept additional error codes if needed. The
+// error message should be a developer-facing English message that helps
+// developers *understand* and *resolve* the error. If a localized user-facing
+// error message is needed, put the localized message in the error details or
+// localize it in the client. The optional error details may contain arbitrary
+// information about the error. There is a predefined set of error detail types
+// in the package `google.rpc` which can be used for common error conditions.
+//
+// # Language mapping
+//
+// The `Status` message is the logical representation of the error model, but it
+// is not necessarily the actual wire format. When the `Status` message is
+// exposed in different client libraries and different wire protocols, it can be
+// mapped differently. For example, it will likely be mapped to some exceptions
+// in Java, but more likely mapped to some error codes in C.
+//
+// # Other uses
+//
+// The error model and the `Status` message can be used in a variety of
+// environments, either with or without APIs, to provide a
+// consistent developer experience across different environments.
+//
+// Example uses of this error model include:
+//
+// - Partial errors. If a service needs to return partial errors to the client,
+// it may embed the `Status` in the normal response to indicate the partial
+// errors.
+//
+// - Workflow errors. A typical workflow has multiple steps. Each step may
+// have a `Status` message for error reporting purpose.
+//
+// - Batch operations. If a client uses batch request and batch response, the
+// `Status` message should be used directly inside batch response, one for
+// each error sub-response.
+//
+// - Asynchronous operations. If an API call embeds asynchronous operation
+// results in its response, the status of those operations should be
+// represented directly using the `Status` message.
+//
+// - Logging. If some API errors are stored in logs, the message `Status` could
+// be used directly after any stripping needed for security/privacy reasons.
+message Status {
+ // The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
+ int32 code = 1;
+
+ // A developer-facing error message, which should be in English. Any
+ // user-facing error message should be localized and sent in the
+ // [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
+ string message = 2;
+
+ // A list of messages that carry the error details. There will be a
+ // common set of message types for APIs to use.
+ repeated google.protobuf.Any details = 3;
+}
diff --git a/speech/grpc/src/main/proto/google/speech/v1/cloud-speech.proto b/speech/grpc/src/main/proto/google/speech/v1/cloud-speech.proto
new file mode 100644
index 00000000000..6ee3b031552
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/speech/v1/cloud-speech.proto
@@ -0,0 +1,238 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.cloud.speech.v1;
+
+import "google/api/annotations.proto";
+import "google/rpc/status.proto";
+
+option java_multiple_files = true;
+option java_outer_classname = "SpeechProto";
+option java_package = "com.google.cloud.speech.v1";
+
+// Service that implements Google Cloud Speech API.
+service Speech {
+ // Perform bidirectional streaming speech recognition on audio using gRPC.
+ rpc Recognize(stream RecognizeRequest) returns (stream RecognizeResponse);
+
+ // Perform non-streaming speech recognition on audio using HTTPS.
+ rpc NonStreamingRecognize(RecognizeRequest) returns (NonStreamingRecognizeResponse) {
+ option (.google.api.http) = { post: "/v1/speech:recognize" body: "*" };
+ }
+}
+
+// `RecognizeRequest` is the only message type sent by the client.
+//
+// `NonStreamingRecognize` sends only one `RecognizeRequest` message and it
+// must contain both an `initial_request` and an 'audio_request`.
+//
+// Streaming `Recognize` sends one or more `RecognizeRequest` messages. The
+// first message must contain an `initial_request` and may contain an
+// 'audio_request`. Any subsequent messages must not contain an
+// `initial_request` and must contain an 'audio_request`.
+message RecognizeRequest {
+ // The `initial_request` message provides information to the recognizer
+ // that specifies how to process the request.
+ //
+ // The first `RecognizeRequest` message must contain an `initial_request`.
+ // Any subsequent `RecognizeRequest` messages must not contain an
+ // `initial_request`.
+ InitialRecognizeRequest initial_request = 1;
+
+ // The audio data to be recognized. For `NonStreamingRecognize`, all the
+ // audio data must be contained in the first (and only) `RecognizeRequest`
+ // message. For streaming `Recognize`, sequential chunks of audio data are
+ // sent in sequential `RecognizeRequest` messages.
+ AudioRequest audio_request = 2;
+}
+
+// The `InitialRecognizeRequest` message provides information to the recognizer
+// that specifies how to process the request.
+message InitialRecognizeRequest {
+ // Audio encoding of the data sent in the audio message.
+ enum AudioEncoding {
+ // Not specified. Will return result `INVALID_ARGUMENT`.
+ ENCODING_UNSPECIFIED = 0;
+
+ // Uncompressed 16-bit signed little-endian samples.
+ // This is the simplest encoding format, useful for getting started.
+ // However, because it is uncompressed, it is not recommended for deployed
+ // clients.
+ LINEAR16 = 1;
+
+ // This is the recommended encoding format because it uses lossless
+ // compression; therefore recognition accuracy is not compromised by a lossy
+ // codec.
+ //
+ // The stream FLAC format is specified at:
+ // http://flac.sourceforge.net/documentation.html.
+ // Only 16-bit samples are supported.
+ // Not all fields in STREAMINFO are supported.
+ FLAC = 2;
+
+ // 8-bit samples that compand 14-bit audio samples using PCMU/mu-law.
+ MULAW = 3;
+
+ // Adaptive Multi-Rate Narrowband codec. `sample_rate` must be 8000 Hz.
+ AMR = 4;
+
+ // Adaptive Multi-Rate Wideband codec. `sample_rate` must be 16000 Hz.
+ AMR_WB = 5;
+ }
+
+ // [Required] Encoding of audio data sent in all `AudioRequest` messages.
+ AudioEncoding encoding = 1;
+
+ // [Required] Sample rate in Hertz of the audio data sent in all
+ // AudioRequest messages.
+ // 16000 is optimal. Valid values are: 8000-48000.
+ int32 sample_rate = 2;
+
+ // [Optional] The language of the supplied audio as a BCP-47 language tag.
+ // Example: "en-GB" https://www.rfc-editor.org/rfc/bcp/bcp47.txt
+ // If omitted, defaults to "en-US".
+ string language_code = 3;
+
+ // [Optional] Maximum number of recognition hypotheses to be returned.
+ // Specifically, the maximum number of `SpeechRecognitionAlternative` messages
+ // within each `SpeechRecognitionResult`.
+ // The server may return fewer than `max_alternatives`.
+ // Valid values are `0`-`30`. A value of `0` or `1` will return a maximum of
+ // `1`. If omitted, defaults to `1`.
+ int32 max_alternatives = 4;
+
+ // [Optional] If set to `true`, the server will attempt to filter out
+ // profanities, replacing all but the initial character in each filtered word
+ // with asterisks, e.g. "f***". If set to `false` or omitted, profanities
+ // won't be filtered out.
+ // Note that profanity filtering is not implemented for all languages.
+ // If the language is not supported, this setting has no effect.
+ bool profanity_filter = 5;
+
+ // [Optional] If `false` or omitted, the recognizer will detect a single
+ // spoken utterance, and it will cease recognition when the user stops
+ // speaking. If `enable_endpointer_events` is `true`, it will return
+ // `END_OF_UTTERANCE` when it detects that the user has stopped speaking.
+ // In all cases, it will return no more than one `SpeechRecognitionResult`,
+ // and set the `is_final` flag to `true`.
+ //
+ // If `true`, the recognizer will continue recognition (even if the user
+ // pauses speaking) until the client sends an `end_of_data` message or when
+ // the maximum time limit has been reached. Multiple
+ // `SpeechRecognitionResult`s with the `is_final` flag set to `true` may be
+ // returned to indicate that the recognizer will not return any further
+ // hypotheses for this portion of the transcript.
+ bool continuous = 6;
+
+ // [Optional] If this parameter is `true`, interim results may be returned as
+ // they become available.
+ // If `false` or omitted, only `is_final=true` result(s) are returned.
+ bool interim_results = 7;
+
+ // [Optional] If this parameter is `true`, `EndpointerEvents` may be returned
+ // as they become available.
+ // If `false` or omitted, no `EndpointerEvents` are returned.
+ bool enable_endpointer_events = 8;
+}
+
+// Contains audio data in the format specified in the `InitialRecognizeRequest`.
+message AudioRequest {
+ // [Required] The audio data bytes encoded as specified in
+ // `InitialRecognizeRequest`.
+ bytes content = 1;
+}
+
+// `NonStreamingRecognizeResponse` is the only message returned to the client by
+// `NonStreamingRecognize`. It contains the result as zero or more sequential
+// `RecognizeResponse` messages.
+//
+// Note that streaming `Recognize` will also return multiple `RecognizeResponse`
+// messages, but each message is individually streamed.
+message NonStreamingRecognizeResponse {
+ // [Output-only] Sequential list of messages returned by the recognizer.
+ repeated RecognizeResponse responses = 1;
+}
+
+// `RecognizeResponse` is the only message type returned to the client.
+message RecognizeResponse {
+ // Indicates the type of endpointer event.
+ enum EndpointerEvent {
+ // No endpointer event specified.
+ ENDPOINTER_EVENT_UNSPECIFIED = 0;
+
+ // Speech has been detected in the audio stream.
+ START_OF_SPEECH = 1;
+
+ // Speech has ceased to be detected in the audio stream.
+ END_OF_SPEECH = 2;
+
+ // The end of the audio stream has been reached. and it is being processed.
+ END_OF_AUDIO = 3;
+
+ // This event is only sent when continuous is `false`. It indicates that the
+ // server has detected the end of the user's speech utterance and expects no
+ // additional speech. Therefore, the server will not process additional
+ // audio. The client should stop sending additional audio data.
+ END_OF_UTTERANCE = 4;
+ }
+
+ // [Output-only] If set, returns a [google.rpc.Status][] message that
+ // specifies the error for the operation.
+ .google.rpc.Status error = 1;
+
+ // [Output-only] May contain zero or one `is_final=true` result (the newly
+ // settled portion). May also contain zero or more `is_final=false` results.
+ repeated SpeechRecognitionResult results = 2;
+
+ // [Output-only] Indicates the lowest index in the `results` array that has
+ // changed. The repeated `SpeechRecognitionResult` results overwrite past
+ // results at this index and higher.
+ int32 result_index = 3;
+
+ // [Output-only] Indicates the type of endpointer event.
+ EndpointerEvent endpoint = 4;
+}
+
+message SpeechRecognitionResult {
+ repeated SpeechRecognitionAlternative alternatives = 1;
+
+ // [Output-only] Set `true` if this is the final time the speech service will
+ // return this particular `SpeechRecognitionResult`. If `false`, this
+ // represents an interim result that may change.
+ bool is_final = 2;
+
+ // [Output-only] An estimate of the probability that the recognizer will not
+ // change its guess about this interim result. Values range from 0.0
+ // (completely unstable) to 1.0 (completely stable). Note that this is not the
+ // same as `confidence`, which estimates the probability that a recognition
+ // result is correct.
+ // This field is only provided for interim results (`is_final=false`).
+ // The default of 0.0 is a sentinel value indicating stability was not set.
+ float stability = 3;
+}
+
+// Alternative hypotheses (a.k.a. n-best list).
+message SpeechRecognitionAlternative {
+ // [Output-only] Transcript text representing the words that the user spoke.
+ string transcript = 1;
+
+ // [Output-only] The confidence estimate between 0.0 and 1.0. A higher number
+ // means the system is more confident that the recognition is correct.
+ // This field is typically provided only for the top hypothesis. and only for
+ // `is_final=true` results.
+ // The default of 0.0 is a sentinel value indicating confidence was not set.
+ float confidence = 2;
+}
diff --git a/speech/grpc/src/main/proto/google/type/README.md b/speech/grpc/src/main/proto/google/type/README.md
new file mode 100644
index 00000000000..f8079ab1ea6
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/type/README.md
@@ -0,0 +1,10 @@
+# Google Common Types
+This package contains definitions of common types for Google APIs.
+All types defined in this package are suitable for different APIs to
+exchange data, and will never break binary compatibility. They should
+have design quality comparable to major programming languages like
+Java and C#.
+
+NOTE: Some common types are defined in the package `google.protobuf`
+as they are directly supported by Protocol Buffers compiler and
+runtime. Those types are called Well-Known Types.
diff --git a/speech/grpc/src/main/proto/google/type/color.proto b/speech/grpc/src/main/proto/google/type/color.proto
new file mode 100644
index 00000000000..3e200230d82
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/type/color.proto
@@ -0,0 +1,163 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.type;
+
+import "google/protobuf/wrappers.proto";
+
+option java_multiple_files = true;
+option java_outer_classname = "ColorProto";
+option java_package = "com.google.type";
+
+
+// Represents a color in the RGBA color space. This representation is designed
+// for simplicity of conversion to/from color representations in various
+// languages over compactness; for example, the fields of this representation
+// can be trivially provided to the constructor of "java.awt.Color" in Java; it
+// can also be trivially provided to UIColor's "+colorWithRed:green:blue:alpha"
+// method in iOS; and, with just a little work, it can be easily formatted into
+// a CSS "rgba()" string in JavaScript, as well. Here are some examples:
+//
+// Example (Java):
+//
+// import com.google.type.Color;
+//
+// // ...
+// public static java.awt.Color fromProto(Color protocolor) {
+// float alpha = protocolor.hasAlpha()
+// ? protocolor.getAlpha().getValue()
+// : 1.0;
+//
+// return new java.awt.Color(
+// protocolor.getRed(),
+// protocolor.getGreen(),
+// protocolor.getBlue(),
+// alpha);
+// }
+//
+// public static Color toProto(java.awt.Color color) {
+// float red = (float) color.getRed();
+// float green = (float) color.getGreen();
+// float blue = (float) color.getBlue();
+// float denominator = 255.0;
+// Color.Builder resultBuilder =
+// Color
+// .newBuilder()
+// .setRed(red / denominator)
+// .setGreen(green / denominator)
+// .setBlue(blue / denominator);
+// int alpha = color.getAlpha();
+// if (alpha != 255) {
+// result.setAlpha(
+// FloatValue
+// .newBuilder()
+// .setValue(((float) alpha) / denominator)
+// .build());
+// }
+// return resultBuilder.build();
+// }
+// // ...
+//
+// Example (iOS / Obj-C):
+//
+// // ...
+// static UIColor* fromProto(Color* protocolor) {
+// float red = [protocolor red];
+// float green = [protocolor green];
+// float blue = [protocolor blue];
+// FloatValue* alpha_wrapper = [protocolor alpha];
+// float alpha = 1.0;
+// if (alpha_wrapper != nil) {
+// alpha = [alpha_wrapper value];
+// }
+// return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
+// }
+//
+// static Color* toProto(UIColor* color) {
+// CGFloat red, green, blue, alpha;
+// if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) {
+// return nil;
+// }
+// Color* result = [Color alloc] init];
+// [result setRed:red];
+// [result setGreen:green];
+// [result setBlue:blue];
+// if (alpha <= 0.9999) {
+// [result setAlpha:floatWrapperWithValue(alpha)];
+// }
+// [result autorelease];
+// return result;
+// }
+// // ...
+//
+// Example (JavaScript):
+//
+// // ...
+//
+// var protoToCssColor = function(rgb_color) {
+// var redFrac = rgb_color.red || 0.0;
+// var greenFrac = rgb_color.green || 0.0;
+// var blueFrac = rgb_color.blue || 0.0;
+// var red = Math.floor(redFrac * 255);
+// var green = Math.floor(greenFrac * 255);
+// var blue = Math.floor(blueFrac * 255);
+//
+// if (!('alpha' in rgb_color)) {
+// return rgbToCssColor_(red, green, blue);
+// }
+//
+// var alphaFrac = rgb_color.alpha.value || 0.0;
+// var rgbParams = [red, green, blue].join(',');
+// return ['rgba(', rgbParams, ',', alphaFrac, ')'].join('');
+// };
+//
+// var rgbToCssColor_ = function(red, green, blue) {
+// var rgbNumber = new Number((red << 16) | (green << 8) | blue);
+// var hexString = rgbNumber.toString(16);
+// var missingZeros = 6 - hexString.length;
+// var resultBuilder = ['#'];
+// for (var i = 0; i < missingZeros; i++) {
+// resultBuilder.push('0');
+// }
+// resultBuilder.push(hexString);
+// return resultBuilder.join('');
+// };
+//
+// // ...
+//
+message Color {
+ // The amount of red in the color as a value in the interval [0, 1].
+ float red = 1;
+
+ // The amount of green in the color as a value in the interval [0, 1].
+ float green = 2;
+
+ // The amount of blue in the color as a value in the interval [0, 1].
+ float blue = 3;
+
+ // The fraction of this color that should be applied to the pixel. That is,
+ // the final pixel color is defined by the equation:
+ //
+ // pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
+ //
+ // This means that a value of 1.0 corresponds to a solid color, whereas
+ // a value of 0.0 corresponds to a completely transparent color. This
+ // uses a wrapper message rather than a simple float scalar so that it is
+ // possible to distinguish between a default value and the value being unset.
+ // If omitted, this color object is to be rendered as a solid color
+ // (as if the alpha value had been explicitly given with a value of 1.0).
+ google.protobuf.FloatValue alpha = 4;
+}
diff --git a/speech/grpc/src/main/proto/google/type/date.proto b/speech/grpc/src/main/proto/google/type/date.proto
new file mode 100644
index 00000000000..a12090b8a4e
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/type/date.proto
@@ -0,0 +1,43 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.type;
+
+option java_generate_equals_and_hash = true;
+option java_multiple_files = true;
+option java_outer_classname = "DateProto";
+option java_package = "com.google.type";
+
+
+// Represents a whole calendar date, e.g. date of birth. The time of day and
+// time zone are either specified elsewhere or are not significant. The date
+// is relative to the Proleptic Gregorian Calendar. The day may be 0 to
+// represent a year and month where the day is not significant, e.g. credit card
+// expiration date. The year may be 0 to represent a month and day independent
+// of year, e.g. anniversary date. Related types are [google.type.TimeOfDay][google.type.TimeOfDay]
+// and [google.protobuf.Timestamp][google.protobuf.Timestamp].
+message Date {
+ // Year of date. Must be from 1 to 9,999, or 0 if specifying a date without
+ // a year.
+ int32 year = 1;
+
+ // Month of year of date. Must be from 1 to 12.
+ int32 month = 2;
+
+ // Day of month. Must be from 1 to 31 and valid for the year and month, or 0
+ // if specifying a year/month where the day is not sigificant.
+ int32 day = 3;
+}
diff --git a/speech/grpc/src/main/proto/google/type/dayofweek.proto b/speech/grpc/src/main/proto/google/type/dayofweek.proto
new file mode 100644
index 00000000000..df09f69912b
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/type/dayofweek.proto
@@ -0,0 +1,50 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.type;
+
+option java_generate_equals_and_hash = true;
+option java_multiple_files = true;
+option java_outer_classname = "DayOfWeekProto";
+option java_package = "com.google.type";
+
+
+// Represents a day of week.
+enum DayOfWeek {
+ // The unspecified day-of-week.
+ DAY_OF_WEEK_UNSPECIFIED = 0;
+
+ // The day-of-week of Monday.
+ MONDAY = 1;
+
+ // The day-of-week of Tuesday.
+ TUESDAY = 2;
+
+ // The day-of-week of Wednesday.
+ WEDNESDAY = 3;
+
+ // The day-of-week of Thursday.
+ THURSDAY = 4;
+
+ // The day-of-week of Friday.
+ FRIDAY = 5;
+
+ // The day-of-week of Saturday.
+ SATURDAY = 6;
+
+ // The day-of-week of Sunday.
+ SUNDAY = 7;
+}
diff --git a/speech/grpc/src/main/proto/google/type/latlng.proto b/speech/grpc/src/main/proto/google/type/latlng.proto
new file mode 100644
index 00000000000..198decc0e76
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/type/latlng.proto
@@ -0,0 +1,36 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.type;
+
+option java_generate_equals_and_hash = true;
+option java_multiple_files = true;
+option java_outer_classname = "LatLngProto";
+option java_package = "com.google.type";
+
+
+// An object representing a latitude/longitude pair. This is expressed as a pair
+// of doubles representing degrees latitude and degrees longitude. Unless
+// specified otherwise, this must conform to the
+// WGS84
+// standard . Values must be within normalized ranges.
+message LatLng {
+ // The latitude in degrees. It must be in the range [-90.0, +90.0].
+ double latitude = 1;
+
+ // The longitude in degrees. It must be in the range [-180.0, +180.0].
+ double longitude = 2;
+}
diff --git a/speech/grpc/src/main/proto/google/type/money.proto b/speech/grpc/src/main/proto/google/type/money.proto
new file mode 100644
index 00000000000..041454a23a7
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/type/money.proto
@@ -0,0 +1,40 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.type;
+
+option java_multiple_files = true;
+option java_outer_classname = "MoneyProto";
+option java_package = "com.google.type";
+
+
+// Represents an amount of money with its currency type.
+message Money {
+ // The 3-letter currency code defined in ISO 4217.
+ string currency_code = 1;
+
+ // The whole units of the amount.
+ // For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
+ int64 units = 2;
+
+ // Number of nano (10^-9) units of the amount.
+ // The value must be between -999,999,999 and +999,999,999 inclusive.
+ // If `units` is positive, `nanos` must be positive or zero.
+ // If `units` is zero, `nanos` can be positive, zero, or negative.
+ // If `units` is negative, `nanos` must be negative or zero.
+ // For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
+ int32 nanos = 3;
+}
diff --git a/speech/grpc/src/main/proto/google/type/timeofday.proto b/speech/grpc/src/main/proto/google/type/timeofday.proto
new file mode 100644
index 00000000000..f39266e00cf
--- /dev/null
+++ b/speech/grpc/src/main/proto/google/type/timeofday.proto
@@ -0,0 +1,42 @@
+// Copyright (c) 2015, Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+package google.type;
+
+option java_generate_equals_and_hash = true;
+option java_multiple_files = true;
+option java_outer_classname = "TimeOfDayProto";
+option java_package = "com.google.type";
+
+
+// Represents a time of day. The date and time zone are either not significant
+// or are specified elsewhere. An API may chose to allow leap seconds. Related
+// types are [google.type.Date][google.type.Date] and [google.protobuf.Timestamp][google.protobuf.Timestamp].
+message TimeOfDay {
+ // Hours of day in 24 hour format. Should be from 0 to 23. An API may choose
+ // to allow the value "24:00:00" for scenarios like business closing time.
+ int32 hours = 1;
+
+ // Minutes of hour of day. Must be from 0 to 59.
+ int32 minutes = 2;
+
+ // Seconds of minutes of the time. Must normally be from 0 to 59. An API may
+ // allow the value 60 if it allows leap-seconds.
+ int32 seconds = 3;
+
+ // Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
+ int32 nanos = 4;
+}