diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..482addc9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,51 @@ +--- +name: Bug report +about: Create a report to help us improve + +--- + +Thanks for stopping by to let us know something could be better! + +**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. + +Please run down the following list and make sure you've tried the usual "quick fixes": + + - Search the issues already opened: https://github.com/googleapis/java-mediatranslation/issues + - Check for answers on StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform + +If you are still having issues, please include as much information as possible: + +#### Environment details + +1. Specify the API at the beginning of the title. For example, "BigQuery: ..."). + General, Core, and Other are also allowed as types +2. OS type and version: +3. Java version: +4. mediatranslation version(s): + +#### Steps to reproduce + + 1. ? + 2. ? + +#### Code example + +```java +// example +``` + +#### Stack trace +``` +Any relevant stacktrace here. +``` + +#### External references such as API reference guides + +- ? + +#### Any additional information below + + +Following these steps guarantees the quickest resolution possible. + +Thanks! diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..754e30c6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,21 @@ +--- +name: Feature request +about: Suggest an idea for this library + +--- + +Thanks for stopping by to let us know something could be better! + +**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. + +**Is your feature request related to a problem? Please describe.** +What the problem is. Example: I'm always frustrated when [...] + +**Describe the solution you'd like** +What you want to happen. + +**Describe alternatives you've considered** +Any alternative solutions or features you've considered. + +**Additional context** +Any other context or screenshots about the feature request. diff --git a/.github/ISSUE_TEMPLATE/support_request.md b/.github/ISSUE_TEMPLATE/support_request.md new file mode 100644 index 00000000..99586903 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/support_request.md @@ -0,0 +1,7 @@ +--- +name: Support request +about: If you have a support contract with Google, please create an issue in the Google Cloud Support console. + +--- + +**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..997b8ac3 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ +Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: +- [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/java-mediatranslation/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea +- [ ] Ensure the tests and linter pass +- [ ] Code coverage does not decrease (if any source code was changed) +- [ ] Appropriate docs were updated (if necessary) + +Fixes # ☕️ diff --git a/.github/release-please.yml b/.github/release-please.yml new file mode 100644 index 00000000..dce2c845 --- /dev/null +++ b/.github/release-please.yml @@ -0,0 +1,2 @@ +releaseType: java-yoshi +bumpMinorPreMajor: true \ No newline at end of file diff --git a/.github/trusted-contribution.yml b/.github/trusted-contribution.yml new file mode 100644 index 00000000..f247d5c7 --- /dev/null +++ b/.github/trusted-contribution.yml @@ -0,0 +1,2 @@ +trustedContributors: +- renovate-bot \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..bbec058d --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +# Maven +target/ + +# Eclipse +.classpath +.project +.settings + +# Intellij +*.iml +.idea/ + +# python utilities +*.pyc +__pycache__ \ No newline at end of file diff --git a/.kokoro/build.bat b/.kokoro/build.bat new file mode 100644 index 00000000..d8a1760c --- /dev/null +++ b/.kokoro/build.bat @@ -0,0 +1,3 @@ +:: See documentation in type-shell-output.bat + +"C:\Program Files\Git\bin\bash.exe" github/java-mediatranslation/.kokoro/build.sh diff --git a/.kokoro/build.sh b/.kokoro/build.sh new file mode 100755 index 00000000..9f661c2d --- /dev/null +++ b/.kokoro/build.sh @@ -0,0 +1,108 @@ +#!/bin/bash +# Copyright 2019 Google LLC +# +# 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. + +set -eo pipefail + +## Get the directory of the build script +scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) +## cd to the parent directory, i.e. the root of the git repo +cd ${scriptDir}/.. + +# Print out Java version +java -version +echo ${JOB_TYPE} + +mvn install -B -V \ + -DskipTests=true \ + -Dclirr.skip=true \ + -Denforcer.skip=true \ + -Dmaven.javadoc.skip=true \ + -Dgcloud.download.skip=true \ + -T 1C + +# if GOOGLE_APPLICATION_CREDIENTIALS is specified as a relative path prepend Kokoro root directory onto it +if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTIALS}" != /* ]]; then + export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_ROOT}/src/${GOOGLE_APPLICATION_CREDENTIALS}) +fi + +RETURN_CODE=0 +set +e + +case ${JOB_TYPE} in +test) + mvn test -B -Dclirr.skip=true -Denforcer.skip=true + RETURN_CODE=$? + ;; +lint) + mvn \ + -Penable-samples \ + com.coveo:fmt-maven-plugin:check + RETURN_CODE=$? + ;; +javadoc) + mvn javadoc:javadoc javadoc:test-javadoc + RETURN_CODE=$? + ;; +integration) + mvn -B ${INTEGRATION_TEST_ARGS} \ + -Penable-integration-tests \ + -DtrimStackTrace=false \ + -Dclirr.skip=true \ + -Denforcer.skip=true \ + -fae \ + verify + RETURN_CODE=$? + ;; +samples) + if [[ -f samples/pom.xml ]] + then + pushd samples + mvn -B \ + -Penable-samples \ + -DtrimStackTrace=false \ + -Dclirr.skip=true \ + -Denforcer.skip=true \ + -fae \ + verify + RETURN_CODE=$? + popd + else + echo "no sample pom.xml found - skipping sample tests" + fi + ;; +clirr) + mvn -B -Denforcer.skip=true clirr:check + RETURN_CODE=$? + ;; +*) + ;; +esac + +if [ "${REPORT_COVERAGE}" == "true" ] +then + bash ${KOKORO_GFILE_DIR}/codecov.sh +fi + +# fix output location of logs +bash .kokoro/coerce_logs.sh + +if [[ "${ENABLE_BUILD_COP}" == "true" ]] +then + chmod +x ${KOKORO_GFILE_DIR}/linux_amd64/buildcop + ${KOKORO_GFILE_DIR}/linux_amd64/buildcop -repo=googleapis/java-mediatranslation +fi + +echo "exiting with ${RETURN_CODE}" +exit ${RETURN_CODE} diff --git a/.kokoro/coerce_logs.sh b/.kokoro/coerce_logs.sh new file mode 100755 index 00000000..5cf7ba49 --- /dev/null +++ b/.kokoro/coerce_logs.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Copyright 2019 Google LLC +# +# 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. + +# This script finds and moves sponge logs so that they can be found by placer +# and are not flagged as flaky by sponge. + +set -eo pipefail + +## Get the directory of the build script +scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) +## cd to the parent directory, i.e. the root of the git repo +cd ${scriptDir}/.. + +job=$(basename ${KOKORO_JOB_NAME}) + +echo "coercing sponge logs..." +for xml in `find . -name *-sponge_log.xml` +do + echo "processing ${xml}" + class=$(basename ${xml} | cut -d- -f2) + dir=$(dirname ${xml})/${job}/${class} + text=$(dirname ${xml})/${class}-sponge_log.txt + mkdir -p ${dir} + mv ${xml} ${dir}/sponge_log.xml + mv ${text} ${dir}/sponge_log.txt +done diff --git a/.kokoro/common.cfg b/.kokoro/common.cfg new file mode 100644 index 00000000..b4ae236a --- /dev/null +++ b/.kokoro/common.cfg @@ -0,0 +1,13 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Download trampoline resources. These will be in ${KOKORO_GFILE_DIR} +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# All builds use the trampoline script to run in docker. +build_file: "java-mediatranslation/.kokoro/trampoline.sh" + +# Tell the trampoline which build file to use. +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-mediatranslation/.kokoro/build.sh" +} diff --git a/.kokoro/continuous/common.cfg b/.kokoro/continuous/common.cfg new file mode 100644 index 00000000..27248a50 --- /dev/null +++ b/.kokoro/continuous/common.cfg @@ -0,0 +1,25 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + regex: "**/*sponge_log.txt" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "java-mediatranslation/.kokoro/trampoline.sh" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-mediatranslation/.kokoro/build.sh" +} + +env_vars: { + key: "JOB_TYPE" + value: "test" +} diff --git a/.kokoro/continuous/dependencies.cfg b/.kokoro/continuous/dependencies.cfg new file mode 100644 index 00000000..c1f4cc88 --- /dev/null +++ b/.kokoro/continuous/dependencies.cfg @@ -0,0 +1,12 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-mediatranslation/.kokoro/dependencies.sh" +} diff --git a/.kokoro/continuous/integration.cfg b/.kokoro/continuous/integration.cfg new file mode 100644 index 00000000..3b017fc8 --- /dev/null +++ b/.kokoro/continuous/integration.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} diff --git a/.kokoro/continuous/java11.cfg b/.kokoro/continuous/java11.cfg new file mode 100644 index 00000000..709f2b4c --- /dev/null +++ b/.kokoro/continuous/java11.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java11" +} diff --git a/.kokoro/continuous/java7.cfg b/.kokoro/continuous/java7.cfg new file mode 100644 index 00000000..cb24f44e --- /dev/null +++ b/.kokoro/continuous/java7.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java7" +} diff --git a/.kokoro/continuous/java8-osx.cfg b/.kokoro/continuous/java8-osx.cfg new file mode 100644 index 00000000..010f0ec0 --- /dev/null +++ b/.kokoro/continuous/java8-osx.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "java-mediatranslation/.kokoro/build.sh" diff --git a/.kokoro/continuous/java8-win.cfg b/.kokoro/continuous/java8-win.cfg new file mode 100644 index 00000000..e27bc1a8 --- /dev/null +++ b/.kokoro/continuous/java8-win.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "java-mediatranslation/.kokoro/build.bat" diff --git a/.kokoro/continuous/java8.cfg b/.kokoro/continuous/java8.cfg new file mode 100644 index 00000000..495cc7ba --- /dev/null +++ b/.kokoro/continuous/java8.cfg @@ -0,0 +1,12 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "REPORT_COVERAGE" + value: "true" +} diff --git a/.kokoro/continuous/lint.cfg b/.kokoro/continuous/lint.cfg new file mode 100644 index 00000000..6d323c8a --- /dev/null +++ b/.kokoro/continuous/lint.cfg @@ -0,0 +1,13 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. + +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "JOB_TYPE" + value: "lint" +} \ No newline at end of file diff --git a/.kokoro/continuous/propose_release.cfg b/.kokoro/continuous/propose_release.cfg new file mode 100644 index 00000000..c33c0037 --- /dev/null +++ b/.kokoro/continuous/propose_release.cfg @@ -0,0 +1,53 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "java-mediatranslation/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-mediatranslation/.kokoro/continuous/propose_release.sh" +} + +# tokens used by release-please to keep an up-to-date release PR. +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "github-magic-proxy-key-release-please" + } + } +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "github-magic-proxy-token-release-please" + } + } +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "github-magic-proxy-url-release-please" + } + } +} diff --git a/.kokoro/continuous/propose_release.sh b/.kokoro/continuous/propose_release.sh new file mode 100755 index 00000000..4ad992c1 --- /dev/null +++ b/.kokoro/continuous/propose_release.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Copyright 2019 Google LLC +# +# 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 +# +# https://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. + +set -eo pipefail + +export NPM_CONFIG_PREFIX=/home/node/.npm-global + +if [ -f ${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please ]; then + # Groom the release PR as new commits are merged. + npx release-please release-pr --token=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-token-release-please \ + --repo-url=googleapis/java-mediatranslation \ + --package-name="mediatranslation" \ + --api-url=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please \ + --proxy-key=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-key-release-please \ + --release-type=java-yoshi +fi diff --git a/.kokoro/continuous/samples.cfg b/.kokoro/continuous/samples.cfg new file mode 100644 index 00000000..fa7b493d --- /dev/null +++ b/.kokoro/continuous/samples.cfg @@ -0,0 +1,31 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "JOB_TYPE" + value: "samples" +} + +env_vars: { + key: "GCLOUD_PROJECT" + value: "gcloud-devel" +} + +env_vars: { + key: "GOOGLE_APPLICATION_CREDENTIALS" + value: "keystore/73713_java_it_service_account" +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "java_it_service_account" + } + } +} diff --git a/.kokoro/dependencies.sh b/.kokoro/dependencies.sh new file mode 100755 index 00000000..18253682 --- /dev/null +++ b/.kokoro/dependencies.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# Copyright 2019 Google LLC +# +# 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. + +set -eo pipefail + +cd github/java-mediatranslation/ + +# Print out Java +java -version +echo $JOB_TYPE + +export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m" + +# this should run maven enforcer +mvn install -B -V \ + -DskipTests=true \ + -Dclirr.skip=true + +mvn -B dependency:analyze -DfailOnWarning=true diff --git a/.kokoro/linkage-monitor.sh b/.kokoro/linkage-monitor.sh new file mode 100755 index 00000000..5247e8b5 --- /dev/null +++ b/.kokoro/linkage-monitor.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Copyright 2019 Google LLC +# +# 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. + +set -eo pipefail +# Display commands being run. +set -x + +cd github/java-mediatranslation/ + +# Print out Java version +java -version +echo ${JOB_TYPE} + +mvn install -B -V \ + -DskipTests=true \ + -Dclirr.skip=true \ + -Denforcer.skip=true \ + -Dmaven.javadoc.skip=true \ + -Dgcloud.download.skip=true + +# Kokoro job cloud-opensource-java/ubuntu/linkage-monitor-gcs creates this JAR +JAR=linkage-monitor-latest-all-deps.jar +curl -v -O "https://storage.googleapis.com/cloud-opensource-java-linkage-monitor/${JAR}" + +# Fails if there's new linkage errors compared with baseline +java -jar ${JAR} com.google.cloud:libraries-bom diff --git a/.kokoro/nightly/common.cfg b/.kokoro/nightly/common.cfg new file mode 100644 index 00000000..27248a50 --- /dev/null +++ b/.kokoro/nightly/common.cfg @@ -0,0 +1,25 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + regex: "**/*sponge_log.txt" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "java-mediatranslation/.kokoro/trampoline.sh" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-mediatranslation/.kokoro/build.sh" +} + +env_vars: { + key: "JOB_TYPE" + value: "test" +} diff --git a/.kokoro/nightly/dependencies.cfg b/.kokoro/nightly/dependencies.cfg new file mode 100644 index 00000000..c1f4cc88 --- /dev/null +++ b/.kokoro/nightly/dependencies.cfg @@ -0,0 +1,12 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-mediatranslation/.kokoro/dependencies.sh" +} diff --git a/.kokoro/nightly/integration.cfg b/.kokoro/nightly/integration.cfg new file mode 100644 index 00000000..8bf59c02 --- /dev/null +++ b/.kokoro/nightly/integration.cfg @@ -0,0 +1,21 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "ENABLE_BUILD_COP" + value: "true" +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "java_it_service_account" + } + } +} diff --git a/.kokoro/nightly/java11.cfg b/.kokoro/nightly/java11.cfg new file mode 100644 index 00000000..709f2b4c --- /dev/null +++ b/.kokoro/nightly/java11.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java11" +} diff --git a/.kokoro/nightly/java7.cfg b/.kokoro/nightly/java7.cfg new file mode 100644 index 00000000..cb24f44e --- /dev/null +++ b/.kokoro/nightly/java7.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java7" +} diff --git a/.kokoro/nightly/java8-osx.cfg b/.kokoro/nightly/java8-osx.cfg new file mode 100644 index 00000000..010f0ec0 --- /dev/null +++ b/.kokoro/nightly/java8-osx.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "java-mediatranslation/.kokoro/build.sh" diff --git a/.kokoro/nightly/java8-win.cfg b/.kokoro/nightly/java8-win.cfg new file mode 100644 index 00000000..e27bc1a8 --- /dev/null +++ b/.kokoro/nightly/java8-win.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "java-mediatranslation/.kokoro/build.bat" diff --git a/.kokoro/nightly/java8.cfg b/.kokoro/nightly/java8.cfg new file mode 100644 index 00000000..495cc7ba --- /dev/null +++ b/.kokoro/nightly/java8.cfg @@ -0,0 +1,12 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "REPORT_COVERAGE" + value: "true" +} diff --git a/.kokoro/nightly/lint.cfg b/.kokoro/nightly/lint.cfg new file mode 100644 index 00000000..6d323c8a --- /dev/null +++ b/.kokoro/nightly/lint.cfg @@ -0,0 +1,13 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. + +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "JOB_TYPE" + value: "lint" +} \ No newline at end of file diff --git a/.kokoro/nightly/samples.cfg b/.kokoro/nightly/samples.cfg new file mode 100644 index 00000000..b4b051cd --- /dev/null +++ b/.kokoro/nightly/samples.cfg @@ -0,0 +1,36 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "JOB_TYPE" + value: "samples" +} + +env_vars: { + key: "GCLOUD_PROJECT" + value: "gcloud-devel" +} + +env_vars: { + key: "GOOGLE_APPLICATION_CREDENTIALS" + value: "keystore/73713_java_it_service_account" +} + +env_vars: { + key: "ENABLE_BUILD_COP" + value: "true" +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "java_it_service_account" + } + } +} diff --git a/.kokoro/presubmit/clirr.cfg b/.kokoro/presubmit/clirr.cfg new file mode 100644 index 00000000..ec572442 --- /dev/null +++ b/.kokoro/presubmit/clirr.cfg @@ -0,0 +1,13 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. + +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "JOB_TYPE" + value: "clirr" +} \ No newline at end of file diff --git a/.kokoro/presubmit/common.cfg b/.kokoro/presubmit/common.cfg new file mode 100644 index 00000000..539b0462 --- /dev/null +++ b/.kokoro/presubmit/common.cfg @@ -0,0 +1,34 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + regex: "**/*sponge_log.txt" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "java-mediatranslation/.kokoro/trampoline.sh" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-mediatranslation/.kokoro/build.sh" +} + +env_vars: { + key: "JOB_TYPE" + value: "test" +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "dpebot_codecov_token" + } + } +} diff --git a/.kokoro/presubmit/dependencies.cfg b/.kokoro/presubmit/dependencies.cfg new file mode 100644 index 00000000..c1f4cc88 --- /dev/null +++ b/.kokoro/presubmit/dependencies.cfg @@ -0,0 +1,12 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-mediatranslation/.kokoro/dependencies.sh" +} diff --git a/.kokoro/presubmit/integration.cfg b/.kokoro/presubmit/integration.cfg new file mode 100644 index 00000000..141f90c1 --- /dev/null +++ b/.kokoro/presubmit/integration.cfg @@ -0,0 +1,31 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "JOB_TYPE" + value: "integration" +} + +env_vars: { + key: "GCLOUD_PROJECT" + value: "gcloud-devel" +} + +env_vars: { + key: "GOOGLE_APPLICATION_CREDENTIALS" + value: "keystore/73713_java_it_service_account" +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "java_it_service_account" + } + } +} diff --git a/.kokoro/presubmit/java11.cfg b/.kokoro/presubmit/java11.cfg new file mode 100644 index 00000000..709f2b4c --- /dev/null +++ b/.kokoro/presubmit/java11.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java11" +} diff --git a/.kokoro/presubmit/java7.cfg b/.kokoro/presubmit/java7.cfg new file mode 100644 index 00000000..cb24f44e --- /dev/null +++ b/.kokoro/presubmit/java7.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java7" +} diff --git a/.kokoro/presubmit/java8-osx.cfg b/.kokoro/presubmit/java8-osx.cfg new file mode 100644 index 00000000..010f0ec0 --- /dev/null +++ b/.kokoro/presubmit/java8-osx.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "java-mediatranslation/.kokoro/build.sh" diff --git a/.kokoro/presubmit/java8-win.cfg b/.kokoro/presubmit/java8-win.cfg new file mode 100644 index 00000000..e27bc1a8 --- /dev/null +++ b/.kokoro/presubmit/java8-win.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "java-mediatranslation/.kokoro/build.bat" diff --git a/.kokoro/presubmit/java8.cfg b/.kokoro/presubmit/java8.cfg new file mode 100644 index 00000000..495cc7ba --- /dev/null +++ b/.kokoro/presubmit/java8.cfg @@ -0,0 +1,12 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "REPORT_COVERAGE" + value: "true" +} diff --git a/.kokoro/presubmit/linkage-monitor.cfg b/.kokoro/presubmit/linkage-monitor.cfg new file mode 100644 index 00000000..76c2520b --- /dev/null +++ b/.kokoro/presubmit/linkage-monitor.cfg @@ -0,0 +1,12 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-mediatranslation/.kokoro/linkage-monitor.sh" +} \ No newline at end of file diff --git a/.kokoro/presubmit/lint.cfg b/.kokoro/presubmit/lint.cfg new file mode 100644 index 00000000..6d323c8a --- /dev/null +++ b/.kokoro/presubmit/lint.cfg @@ -0,0 +1,13 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. + +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "JOB_TYPE" + value: "lint" +} \ No newline at end of file diff --git a/.kokoro/presubmit/samples.cfg b/.kokoro/presubmit/samples.cfg new file mode 100644 index 00000000..fa7b493d --- /dev/null +++ b/.kokoro/presubmit/samples.cfg @@ -0,0 +1,31 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "JOB_TYPE" + value: "samples" +} + +env_vars: { + key: "GCLOUD_PROJECT" + value: "gcloud-devel" +} + +env_vars: { + key: "GOOGLE_APPLICATION_CREDENTIALS" + value: "keystore/73713_java_it_service_account" +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "java_it_service_account" + } + } +} diff --git a/.kokoro/release/bump_snapshot.cfg b/.kokoro/release/bump_snapshot.cfg new file mode 100644 index 00000000..e53ebd85 --- /dev/null +++ b/.kokoro/release/bump_snapshot.cfg @@ -0,0 +1,53 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "java-mediatranslation/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-mediatranslation/.kokoro/release/bump_snapshot.sh" +} + +# tokens used by release-please to keep an up-to-date release PR. +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "github-magic-proxy-key-release-please" + } + } +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "github-magic-proxy-token-release-please" + } + } +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "github-magic-proxy-url-release-please" + } + } +} diff --git a/.kokoro/release/bump_snapshot.sh b/.kokoro/release/bump_snapshot.sh new file mode 100755 index 00000000..71d7fd3b --- /dev/null +++ b/.kokoro/release/bump_snapshot.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Copyright 2019 Google LLC +# +# 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 +# +# https://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. + +set -eo pipefail + +export NPM_CONFIG_PREFIX=/home/node/.npm-global + +if [ -f ${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please ]; then + # Groom the snapshot release PR immediately after publishing a release + npx release-please release-pr --token=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-token-release-please \ + --repo-url=googleapis/java-mediatranslation \ + --package-name="mediatranslation" \ + --api-url=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please \ + --proxy-key=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-key-release-please \ + --snapshot \ + --release-type=java-auth-yoshi +fi diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg new file mode 100644 index 00000000..4e61866e --- /dev/null +++ b/.kokoro/release/common.cfg @@ -0,0 +1,49 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "java-mediatranslation/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 70247 + keyname: "maven-gpg-keyring" + } + } +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 70247 + keyname: "maven-gpg-passphrase" + } + } +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 70247 + keyname: "maven-gpg-pubkeyring" + } + } +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 70247 + keyname: "sonatype-credentials" + } + } +} diff --git a/.kokoro/release/common.sh b/.kokoro/release/common.sh new file mode 100755 index 00000000..6e3f6599 --- /dev/null +++ b/.kokoro/release/common.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# Copyright 2018 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. + +set -eo pipefail + +# Get secrets from keystore and set and environment variables +setup_environment_secrets() { + export GPG_PASSPHRASE=$(cat ${KOKORO_KEYSTORE_DIR}/70247_maven-gpg-passphrase) + export GPG_TTY=$(tty) + export GPG_HOMEDIR=/gpg + mkdir $GPG_HOMEDIR + mv ${KOKORO_KEYSTORE_DIR}/70247_maven-gpg-pubkeyring $GPG_HOMEDIR/pubring.gpg + mv ${KOKORO_KEYSTORE_DIR}/70247_maven-gpg-keyring $GPG_HOMEDIR/secring.gpg + export SONATYPE_USERNAME=$(cat ${KOKORO_KEYSTORE_DIR}/70247_sonatype-credentials | cut -f1 -d'|') + export SONATYPE_PASSWORD=$(cat ${KOKORO_KEYSTORE_DIR}/70247_sonatype-credentials | cut -f2 -d'|') +} + +create_settings_xml_file() { + echo " + + + ossrh + ${SONATYPE_USERNAME} + ${SONATYPE_PASSWORD} + + + sonatype-nexus-staging + ${SONATYPE_USERNAME} + ${SONATYPE_PASSWORD} + + + sonatype-nexus-snapshots + ${SONATYPE_USERNAME} + ${SONATYPE_PASSWORD} + + +" > $1 +} \ No newline at end of file diff --git a/.kokoro/release/drop.cfg b/.kokoro/release/drop.cfg new file mode 100644 index 00000000..69838191 --- /dev/null +++ b/.kokoro/release/drop.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-mediatranslation/.kokoro/release/drop.sh" +} diff --git a/.kokoro/release/drop.sh b/.kokoro/release/drop.sh new file mode 100755 index 00000000..5c4551ef --- /dev/null +++ b/.kokoro/release/drop.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Copyright 2018 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. + +set -eo pipefail + +# STAGING_REPOSITORY_ID must be set +if [ -z "${STAGING_REPOSITORY_ID}" ]; then + echo "Missing STAGING_REPOSITORY_ID environment variable" + exit 1 +fi + +source $(dirname "$0")/common.sh +pushd $(dirname "$0")/../../ + +setup_environment_secrets +create_settings_xml_file "settings.xml" + +mvn nexus-staging:drop -B \ + --settings=settings.xml \ + -DstagingRepositoryId=${STAGING_REPOSITORY_ID} diff --git a/.kokoro/release/promote.cfg b/.kokoro/release/promote.cfg new file mode 100644 index 00000000..06f8cc07 --- /dev/null +++ b/.kokoro/release/promote.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-mediatranslation/.kokoro/release/promote.sh" +} diff --git a/.kokoro/release/promote.sh b/.kokoro/release/promote.sh new file mode 100755 index 00000000..1fa95fa5 --- /dev/null +++ b/.kokoro/release/promote.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Copyright 2018 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. + +set -eo pipefail + +# STAGING_REPOSITORY_ID must be set +if [ -z "${STAGING_REPOSITORY_ID}" ]; then + echo "Missing STAGING_REPOSITORY_ID environment variable" + exit 1 +fi + +source $(dirname "$0")/common.sh + +pushd $(dirname "$0")/../../ + +setup_environment_secrets +create_settings_xml_file "settings.xml" + +mvn nexus-staging:release -B \ + -DperformRelease=true \ + --settings=settings.xml \ + -DstagingRepositoryId=${STAGING_REPOSITORY_ID} diff --git a/.kokoro/release/publish_javadoc.cfg b/.kokoro/release/publish_javadoc.cfg new file mode 100644 index 00000000..25deb25f --- /dev/null +++ b/.kokoro/release/publish_javadoc.cfg @@ -0,0 +1,19 @@ +# Format: //devtools/kokoro/config/proto/build.proto +env_vars: { + key: "STAGING_BUCKET" + value: "docs-staging" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-mediatranslation/.kokoro/release/publish_javadoc.sh" +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "docuploader_service_account" + } + } +} diff --git a/.kokoro/release/publish_javadoc.sh b/.kokoro/release/publish_javadoc.sh new file mode 100755 index 00000000..8170d05e --- /dev/null +++ b/.kokoro/release/publish_javadoc.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# Copyright 2019 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. + +set -eo pipefail + +if [[ -z "${CREDENTIALS}" ]]; then + CREDENTIALS=${KOKORO_KEYSTORE_DIR}/73713_docuploader_service_account +fi + +if [[ -z "${STAGING_BUCKET}" ]]; then + echo "Need to set STAGING_BUCKET environment variable" + exit 1 +fi + +# work from the git root directory +pushd $(dirname "$0")/../../ + +# install docuploader package +python3 -m pip install gcp-docuploader + +# compile all packages +mvn clean install -B -DskipTests=true + +NAME=google-cloud-mediatranslation +VERSION=$(grep ${NAME}: versions.txt | cut -d: -f3) + +# build the docs +mvn site -B + +pushd target/site/apidocs + +# create metadata +python3 -m docuploader create-metadata \ + --name ${NAME} \ + --version ${VERSION} \ + --language java + +# upload docs +python3 -m docuploader upload . \ + --credentials ${CREDENTIALS} \ + --staging-bucket ${STAGING_BUCKET} + +popd diff --git a/.kokoro/release/snapshot.cfg b/.kokoro/release/snapshot.cfg new file mode 100644 index 00000000..c370d11e --- /dev/null +++ b/.kokoro/release/snapshot.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-mediatranslation/.kokoro/release/snapshot.sh" +} \ No newline at end of file diff --git a/.kokoro/release/snapshot.sh b/.kokoro/release/snapshot.sh new file mode 100755 index 00000000..098168a7 --- /dev/null +++ b/.kokoro/release/snapshot.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Copyright 2019 Google LLC +# +# 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. + +set -eo pipefail + +source $(dirname "$0")/common.sh +MAVEN_SETTINGS_FILE=$(realpath $(dirname "$0")/../../)/settings.xml +pushd $(dirname "$0")/../../ + +# ensure we're trying to push a snapshot (no-result returns non-zero exit code) +grep SNAPSHOT versions.txt + +setup_environment_secrets +create_settings_xml_file "settings.xml" + +mvn clean install deploy -B \ + --settings ${MAVEN_SETTINGS_FILE} \ + -DperformRelease=true \ + -Dgpg.executable=gpg \ + -Dgpg.passphrase=${GPG_PASSPHRASE} \ + -Dgpg.homedir=${GPG_HOMEDIR} diff --git a/.kokoro/release/stage.cfg b/.kokoro/release/stage.cfg new file mode 100644 index 00000000..549c5565 --- /dev/null +++ b/.kokoro/release/stage.cfg @@ -0,0 +1,44 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-mediatranslation/.kokoro/release/stage.sh" +} + +# Need to save the properties file +action { + define_artifacts { + regex: "github/java-mediatranslation/target/nexus-staging/staging/*.properties" + strip_prefix: "github/java-mediatranslation" + } +} + +# Fetch the token needed for reporting release status to GitHub +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "yoshi-automation-github-key" + } + } +} + +# Fetch magictoken to use with Magic Github Proxy +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "releasetool-magictoken" + } + } +} + +# Fetch api key to use with Magic Github Proxy +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "magic-github-proxy-api-key" + } + } +} diff --git a/.kokoro/release/stage.sh b/.kokoro/release/stage.sh new file mode 100755 index 00000000..3c482cbc --- /dev/null +++ b/.kokoro/release/stage.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Copyright 2018 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. + +set -eo pipefail + +# Start the releasetool reporter +python3 -m pip install gcp-releasetool +python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script + +source $(dirname "$0")/common.sh +MAVEN_SETTINGS_FILE=$(realpath $(dirname "$0")/../../)/settings.xml +pushd $(dirname "$0")/../../ + +setup_environment_secrets +create_settings_xml_file "settings.xml" + +mvn clean install deploy -B \ + --settings ${MAVEN_SETTINGS_FILE} \ + -DskipTests=true \ + -DperformRelease=true \ + -Dgpg.executable=gpg \ + -Dgpg.passphrase=${GPG_PASSPHRASE} \ + -Dgpg.homedir=${GPG_HOMEDIR} + +if [[ -n "${AUTORELEASE_PR}" ]] +then + mvn nexus-staging:release -B \ + -DperformRelease=true \ + --settings=settings.xml +fi \ No newline at end of file diff --git a/.kokoro/trampoline.sh b/.kokoro/trampoline.sh new file mode 100644 index 00000000..ba17ce01 --- /dev/null +++ b/.kokoro/trampoline.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# Copyright 2018 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. +set -eo pipefail +# Always run the cleanup script, regardless of the success of bouncing into +# the container. +function cleanup() { + chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh + ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh + echo "cleanup"; +} +trap cleanup EXIT +python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" diff --git a/.repo-metadata.json b/.repo-metadata.json new file mode 100644 index 00000000..575ced24 --- /dev/null +++ b/.repo-metadata.json @@ -0,0 +1,14 @@ +{ + "name": "mediatranslation", + "name_pretty": "Media Translation API", + "product_documentation": "https://cloud.google.com/", + "api_description": "provides enterprise quality translation from/to various media types.", + "client_documentation": "https://googleapis.dev/java/google-cloud-mediatranslation/latest/index.html", + "release_level": "beta", + "transport": "grpc", + "language": "java", + "repo": "googleapis/java-mediatranslation", + "repo_short": "java-mediatranslation", + "distribution_name": "com.google.cloud:google-cloud-mediatranslation", + "api_id": "mediatranslation.googleapis.com" +} \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..6b2238bb --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,93 @@ +# Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of +experience, education, socio-economic status, nationality, personal appearance, +race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +This Code of Conduct also applies outside the project spaces when the Project +Steward has a reasonable belief that an individual's behavior may have a +negative impact on the project or its community. + +## Conflict Resolution + +We do not believe that all conflict is bad; healthy debate and disagreement +often yield positive results. However, it is never okay to be disrespectful or +to engage in behavior that violates the project’s code of conduct. + +If you see someone violating the code of conduct, you are encouraged to address +the behavior directly with those involved. Many issues can be resolved quickly +and easily, and this gives people more control over the outcome of their +dispute. If you are unable to resolve the matter for any reason, or if the +behavior is threatening or harassing, report it. We are dedicated to providing +an environment where participants feel welcome and safe. + +Reports should be directed to *[PROJECT STEWARD NAME(s) AND EMAIL(s)]*, the +Project Steward(s) for *[PROJECT NAME]*. It is the Project Steward’s duty to +receive and address reported violations of the code of conduct. They will then +work with a committee consisting of representatives from the Open Source +Programs Office and the Google Open Source Strategy team. If for any reason you +are uncomfortable reaching out the Project Steward, please email +opensource@google.com. + +We will investigate every complaint, but you may not receive a direct response. +We will use our discretion in determining when and how to follow up on reported +incidents, which may range from not taking action to permanent expulsion from +the project and project-sponsored spaces. We will notify the accused of the +report and provide them an opportunity to discuss it before any action is taken. +The identity of the reporter will be omitted from the details of the report +supplied to the accused. In potentially harmful situations, such as ongoing +harassment or threats to anyone's safety, we may take action without notice. + +## Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, +available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..085021dd --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,130 @@ +# How to Contribute + +We'd love to accept your patches and contributions to this project. There are +just a few small guidelines you need to follow. + +## Contributor License Agreement + +Contributions to this project must be accompanied by a Contributor License +Agreement. You (or your employer) retain the copyright to your contribution; +this simply gives us permission to use and redistribute your contributions as +part of the project. Head over to to see +your current agreements on file or to sign a new one. + +You generally only need to submit a CLA once, so if you've already submitted one +(even if it was for a different project), you probably don't need to do it +again. + +## Code reviews + +All submissions, including submissions by project members, require review. We +use GitHub pull requests for this purpose. Consult +[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more +information on using pull requests. + +## Community Guidelines + +This project follows +[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/). + +## Building the project + +To build, package, and run all unit tests run the command + +``` +mvn clean verify +``` + +### Running Integration tests + +To include integration tests when building the project, you need access to +a GCP Project with a valid service account. + +For instructions on how to generate a service account and corresponding +credentials JSON see: [Creating a Service Account][1]. + +Then run the following to build, package, run all unit tests and run all +integration tests. + +```bash +export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json +mvn -Penable-integration-tests clean verify +``` + +## Code Samples + +Code Samples must be bundled in separate Maven modules, and guarded by a +Maven profile with the name `enable-samples`. + +The samples must be separate from the primary project for a few reasons: +1. Primary projects have a minimum Java version of Java 7 whereas samples have + a minimum Java version of Java 8. Due to this we need the ability to + selectively exclude samples from a build run. +2. Many code samples depend on external GCP services and need + credentials to access the service. +3. Code samples are not released as Maven artifacts and must be excluded from + release builds. + +### Building + +```bash +mvn -Penable-samples clean verify +``` + +Some samples require access to GCP services and require a service account: + +```bash +export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json +mvn -Penable-samples clean verify +``` + +### Profile Config + +1. To add samples in a profile to your Maven project, add the following to your +`pom.xml` + + ```xml + + [...] + + + enable-samples + + sample + + + + [...] + + ``` + +2. [Activate](#profile-activation) the profile. +3. Define your samples in a normal Maven project in the `samples/` directory + +### Profile Activation + +To include code samples when building and testing the project, enable the +`enable-samples` Maven profile. + +#### Command line + +To activate the Maven profile on the command line add `-Penable-samples` to your +Maven command. + +#### Maven `settings.xml` + +To activate the Maven profile in your `~/.m2/settings.xml` add an entry of +`enable-samples` following the instructions in [Active Profiles][2]. + +This method has the benefit of applying to all projects you build (and is +respected by IntelliJ IDEA) and is recommended if you are going to be +contributing samples to several projects. + +#### IntelliJ IDEA + +To activate the Maven Profile inside IntelliJ IDEA, follow the instructions in +[Activate Maven profiles][3] to activate `enable-samples`. + +[1]: https://cloud.google.com/docs/authentication/getting-started#creating_a_service_account +[2]: https://maven.apache.org/settings.html#Active_Profiles +[3]: https://www.jetbrains.com/help/idea/work-with-maven-profiles.html#activate_maven_profiles diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/README.md b/README.md new file mode 100644 index 00000000..bd12fa48 --- /dev/null +++ b/README.md @@ -0,0 +1,165 @@ +# Google Media Translation API Client for Java + +Java idiomatic client for [Media Translation API][product-docs]. + +[![Maven][maven-version-image]][maven-version-link] +![Stability][stability-image] + +- [Product Documentation][product-docs] +- [Client Library Documentation][javadocs] + +> Note: This client is a work-in-progress, and may occasionally +> make backwards-incompatible changes. + +## Quickstart + +If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file +```xml + + + + com.google.cloud + libraries-bom + 4.2.0 + pom + import + + + + + + + com.google.cloud + google-cloud-mediatranslation + + +``` + +[//]: # ({x-version-update-start:google-cloud-mediatranslation:released}) + +If you are using Maven without BOM, add this to your dependencies: + +```xml + + com.google.cloud + google-cloud-mediatranslation + 0.0.0 + + +``` + +If you are using Gradle, add this to your dependencies +```Groovy +compile 'com.google.cloud:google-cloud-mediatranslation:0.0.0' +``` +If you are using SBT, add this to your dependencies +```Scala +libraryDependencies += "com.google.cloud" % "google-cloud-mediatranslation" % "0.0.0" +``` +[//]: # ({x-version-update-end}) + +## Authentication + +See the [Authentication][authentication] section in the base directory's README. + +## Getting Started + +### Prerequisites + +You will need a [Google Cloud Platform Console][developer-console] project with the Media Translation API [API enabled][enable-api]. + +[Follow these instructions][create-project] to get your project set up. You will also need to set up the local development environment by +[installing the Google Cloud SDK][cloud-sdk] and running the following commands in command line: +`gcloud auth login` and `gcloud config set project [YOUR PROJECT ID]`. + +### Installation and setup + +You'll need to obtain the `google-cloud-mediatranslation` library. See the [Quickstart](#quickstart) section +to add `google-cloud-mediatranslation` as a dependency in your code. + +## About Media Translation API + + +[Media Translation API][product-docs] provides enterprise quality translation from/to various media types. + +See the [Media Translation API client library docs][javadocs] to learn how to +use this Media Translation API Client Library. + + + + + + +## Troubleshooting + +To get help, follow the instructions in the [shared Troubleshooting document][troubleshooting]. + +## Transport + +Media Translation API uses gRPC for the transport layer. + +## Java Versions + +Java 7 or above is required for using this client. + +## Versioning + +This library follows [Semantic Versioning](http://semver.org/). + + +It is currently in major version zero (``0.y.z``), which means that anything may change at any time +and the public API should not be considered stable. + + +## Contributing + + +Contributions to this library are always welcome and highly encouraged. + +See [CONTRIBUTING][contributing] for more information how to get started. + +Please note that this project is released with a Contributor Code of Conduct. By participating in +this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more +information. + +## License + +Apache 2.0 - See [LICENSE][license] for more information. + +## CI Status + +Java Version | Status +------------ | ------ +Java 7 | [![Kokoro CI][kokoro-badge-image-1]][kokoro-badge-link-1] +Java 8 | [![Kokoro CI][kokoro-badge-image-2]][kokoro-badge-link-2] +Java 8 OSX | [![Kokoro CI][kokoro-badge-image-3]][kokoro-badge-link-3] +Java 8 Windows | [![Kokoro CI][kokoro-badge-image-4]][kokoro-badge-link-4] +Java 11 | [![Kokoro CI][kokoro-badge-image-5]][kokoro-badge-link-5] + +[product-docs]: https://cloud.google.com/ +[javadocs]: https://googleapis.dev/java/google-cloud-mediatranslation/latest/index.html +[kokoro-badge-image-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-mediatranslation/java7.svg +[kokoro-badge-link-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-mediatranslation/java7.html +[kokoro-badge-image-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-mediatranslation/java8.svg +[kokoro-badge-link-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-mediatranslation/java8.html +[kokoro-badge-image-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-mediatranslation/java8-osx.svg +[kokoro-badge-link-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-mediatranslation/java8-osx.html +[kokoro-badge-image-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-mediatranslation/java8-win.svg +[kokoro-badge-link-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-mediatranslation/java8-win.html +[kokoro-badge-image-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-mediatranslation/java11.svg +[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-mediatranslation/java11.html +[stability-image]: https://img.shields.io/badge/stability-beta-yellow +[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-mediatranslation.svg +[maven-version-link]: https://search.maven.org/search?q=g:com.google.cloud%20AND%20a:google-cloud-mediatranslation&core=gav +[authentication]: https://github.com/googleapis/google-cloud-java#authentication +[developer-console]: https://console.developers.google.com/ +[create-project]: https://cloud.google.com/resource-manager/docs/creating-managing-projects +[cloud-sdk]: https://cloud.google.com/sdk/ +[troubleshooting]: https://github.com/googleapis/google-cloud-common/blob/master/troubleshooting/readme.md#troubleshooting +[contributing]: https://github.com/googleapis/java-mediatranslation/blob/master/CONTRIBUTING.md +[code-of-conduct]: https://github.com/googleapis/java-mediatranslation/blob/master/CODE_OF_CONDUCT.md#contributor-code-of-conduct +[license]: https://github.com/googleapis/java-mediatranslation/blob/master/LICENSE + +[enable-api]: https://console.cloud.google.com/flows/enableapi?apiid=mediatranslation.googleapis.com +[libraries-bom]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM +[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png diff --git a/codecov.yaml b/codecov.yaml new file mode 100644 index 00000000..5724ea94 --- /dev/null +++ b/codecov.yaml @@ -0,0 +1,4 @@ +--- +codecov: + ci: + - source.cloud.google.com diff --git a/google-cloud-mediatranslation-bom/pom.xml b/google-cloud-mediatranslation-bom/pom.xml new file mode 100644 index 00000000..3feea564 --- /dev/null +++ b/google-cloud-mediatranslation-bom/pom.xml @@ -0,0 +1,93 @@ + + + 4.0.0 + com.google.cloud + google-cloud-mediatranslation-bom + 0.0.1-SNAPSHOT + pom + + com.google.cloud + google-cloud-shared-config + 0.2.1 + + + Google Media Translation API BOM + https://github.com/googleapis/java-mediatranslation + + BOM for Media Translation API + + + + Google LLC + + + + + chingor13 + Jeff Ching + chingor@google.com + Google LLC + + Developer + + + + + + scm:git:https://github.com/googleapis/java-mediatranslation.git + scm:git:git@github.com:googleapis/java-mediatranslation.git + https://github.com/googleapis/java-mediatranslation + + + + + sonatype-nexus-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + sonatype-nexus-staging + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + + + + com.google.cloud + google-cloud-mediatranslation + 0.0.1-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-mediatranslation-v1beta1 + 0.0.1-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-mediatranslation-v1beta1 + 0.0.1-SNAPSHOT + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + true + + + + + \ No newline at end of file diff --git a/google-cloud-mediatranslation/pom.xml b/google-cloud-mediatranslation/pom.xml new file mode 100644 index 00000000..9802eecf --- /dev/null +++ b/google-cloud-mediatranslation/pom.xml @@ -0,0 +1,101 @@ + + + 4.0.0 + com.google.cloud + google-cloud-mediatranslation + 0.0.1-SNAPSHOT + jar + Google Media Translation API + https://github.com/googleapis/java-mediatranslation + provides enterprise quality translation from/to various media types. + + com.google.cloud + google-cloud-mediatranslation-parent + 0.0.1-SNAPSHOT + + + google-cloud-mediatranslation + + + + io.grpc + grpc-api + + + io.grpc + grpc-stub + + + io.grpc + grpc-protobuf + + + com.google.api + api-common + + + com.google.protobuf + protobuf-java + + + com.google.api.grpc + proto-google-common-protos + + + + com.google.api.grpc + proto-google-cloud-mediatranslation-v1beta1 + + + com.google.guava + guava + + + com.google.api + gax + + + com.google.api + gax-grpc + + + org.threeten + threetenbp + + + + + junit + junit + test + + + + com.google.api.grpc + grpc-google-cloud-mediatranslation-v1beta1 + test + + + + com.google.api + gax-grpc + testlib + test + + + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + \ No newline at end of file diff --git a/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/SpeechTranslationServiceClient.java b/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/SpeechTranslationServiceClient.java new file mode 100644 index 00000000..4c581b04 --- /dev/null +++ b/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/SpeechTranslationServiceClient.java @@ -0,0 +1,207 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +package com.google.cloud.mediatranslation.v1beta1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.cloud.mediatranslation.v1beta1.stub.SpeechTranslationServiceStub; +import com.google.cloud.mediatranslation.v1beta1.stub.SpeechTranslationServiceStubSettings; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND SERVICE +/** + * Service Description: Provides translation from/to media types. + * + *

This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. Sample code to get started: + * + *

+ * 
+ * try (SpeechTranslationServiceClient speechTranslationServiceClient = SpeechTranslationServiceClient.create()) {
+ *   StreamingTranslateSpeechRequest request = StreamingTranslateSpeechRequest.newBuilder().build();
+ *   ApiFuture<StreamingTranslateSpeechResponse> future = speechTranslationServiceClient.streamingTranslateSpeechCallable().futureCall(request);
+ *   // Do something
+ *   StreamingTranslateSpeechResponse response = future.get();
+ * }
+ * 
+ * 
+ * + *

Note: close() needs to be called on the speechTranslationServiceClient object to clean up + * resources such as threads. In the example above, try-with-resources is used, which automatically + * calls close(). + * + *

The surface of this class includes several types of Java methods for each of the API's + * methods: + * + *

    + *
  1. A "flattened" method. With this type of method, the fields of the request type have been + * converted into function parameters. It may be the case that not all fields are available as + * parameters, and not every API method will have a flattened method entry point. + *
  2. A "request object" method. This type of method only takes one parameter, a request object, + * which must be constructed before the call. Not every API method will have a request object + * method. + *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. + *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist with + * these names, this class includes a format method for each type of name, and additionally a parse + * method to extract the individual identifiers contained within names that are returned. + * + *

This class can be customized by passing in a custom instance of + * SpeechTranslationServiceSettings to create(). For example: + * + *

To customize credentials: + * + *

+ * 
+ * SpeechTranslationServiceSettings speechTranslationServiceSettings =
+ *     SpeechTranslationServiceSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * SpeechTranslationServiceClient speechTranslationServiceClient =
+ *     SpeechTranslationServiceClient.create(speechTranslationServiceSettings);
+ * 
+ * 
+ * + * To customize the endpoint: + * + *
+ * 
+ * SpeechTranslationServiceSettings speechTranslationServiceSettings =
+ *     SpeechTranslationServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * SpeechTranslationServiceClient speechTranslationServiceClient =
+ *     SpeechTranslationServiceClient.create(speechTranslationServiceSettings);
+ * 
+ * 
+ */ +@Generated("by gapic-generator") +@BetaApi +public class SpeechTranslationServiceClient implements BackgroundResource { + private final SpeechTranslationServiceSettings settings; + private final SpeechTranslationServiceStub stub; + + /** Constructs an instance of SpeechTranslationServiceClient with default settings. */ + public static final SpeechTranslationServiceClient create() throws IOException { + return create(SpeechTranslationServiceSettings.newBuilder().build()); + } + + /** + * Constructs an instance of SpeechTranslationServiceClient, using the given settings. The + * channels are created based on the settings passed in, or defaults for any settings that are not + * set. + */ + public static final SpeechTranslationServiceClient create( + SpeechTranslationServiceSettings settings) throws IOException { + return new SpeechTranslationServiceClient(settings); + } + + /** + * Constructs an instance of SpeechTranslationServiceClient, using the given stub for making + * calls. This is for advanced usage - prefer to use SpeechTranslationServiceSettings}. + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final SpeechTranslationServiceClient create(SpeechTranslationServiceStub stub) { + return new SpeechTranslationServiceClient(stub); + } + + /** + * Constructs an instance of SpeechTranslationServiceClient, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected SpeechTranslationServiceClient(SpeechTranslationServiceSettings settings) + throws IOException { + this.settings = settings; + this.stub = ((SpeechTranslationServiceStubSettings) settings.getStubSettings()).createStub(); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected SpeechTranslationServiceClient(SpeechTranslationServiceStub stub) { + this.settings = null; + this.stub = stub; + } + + public final SpeechTranslationServiceSettings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public SpeechTranslationServiceStub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Performs bidirectional streaming speech translation: receive results while sending audio. This + * method is only available via the gRPC API (not REST). + * + *

Sample code: + * + *


+   * try (SpeechTranslationServiceClient speechTranslationServiceClient = SpeechTranslationServiceClient.create()) {
+   *   BidiStream<StreamingTranslateSpeechRequest, StreamingTranslateSpeechResponse> bidiStream =
+   *       speechTranslationServiceClient.streamingTranslateSpeechCallable().call();
+   *
+   *   StreamingTranslateSpeechRequest request = StreamingTranslateSpeechRequest.newBuilder().build();
+   *   bidiStream.send(request);
+   *   for (StreamingTranslateSpeechResponse response : bidiStream) {
+   *     // Do something when receive a response
+   *   }
+   * }
+   * 
+ */ + public final BidiStreamingCallable< + StreamingTranslateSpeechRequest, StreamingTranslateSpeechResponse> + streamingTranslateSpeechCallable() { + return stub.streamingTranslateSpeechCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/SpeechTranslationServiceSettings.java b/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/SpeechTranslationServiceSettings.java new file mode 100644 index 00000000..812fbac3 --- /dev/null +++ b/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/SpeechTranslationServiceSettings.java @@ -0,0 +1,171 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +package com.google.cloud.mediatranslation.v1beta1; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.mediatranslation.v1beta1.stub.SpeechTranslationServiceStubSettings; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link SpeechTranslationServiceClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (mediatranslation.googleapis.com) and default port (443) are + * used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + */ +@Generated("by gapic-generator") +@BetaApi +public class SpeechTranslationServiceSettings + extends ClientSettings { + /** Returns the object with the settings used for calls to streamingTranslateSpeech. */ + public StreamingCallSettings + streamingTranslateSpeechSettings() { + return ((SpeechTranslationServiceStubSettings) getStubSettings()) + .streamingTranslateSpeechSettings(); + } + + public static final SpeechTranslationServiceSettings create( + SpeechTranslationServiceStubSettings stub) throws IOException { + return new SpeechTranslationServiceSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return SpeechTranslationServiceStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return SpeechTranslationServiceStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return SpeechTranslationServiceStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return SpeechTranslationServiceStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return SpeechTranslationServiceStubSettings.defaultGrpcTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return SpeechTranslationServiceStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SpeechTranslationServiceStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected SpeechTranslationServiceSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for SpeechTranslationServiceSettings. */ + public static class Builder + extends ClientSettings.Builder { + protected Builder() throws IOException { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(SpeechTranslationServiceStubSettings.newBuilder(clientContext)); + } + + private static Builder createDefault() { + return new Builder(SpeechTranslationServiceStubSettings.newBuilder()); + } + + protected Builder(SpeechTranslationServiceSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(SpeechTranslationServiceStubSettings.Builder stubSettings) { + super(stubSettings); + } + + public SpeechTranslationServiceStubSettings.Builder getStubSettingsBuilder() { + return ((SpeechTranslationServiceStubSettings.Builder) getStubSettings()); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods( + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** Returns the builder for the settings used for calls to streamingTranslateSpeech. */ + public StreamingCallSettings.Builder< + StreamingTranslateSpeechRequest, StreamingTranslateSpeechResponse> + streamingTranslateSpeechSettings() { + return getStubSettingsBuilder().streamingTranslateSpeechSettings(); + } + + @Override + public SpeechTranslationServiceSettings build() throws IOException { + return new SpeechTranslationServiceSettings(this); + } + } +} diff --git a/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/package-info.java b/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/package-info.java new file mode 100644 index 00000000..d7ec098a --- /dev/null +++ b/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/package-info.java @@ -0,0 +1,40 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ + +/** + * A client to Media Translation API. + * + *

The interfaces provided are listed below, along with usage samples. + * + *

============================== SpeechTranslationServiceClient ============================== + * + *

Service Description: Provides translation from/to media types. + * + *

Sample for SpeechTranslationServiceClient: + * + *

+ * 
+ * try (SpeechTranslationServiceClient speechTranslationServiceClient = SpeechTranslationServiceClient.create()) {
+ *   StreamingTranslateSpeechRequest request = StreamingTranslateSpeechRequest.newBuilder().build();
+ *   StreamingTranslateSpeechResponse response = speechTranslationServiceClient.streamingTranslateSpeechCallable(request);
+ * }
+ * 
+ * 
+ */ +@Generated("by gapic-generator") +package com.google.cloud.mediatranslation.v1beta1; + +import javax.annotation.Generated; diff --git a/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/stub/GrpcSpeechTranslationServiceCallableFactory.java b/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/stub/GrpcSpeechTranslationServiceCallableFactory.java new file mode 100644 index 00000000..ae7260dd --- /dev/null +++ b/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/stub/GrpcSpeechTranslationServiceCallableFactory.java @@ -0,0 +1,115 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +package com.google.cloud.mediatranslation.v1beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * gRPC callable factory implementation for Media Translation API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator") +@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") +public class GrpcSpeechTranslationServiceCallableFactory implements GrpcStubCallableFactory { + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings pagedCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable( + grpcCallSettings, pagedCallSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings batchingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, batchingCallSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings operationCallSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, operationCallSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } +} diff --git a/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/stub/GrpcSpeechTranslationServiceStub.java b/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/stub/GrpcSpeechTranslationServiceStub.java new file mode 100644 index 00000000..b61e70eb --- /dev/null +++ b/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/stub/GrpcSpeechTranslationServiceStub.java @@ -0,0 +1,155 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +package com.google.cloud.mediatranslation.v1beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest; +import com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse; +import io.grpc.MethodDescriptor; +import io.grpc.protobuf.ProtoUtils; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * gRPC stub implementation for Media Translation API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public class GrpcSpeechTranslationServiceStub extends SpeechTranslationServiceStub { + + private static final MethodDescriptor< + StreamingTranslateSpeechRequest, StreamingTranslateSpeechResponse> + streamingTranslateSpeechMethodDescriptor = + MethodDescriptor + .newBuilder() + .setType(MethodDescriptor.MethodType.BIDI_STREAMING) + .setFullMethodName( + "google.cloud.mediatranslation.v1beta1.SpeechTranslationService/StreamingTranslateSpeech") + .setRequestMarshaller( + ProtoUtils.marshaller(StreamingTranslateSpeechRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(StreamingTranslateSpeechResponse.getDefaultInstance())) + .build(); + + private final BackgroundResource backgroundResources; + + private final BidiStreamingCallable< + StreamingTranslateSpeechRequest, StreamingTranslateSpeechResponse> + streamingTranslateSpeechCallable; + + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcSpeechTranslationServiceStub create( + SpeechTranslationServiceStubSettings settings) throws IOException { + return new GrpcSpeechTranslationServiceStub(settings, ClientContext.create(settings)); + } + + public static final GrpcSpeechTranslationServiceStub create(ClientContext clientContext) + throws IOException { + return new GrpcSpeechTranslationServiceStub( + SpeechTranslationServiceStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcSpeechTranslationServiceStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcSpeechTranslationServiceStub( + SpeechTranslationServiceStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcSpeechTranslationServiceStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected GrpcSpeechTranslationServiceStub( + SpeechTranslationServiceStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new GrpcSpeechTranslationServiceCallableFactory()); + } + + /** + * Constructs an instance of GrpcSpeechTranslationServiceStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected GrpcSpeechTranslationServiceStub( + SpeechTranslationServiceStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + GrpcCallSettings + streamingTranslateSpeechTransportSettings = + GrpcCallSettings + .newBuilder() + .setMethodDescriptor(streamingTranslateSpeechMethodDescriptor) + .build(); + + this.streamingTranslateSpeechCallable = + callableFactory.createBidiStreamingCallable( + streamingTranslateSpeechTransportSettings, + settings.streamingTranslateSpeechSettings(), + clientContext); + + backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public BidiStreamingCallable + streamingTranslateSpeechCallable() { + return streamingTranslateSpeechCallable; + } + + @Override + public final void close() { + shutdown(); + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/stub/SpeechTranslationServiceStub.java b/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/stub/SpeechTranslationServiceStub.java new file mode 100644 index 00000000..2e95722b --- /dev/null +++ b/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/stub/SpeechTranslationServiceStub.java @@ -0,0 +1,42 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +package com.google.cloud.mediatranslation.v1beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest; +import com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Base stub class for Media Translation API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public abstract class SpeechTranslationServiceStub implements BackgroundResource { + + public BidiStreamingCallable + streamingTranslateSpeechCallable() { + throw new UnsupportedOperationException("Not implemented: streamingTranslateSpeechCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/stub/SpeechTranslationServiceStubSettings.java b/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/stub/SpeechTranslationServiceStubSettings.java new file mode 100644 index 00000000..30e50040 --- /dev/null +++ b/google-cloud-mediatranslation/src/main/java/com/google/cloud/mediatranslation/v1beta1/stub/SpeechTranslationServiceStubSettings.java @@ -0,0 +1,258 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +package com.google.cloud.mediatranslation.v1beta1.stub; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest; +import com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link SpeechTranslationServiceStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (mediatranslation.googleapis.com) and default port (443) are + * used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + */ +@Generated("by gapic-generator") +@BetaApi +public class SpeechTranslationServiceStubSettings + extends StubSettings { + /** The default scopes of the service. */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build(); + + private final StreamingCallSettings< + StreamingTranslateSpeechRequest, StreamingTranslateSpeechResponse> + streamingTranslateSpeechSettings; + + /** Returns the object with the settings used for calls to streamingTranslateSpeech. */ + public StreamingCallSettings + streamingTranslateSpeechSettings() { + return streamingTranslateSpeechSettings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public SpeechTranslationServiceStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcSpeechTranslationServiceStub.create(this); + } else { + throw new UnsupportedOperationException( + "Transport not supported: " + getTransportChannelProvider().getTransportName()); + } + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return "mediatranslation.googleapis.com:443"; + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder() + .setMaxInboundMessageSize(Integer.MAX_VALUE); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().build(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(SpeechTranslationServiceStubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected SpeechTranslationServiceStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + streamingTranslateSpeechSettings = settingsBuilder.streamingTranslateSpeechSettings().build(); + } + + /** Builder for SpeechTranslationServiceStubSettings. */ + public static class Builder + extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + + private final StreamingCallSettings.Builder< + StreamingTranslateSpeechRequest, StreamingTranslateSpeechResponse> + streamingTranslateSpeechSettings; + + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "idempotent", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); + definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(60000L)) + .setInitialRpcTimeout(Duration.ofMillis(20000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(20000L)) + .setTotalTimeout(Duration.ofMillis(600000L)) + .build(); + definitions.put("default", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + streamingTranslateSpeechSettings = StreamingCallSettings.newBuilder(); + + unaryMethodSettingsBuilders = ImmutableList.>of(); + + initDefaults(this); + } + + private static Builder createDefault() { + Builder builder = new Builder((ClientContext) null); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + + return builder; + } + + protected Builder(SpeechTranslationServiceStubSettings settings) { + super(settings); + + streamingTranslateSpeechSettings = settings.streamingTranslateSpeechSettings.toBuilder(); + + unaryMethodSettingsBuilders = ImmutableList.>of(); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** Returns the builder for the settings used for calls to streamingTranslateSpeech. */ + public StreamingCallSettings.Builder< + StreamingTranslateSpeechRequest, StreamingTranslateSpeechResponse> + streamingTranslateSpeechSettings() { + return streamingTranslateSpeechSettings; + } + + @Override + public SpeechTranslationServiceStubSettings build() throws IOException { + return new SpeechTranslationServiceStubSettings(this); + } + } +} diff --git a/google-cloud-mediatranslation/src/test/java/com/google/cloud/mediatranslation/v1beta1/MockSpeechTranslationService.java b/google-cloud-mediatranslation/src/test/java/com/google/cloud/mediatranslation/v1beta1/MockSpeechTranslationService.java new file mode 100644 index 00000000..f426c044 --- /dev/null +++ b/google-cloud-mediatranslation/src/test/java/com/google/cloud/mediatranslation/v1beta1/MockSpeechTranslationService.java @@ -0,0 +1,57 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +package com.google.cloud.mediatranslation.v1beta1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.AbstractMessage; +import io.grpc.ServerServiceDefinition; +import java.util.List; + +@javax.annotation.Generated("by GAPIC") +@BetaApi +public class MockSpeechTranslationService implements MockGrpcService { + private final MockSpeechTranslationServiceImpl serviceImpl; + + public MockSpeechTranslationService() { + serviceImpl = new MockSpeechTranslationServiceImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(AbstractMessage response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/google-cloud-mediatranslation/src/test/java/com/google/cloud/mediatranslation/v1beta1/MockSpeechTranslationServiceImpl.java b/google-cloud-mediatranslation/src/test/java/com/google/cloud/mediatranslation/v1beta1/MockSpeechTranslationServiceImpl.java new file mode 100644 index 00000000..1dc8a6d9 --- /dev/null +++ b/google-cloud-mediatranslation/src/test/java/com/google/cloud/mediatranslation/v1beta1/MockSpeechTranslationServiceImpl.java @@ -0,0 +1,88 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +package com.google.cloud.mediatranslation.v1beta1; + +import com.google.api.core.BetaApi; +import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceGrpc.SpeechTranslationServiceImplBase; +import com.google.protobuf.AbstractMessage; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; + +@javax.annotation.Generated("by GAPIC") +@BetaApi +public class MockSpeechTranslationServiceImpl extends SpeechTranslationServiceImplBase { + private List requests; + private Queue responses; + + public MockSpeechTranslationServiceImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(AbstractMessage response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public StreamObserver streamingTranslateSpeech( + final StreamObserver responseObserver) { + final Object response = responses.remove(); + StreamObserver requestObserver = + new StreamObserver() { + @Override + public void onNext(StreamingTranslateSpeechRequest value) { + if (response instanceof StreamingTranslateSpeechResponse) { + responseObserver.onNext((StreamingTranslateSpeechResponse) response); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void onError(Throwable t) { + responseObserver.onError(t); + } + + @Override + public void onCompleted() { + responseObserver.onCompleted(); + } + }; + return requestObserver; + } +} diff --git a/google-cloud-mediatranslation/src/test/java/com/google/cloud/mediatranslation/v1beta1/SpeechTranslationServiceClientTest.java b/google-cloud-mediatranslation/src/test/java/com/google/cloud/mediatranslation/v1beta1/SpeechTranslationServiceClientTest.java new file mode 100644 index 00000000..301c945c --- /dev/null +++ b/google-cloud-mediatranslation/src/test/java/com/google/cloud/mediatranslation/v1beta1/SpeechTranslationServiceClientTest.java @@ -0,0 +1,130 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +package com.google.cloud.mediatranslation.v1beta1; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.testing.LocalChannelProvider; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.api.gax.grpc.testing.MockServiceHelper; +import com.google.api.gax.grpc.testing.MockStreamObserver; +import com.google.api.gax.rpc.ApiStreamObserver; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import io.grpc.Status; +import io.grpc.StatusRuntimeException; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.ExecutionException; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@javax.annotation.Generated("by GAPIC") +public class SpeechTranslationServiceClientTest { + private static MockSpeechTranslationService mockSpeechTranslationService; + private static MockServiceHelper serviceHelper; + private SpeechTranslationServiceClient client; + private LocalChannelProvider channelProvider; + + @BeforeClass + public static void startStaticServer() { + mockSpeechTranslationService = new MockSpeechTranslationService(); + serviceHelper = + new MockServiceHelper( + UUID.randomUUID().toString(), + Arrays.asList(mockSpeechTranslationService)); + serviceHelper.start(); + } + + @AfterClass + public static void stopServer() { + serviceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + serviceHelper.reset(); + channelProvider = serviceHelper.createChannelProvider(); + SpeechTranslationServiceSettings settings = + SpeechTranslationServiceSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SpeechTranslationServiceClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + @SuppressWarnings("all") + public void streamingTranslateSpeechTest() throws Exception { + StreamingTranslateSpeechResponse expectedResponse = + StreamingTranslateSpeechResponse.newBuilder().build(); + mockSpeechTranslationService.addResponse(expectedResponse); + StreamingTranslateSpeechRequest request = StreamingTranslateSpeechRequest.newBuilder().build(); + + MockStreamObserver responseObserver = + new MockStreamObserver<>(); + + BidiStreamingCallable + callable = client.streamingTranslateSpeechCallable(); + ApiStreamObserver requestObserver = + callable.bidiStreamingCall(responseObserver); + + requestObserver.onNext(request); + requestObserver.onCompleted(); + + List actualResponses = responseObserver.future().get(); + Assert.assertEquals(1, actualResponses.size()); + Assert.assertEquals(expectedResponse, actualResponses.get(0)); + } + + @Test + @SuppressWarnings("all") + public void streamingTranslateSpeechExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockSpeechTranslationService.addException(exception); + StreamingTranslateSpeechRequest request = StreamingTranslateSpeechRequest.newBuilder().build(); + + MockStreamObserver responseObserver = + new MockStreamObserver<>(); + + BidiStreamingCallable + callable = client.streamingTranslateSpeechCallable(); + ApiStreamObserver requestObserver = + callable.bidiStreamingCall(responseObserver); + + requestObserver.onNext(request); + + try { + List actualResponses = responseObserver.future().get(); + Assert.fail("No exception thrown"); + } catch (ExecutionException e) { + Assert.assertTrue(e.getCause() instanceof InvalidArgumentException); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } +} diff --git a/grpc-google-cloud-mediatranslation-v1beta1/pom.xml b/grpc-google-cloud-mediatranslation-v1beta1/pom.xml new file mode 100644 index 00000000..5a0dcb2d --- /dev/null +++ b/grpc-google-cloud-mediatranslation-v1beta1/pom.xml @@ -0,0 +1,56 @@ + + 4.0.0 + com.google.api.grpc + grpc-google-cloud-mediatranslation-v1beta1 + 0.0.1-SNAPSHOT + grpc-google-cloud-mediatranslation-v1beta1 + GRPC library for grpc-google-cloud-mediatranslation-v1beta1 + + com.google.cloud + google-cloud-mediatranslation-parent + 0.0.1-SNAPSHOT + + + + io.grpc + grpc-api + + + io.grpc + grpc-stub + + + io.grpc + grpc-protobuf + + + com.google.protobuf + protobuf-java + + + com.google.api.grpc + proto-google-cloud-mediatranslation-v1beta1 + + + com.google.guava + guava + + + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + \ No newline at end of file diff --git a/grpc-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/SpeechTranslationServiceGrpc.java b/grpc-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/SpeechTranslationServiceGrpc.java new file mode 100644 index 00000000..b5deefce --- /dev/null +++ b/grpc-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/SpeechTranslationServiceGrpc.java @@ -0,0 +1,355 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +package com.google.cloud.mediatranslation.v1beta1; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; + +/** + * + * + *
+ * Provides translation from/to media types.
+ * 
+ */ +@javax.annotation.Generated( + value = "by gRPC proto compiler", + comments = "Source: google/cloud/mediatranslation/v1beta1/media_translation.proto") +public final class SpeechTranslationServiceGrpc { + + private SpeechTranslationServiceGrpc() {} + + public static final String SERVICE_NAME = + "google.cloud.mediatranslation.v1beta1.SpeechTranslationService"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse> + getStreamingTranslateSpeechMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "StreamingTranslateSpeech", + requestType = com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest.class, + responseType = + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING) + public static io.grpc.MethodDescriptor< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse> + getStreamingTranslateSpeechMethod() { + io.grpc.MethodDescriptor< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse> + getStreamingTranslateSpeechMethod; + if ((getStreamingTranslateSpeechMethod = + SpeechTranslationServiceGrpc.getStreamingTranslateSpeechMethod) + == null) { + synchronized (SpeechTranslationServiceGrpc.class) { + if ((getStreamingTranslateSpeechMethod = + SpeechTranslationServiceGrpc.getStreamingTranslateSpeechMethod) + == null) { + SpeechTranslationServiceGrpc.getStreamingTranslateSpeechMethod = + getStreamingTranslateSpeechMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING) + .setFullMethodName( + generateFullMethodName(SERVICE_NAME, "StreamingTranslateSpeech")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.mediatranslation.v1beta1 + .StreamingTranslateSpeechRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.mediatranslation.v1beta1 + .StreamingTranslateSpeechResponse.getDefaultInstance())) + .setSchemaDescriptor( + new SpeechTranslationServiceMethodDescriptorSupplier( + "StreamingTranslateSpeech")) + .build(); + } + } + } + return getStreamingTranslateSpeechMethod; + } + + /** Creates a new async stub that supports all call types for the service */ + public static SpeechTranslationServiceStub newStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public SpeechTranslationServiceStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new SpeechTranslationServiceStub(channel, callOptions); + } + }; + return SpeechTranslationServiceStub.newStub(factory, channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static SpeechTranslationServiceBlockingStub newBlockingStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public SpeechTranslationServiceBlockingStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new SpeechTranslationServiceBlockingStub(channel, callOptions); + } + }; + return SpeechTranslationServiceBlockingStub.newStub(factory, channel); + } + + /** Creates a new ListenableFuture-style stub that supports unary calls on the service */ + public static SpeechTranslationServiceFutureStub newFutureStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public SpeechTranslationServiceFutureStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new SpeechTranslationServiceFutureStub(channel, callOptions); + } + }; + return SpeechTranslationServiceFutureStub.newStub(factory, channel); + } + + /** + * + * + *
+   * Provides translation from/to media types.
+   * 
+ */ + public abstract static class SpeechTranslationServiceImplBase implements io.grpc.BindableService { + + /** + * + * + *
+     * Performs bidirectional streaming speech translation: receive results while
+     * sending audio. This method is only available via the gRPC API (not REST).
+     * 
+ */ + public io.grpc.stub.StreamObserver< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest> + streamingTranslateSpeech( + io.grpc.stub.StreamObserver< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse> + responseObserver) { + return asyncUnimplementedStreamingCall(getStreamingTranslateSpeechMethod(), responseObserver); + } + + @java.lang.Override + public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getStreamingTranslateSpeechMethod(), + asyncBidiStreamingCall( + new MethodHandlers< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse>( + this, METHODID_STREAMING_TRANSLATE_SPEECH))) + .build(); + } + } + + /** + * + * + *
+   * Provides translation from/to media types.
+   * 
+ */ + public static final class SpeechTranslationServiceStub + extends io.grpc.stub.AbstractAsyncStub { + private SpeechTranslationServiceStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected SpeechTranslationServiceStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new SpeechTranslationServiceStub(channel, callOptions); + } + + /** + * + * + *
+     * Performs bidirectional streaming speech translation: receive results while
+     * sending audio. This method is only available via the gRPC API (not REST).
+     * 
+ */ + public io.grpc.stub.StreamObserver< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest> + streamingTranslateSpeech( + io.grpc.stub.StreamObserver< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse> + responseObserver) { + return asyncBidiStreamingCall( + getChannel().newCall(getStreamingTranslateSpeechMethod(), getCallOptions()), + responseObserver); + } + } + + /** + * + * + *
+   * Provides translation from/to media types.
+   * 
+ */ + public static final class SpeechTranslationServiceBlockingStub + extends io.grpc.stub.AbstractBlockingStub { + private SpeechTranslationServiceBlockingStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected SpeechTranslationServiceBlockingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new SpeechTranslationServiceBlockingStub(channel, callOptions); + } + } + + /** + * + * + *
+   * Provides translation from/to media types.
+   * 
+ */ + public static final class SpeechTranslationServiceFutureStub + extends io.grpc.stub.AbstractFutureStub { + private SpeechTranslationServiceFutureStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected SpeechTranslationServiceFutureStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new SpeechTranslationServiceFutureStub(channel, callOptions); + } + } + + private static final int METHODID_STREAMING_TRANSLATE_SPEECH = 0; + + private static final class MethodHandlers + implements io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final SpeechTranslationServiceImplBase serviceImpl; + private final int methodId; + + MethodHandlers(SpeechTranslationServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_STREAMING_TRANSLATE_SPEECH: + return (io.grpc.stub.StreamObserver) + serviceImpl.streamingTranslateSpeech( + (io.grpc.stub.StreamObserver< + com.google.cloud.mediatranslation.v1beta1 + .StreamingTranslateSpeechResponse>) + responseObserver); + default: + throw new AssertionError(); + } + } + } + + private abstract static class SpeechTranslationServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, + io.grpc.protobuf.ProtoServiceDescriptorSupplier { + SpeechTranslationServiceBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("SpeechTranslationService"); + } + } + + private static final class SpeechTranslationServiceFileDescriptorSupplier + extends SpeechTranslationServiceBaseDescriptorSupplier { + SpeechTranslationServiceFileDescriptorSupplier() {} + } + + private static final class SpeechTranslationServiceMethodDescriptorSupplier + extends SpeechTranslationServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + SpeechTranslationServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (SpeechTranslationServiceGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = + result = + io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new SpeechTranslationServiceFileDescriptorSupplier()) + .addMethod(getStreamingTranslateSpeechMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/java.header b/java.header new file mode 100644 index 00000000..3a9b503a --- /dev/null +++ b/java.header @@ -0,0 +1,15 @@ +^/\*$ +^ \* Copyright \d\d\d\d,? Google (Inc\.|LLC)( All [rR]ights [rR]eserved\.)?$ +^ \*$ +^ \* 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$ +^ \*$ +^ \*[ ]+https?://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\.$ +^ \*/$ diff --git a/license-checks.xml b/license-checks.xml new file mode 100644 index 00000000..6597fced --- /dev/null +++ b/license-checks.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..6406f9b0 --- /dev/null +++ b/pom.xml @@ -0,0 +1,256 @@ + + + 4.0.0 + com.google.cloud + google-cloud-mediatranslation-parent + pom + 0.0.1-SNAPSHOT + Google Media Translation API Parent + https://github.com/googleapis/java-mediatranslation + + Java idiomatic client for Google Cloud Platform services. + + + + com.google.cloud + google-cloud-shared-config + 0.4.0 + + + + + chingor + Jeff Ching + chingor@google.com + Google + + Developer + + + + + Google LLC + + + scm:git:git@github.com:googleapis/java-mediatranslation.git + scm:git:git@github.com:googleapis/java-mediatranslation.git + https://github.com/googleapis/java-mediatranslation + HEAD + + + https://github.com/googleapis/java-mediatranslation/issues + GitHub Issues + + + + sonatype-nexus-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + sonatype-nexus-staging + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + Apache-2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + + + + + UTF-8 + UTF-8 + github + google-cloud-mediatranslation-parent + 1.91.1 + 1.8.1 + 1.17.0 + 1.54.0 + 1.27.2 + 3.11.4 + 4.13 + 28.2-android + 1.4.1 + 1.3.2 + 1.18 + + + + + + com.google.cloud + google-cloud-mediatranslation + 0.0.1-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-mediatranslation-v1beta1 + 0.0.1-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-mediatranslation-v1beta1 + 0.0.1-SNAPSHOT + + + + io.grpc + grpc-bom + ${grpc.version} + pom + import + + + com.google.api + gax-bom + ${gax.version} + pom + import + + + com.google.guava + guava-bom + ${guava.version} + pom + import + + + + com.google.protobuf + protobuf-java + ${protobuf.version} + + + com.google.api + api-common + ${google.api-common.version} + + + com.google.api.grpc + proto-google-common-protos + ${google.common-protos.version} + + + org.threeten + threetenbp + ${threeten.version} + + + javax.annotation + javax.annotation-api + ${javax.annotations.version} + + + org.codehaus.mojo + animal-sniffer-annotations + ${animal-sniffer.version} + + + + junit + junit + ${junit.version} + test + + + com.google.api + gax-grpc + ${gax.version} + testlib + test + + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + org.objenesis:objenesis + + + + + + + + google-cloud-mediatranslation + proto-google-cloud-mediatranslation-v1beta1 + grpc-google-cloud-mediatranslation-v1beta1 + google-cloud-mediatranslation-bom + + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 3.0.0 + + + + index + dependency-info + team + ci-management + issue-management + licenses + scm + dependency-management + distribution-management + summary + modules + + + + + true + ${site.installationModule} + jar + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.1.1 + + + html + + aggregate + javadoc + + + + + none + protected + true + ${project.build.directory}/javadoc + + + Test helpers packages + com.google.cloud.testing + + + SPI packages + com.google.cloud.spi* + + + + + https://grpc.io/grpc-java/javadoc/ + https://developers.google.com/protocol-buffers/docs/reference/java/ + https://googleapis.dev/java/google-auth-library/latest/ + https://googleapis.dev/java/gax/latest/ + https://googleapis.github.io/api-common-java/${google.api-common.version}/apidocs/ + + + + + + \ No newline at end of file diff --git a/proto-google-cloud-mediatranslation-v1beta1/pom.xml b/proto-google-cloud-mediatranslation-v1beta1/pom.xml new file mode 100644 index 00000000..4ff25770 --- /dev/null +++ b/proto-google-cloud-mediatranslation-v1beta1/pom.xml @@ -0,0 +1,33 @@ + + 4.0.0 + com.google.api.grpc + proto-google-cloud-mediatranslation-v1beta1 + 0.0.1-SNAPSHOT + proto-google-cloud-mediatranslation-v1beta1 + PROTO library for proto-google-cloud-mediatranslation-v1beta1 + + com.google.cloud + google-cloud-mediatranslation-parent + 0.0.1-SNAPSHOT + + + + com.google.protobuf + protobuf-java + + + com.google.api.grpc + proto-google-common-protos + + + com.google.api + api-common + + + com.google.guava + guava + + + \ No newline at end of file diff --git a/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/MediaTranslationProto.java b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/MediaTranslationProto.java new file mode 100644 index 00000000..3f1547c4 --- /dev/null +++ b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/MediaTranslationProto.java @@ -0,0 +1,191 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/mediatranslation/v1beta1/media_translation.proto + +package com.google.cloud.mediatranslation.v1beta1; + +public final class MediaTranslationProto { + private MediaTranslationProto() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_mediatranslation_v1beta1_TranslateSpeechConfig_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_mediatranslation_v1beta1_TranslateSpeechConfig_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechConfig_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechConfig_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_TextTranslationResult_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_TextTranslationResult_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResponse_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n=google/cloud/mediatranslation/v1beta1/" + + "media_translation.proto\022%google.cloud.me" + + "diatranslation.v1beta1\032\037google/api/field" + + "_behavior.proto\032\027google/rpc/status.proto" + + "\032\027google/api/client.proto\"\336\001\n\025TranslateS" + + "peechConfig\022\033\n\016audio_encoding\030\001 \001(\tB\003\340A\002" + + "\022!\n\024source_language_code\030\002 \001(\tB\003\340A\002\022.\n!a" + + "lternative_source_language_codes\030\006 \003(\tB\003" + + "\340A\001\022!\n\024target_language_code\030\003 \001(\tB\003\340A\002\022\036" + + "\n\021sample_rate_hertz\030\004 \001(\005B\003\340A\001\022\022\n\005model\030" + + "\005 \001(\tB\003\340A\001\"\230\001\n\036StreamingTranslateSpeechC" + + "onfig\022W\n\014audio_config\030\001 \001(\0132<.google.clo" + + "ud.mediatranslation.v1beta1.TranslateSpe" + + "echConfigB\003\340A\002\022\035\n\020single_utterance\030\002 \001(\010" + + "B\003\340A\001\"\262\001\n\037StreamingTranslateSpeechReques" + + "t\022a\n\020streaming_config\030\001 \001(\0132E.google.clo" + + "ud.mediatranslation.v1beta1.StreamingTra" + + "nslateSpeechConfigH\000\022\027\n\raudio_content\030\002 " + + "\001(\014H\000B\023\n\021streaming_request\"\301\002\n\036Streaming" + + "TranslateSpeechResult\022~\n\027text_translatio" + + "n_result\030\001 \001(\0132[.google.cloud.mediatrans" + + "lation.v1beta1.StreamingTranslateSpeechR" + + "esult.TextTranslationResultH\000\022\037\n\022recogni" + + "tion_result\030\003 \001(\tB\003\340A\003\032t\n\025TextTranslatio" + + "nResult\022\030\n\013translation\030\001 \001(\tB\003\340A\003\022\025\n\010is_" + + "final\030\002 \001(\010B\003\340A\003\022*\n\035detected_source_lang" + + "uage_code\030\003 \001(\tB\003\340A\003B\010\n\006result\"\362\002\n Strea" + + "mingTranslateSpeechResponse\022&\n\005error\030\001 \001" + + "(\0132\022.google.rpc.StatusB\003\340A\003\022Z\n\006result\030\002 " + + "\001(\0132E.google.cloud.mediatranslation.v1be" + + "ta1.StreamingTranslateSpeechResultB\003\340A\003\022" + + "w\n\021speech_event_type\030\003 \001(\0162W.google.clou" + + "d.mediatranslation.v1beta1.StreamingTran" + + "slateSpeechResponse.SpeechEventTypeB\003\340A\003" + + "\"Q\n\017SpeechEventType\022!\n\035SPEECH_EVENT_TYPE" + + "_UNSPECIFIED\020\000\022\033\n\027END_OF_SINGLE_UTTERANC" + + "E\020\0012\243\002\n\030SpeechTranslationService\022\261\001\n\030Str" + + "eamingTranslateSpeech\022F.google.cloud.med" + + "iatranslation.v1beta1.StreamingTranslate" + + "SpeechRequest\032G.google.cloud.mediatransl" + + "ation.v1beta1.StreamingTranslateSpeechRe" + + "sponse\"\000(\0010\001\032S\312A\037mediatranslation.google" + + "apis.com\322A.https://www.googleapis.com/au" + + "th/cloud-platformB\231\002\n)com.google.cloud.m" + + "ediatranslation.v1beta1B\025MediaTranslatio" + + "nProtoP\001ZUgoogle.golang.org/genproto/goo" + + "gleapis/cloud/mediatranslation/v1beta1;m" + + "ediatranslation\370\001\001\252\002%Google.Cloud.MediaT" + + "ranslation.V1Beta1\312\002%Google\\Cloud\\MediaT" + + "ranslation\\V1beta1\352\002(Google::Cloud::Medi" + + "aTranslation::V1beta1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.rpc.StatusProto.getDescriptor(), + com.google.api.ClientProto.getDescriptor(), + }); + internal_static_google_cloud_mediatranslation_v1beta1_TranslateSpeechConfig_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_cloud_mediatranslation_v1beta1_TranslateSpeechConfig_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_mediatranslation_v1beta1_TranslateSpeechConfig_descriptor, + new java.lang.String[] { + "AudioEncoding", + "SourceLanguageCode", + "AlternativeSourceLanguageCodes", + "TargetLanguageCode", + "SampleRateHertz", + "Model", + }); + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechConfig_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechConfig_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechConfig_descriptor, + new java.lang.String[] { + "AudioConfig", "SingleUtterance", + }); + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechRequest_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechRequest_descriptor, + new java.lang.String[] { + "StreamingConfig", "AudioContent", "StreamingRequest", + }); + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_descriptor, + new java.lang.String[] { + "TextTranslationResult", "RecognitionResult", "Result", + }); + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_TextTranslationResult_descriptor = + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_descriptor + .getNestedTypes() + .get(0); + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_TextTranslationResult_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_TextTranslationResult_descriptor, + new java.lang.String[] { + "Translation", "IsFinal", "DetectedSourceLanguageCode", + }); + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResponse_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResponse_descriptor, + new java.lang.String[] { + "Error", "Result", "SpeechEventType", + }); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.ClientProto.defaultHost); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + registry.add(com.google.api.ClientProto.oauthScopes); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.rpc.StatusProto.getDescriptor(); + com.google.api.ClientProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechConfig.java b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechConfig.java new file mode 100644 index 00000000..f1421d04 --- /dev/null +++ b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechConfig.java @@ -0,0 +1,917 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/mediatranslation/v1beta1/media_translation.proto + +package com.google.cloud.mediatranslation.v1beta1; + +/** + * + * + *
+ * Config used for streaming translation.
+ * 
+ * + * Protobuf type {@code google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig} + */ +public final class StreamingTranslateSpeechConfig extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) + StreamingTranslateSpeechConfigOrBuilder { + private static final long serialVersionUID = 0L; + // Use StreamingTranslateSpeechConfig.newBuilder() to construct. + private StreamingTranslateSpeechConfig( + com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private StreamingTranslateSpeechConfig() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new StreamingTranslateSpeechConfig(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private StreamingTranslateSpeechConfig( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.Builder subBuilder = + null; + if (audioConfig_ != null) { + subBuilder = audioConfig_.toBuilder(); + } + audioConfig_ = + input.readMessage( + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.parser(), + extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(audioConfig_); + audioConfig_ = subBuilder.buildPartial(); + } + + break; + } + case 16: + { + singleUtterance_ = input.readBool(); + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig.class, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig.Builder.class); + } + + public static final int AUDIO_CONFIG_FIELD_NUMBER = 1; + private com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audioConfig_; + /** + * + * + *
+   * Required. The common config for all the following audio contents.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audio_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the audioConfig field is set. + */ + public boolean hasAudioConfig() { + return audioConfig_ != null; + } + /** + * + * + *
+   * Required. The common config for all the following audio contents.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audio_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The audioConfig. + */ + public com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig getAudioConfig() { + return audioConfig_ == null + ? com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.getDefaultInstance() + : audioConfig_; + } + /** + * + * + *
+   * Required. The common config for all the following audio contents.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audio_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfigOrBuilder + getAudioConfigOrBuilder() { + return getAudioConfig(); + } + + public static final int SINGLE_UTTERANCE_FIELD_NUMBER = 2; + private boolean singleUtterance_; + /** + * + * + *
+   * Optional. If `false` or omitted, the system performs
+   * continuous translation (continuing to wait for and process audio even if
+   * the user pauses speaking) until the client closes the input stream (gRPC
+   * API) or until the maximum time limit has been reached. May return multiple
+   * `StreamingTranslateSpeechResult`s with the `is_final` flag set to `true`.
+   * If `true`, the speech translator will detect a single spoken utterance.
+   * When it detects that the user has paused or stopped speaking, it will
+   * return an `END_OF_SINGLE_UTTERANCE` event and cease translation.
+   * When the client receives 'END_OF_SINGLE_UTTERANCE' event, the client should
+   * stop sending the requests. However, clients should keep receiving remaining
+   * responses until the stream is terminated. To construct the complete
+   * sentence in a streaming way, one should override (if 'is_final' of previous
+   * response is false), or append (if 'is_final' of previous response is true).
+   * 
+ * + * bool single_utterance = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The singleUtterance. + */ + public boolean getSingleUtterance() { + return singleUtterance_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (audioConfig_ != null) { + output.writeMessage(1, getAudioConfig()); + } + if (singleUtterance_ != false) { + output.writeBool(2, singleUtterance_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (audioConfig_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getAudioConfig()); + } + if (singleUtterance_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(2, singleUtterance_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj + instanceof com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig)) { + return super.equals(obj); + } + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig other = + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) obj; + + if (hasAudioConfig() != other.hasAudioConfig()) return false; + if (hasAudioConfig()) { + if (!getAudioConfig().equals(other.getAudioConfig())) return false; + } + if (getSingleUtterance() != other.getSingleUtterance()) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasAudioConfig()) { + hash = (37 * hash) + AUDIO_CONFIG_FIELD_NUMBER; + hash = (53 * hash) + getAudioConfig().hashCode(); + } + hash = (37 * hash) + SINGLE_UTTERANCE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getSingleUtterance()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Config used for streaming translation.
+   * 
+ * + * Protobuf type {@code google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfigOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig.class, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig.Builder + .class); + } + + // Construct using + // com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + if (audioConfigBuilder_ == null) { + audioConfig_ = null; + } else { + audioConfig_ = null; + audioConfigBuilder_ = null; + } + singleUtterance_ = false; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechConfig_descriptor; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + getDefaultInstanceForType() { + return com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig build() { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig buildPartial() { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig result = + new com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig(this); + if (audioConfigBuilder_ == null) { + result.audioConfig_ = audioConfig_; + } else { + result.audioConfig_ = audioConfigBuilder_.build(); + } + result.singleUtterance_ = singleUtterance_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other + instanceof com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) { + return mergeFrom( + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig other) { + if (other + == com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + .getDefaultInstance()) return this; + if (other.hasAudioConfig()) { + mergeAudioConfig(other.getAudioConfig()); + } + if (other.getSingleUtterance() != false) { + setSingleUtterance(other.getSingleUtterance()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) + e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audioConfig_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig, + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.Builder, + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfigOrBuilder> + audioConfigBuilder_; + /** + * + * + *
+     * Required. The common config for all the following audio contents.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audio_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the audioConfig field is set. + */ + public boolean hasAudioConfig() { + return audioConfigBuilder_ != null || audioConfig_ != null; + } + /** + * + * + *
+     * Required. The common config for all the following audio contents.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audio_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The audioConfig. + */ + public com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig getAudioConfig() { + if (audioConfigBuilder_ == null) { + return audioConfig_ == null + ? com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.getDefaultInstance() + : audioConfig_; + } else { + return audioConfigBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Required. The common config for all the following audio contents.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audio_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setAudioConfig( + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig value) { + if (audioConfigBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + audioConfig_ = value; + onChanged(); + } else { + audioConfigBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * Required. The common config for all the following audio contents.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audio_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setAudioConfig( + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.Builder builderForValue) { + if (audioConfigBuilder_ == null) { + audioConfig_ = builderForValue.build(); + onChanged(); + } else { + audioConfigBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * Required. The common config for all the following audio contents.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audio_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeAudioConfig( + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig value) { + if (audioConfigBuilder_ == null) { + if (audioConfig_ != null) { + audioConfig_ = + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.newBuilder( + audioConfig_) + .mergeFrom(value) + .buildPartial(); + } else { + audioConfig_ = value; + } + onChanged(); + } else { + audioConfigBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * Required. The common config for all the following audio contents.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audio_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearAudioConfig() { + if (audioConfigBuilder_ == null) { + audioConfig_ = null; + onChanged(); + } else { + audioConfig_ = null; + audioConfigBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * Required. The common config for all the following audio contents.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audio_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.Builder + getAudioConfigBuilder() { + + onChanged(); + return getAudioConfigFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Required. The common config for all the following audio contents.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audio_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfigOrBuilder + getAudioConfigOrBuilder() { + if (audioConfigBuilder_ != null) { + return audioConfigBuilder_.getMessageOrBuilder(); + } else { + return audioConfig_ == null + ? com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.getDefaultInstance() + : audioConfig_; + } + } + /** + * + * + *
+     * Required. The common config for all the following audio contents.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audio_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig, + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.Builder, + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfigOrBuilder> + getAudioConfigFieldBuilder() { + if (audioConfigBuilder_ == null) { + audioConfigBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig, + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.Builder, + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfigOrBuilder>( + getAudioConfig(), getParentForChildren(), isClean()); + audioConfig_ = null; + } + return audioConfigBuilder_; + } + + private boolean singleUtterance_; + /** + * + * + *
+     * Optional. If `false` or omitted, the system performs
+     * continuous translation (continuing to wait for and process audio even if
+     * the user pauses speaking) until the client closes the input stream (gRPC
+     * API) or until the maximum time limit has been reached. May return multiple
+     * `StreamingTranslateSpeechResult`s with the `is_final` flag set to `true`.
+     * If `true`, the speech translator will detect a single spoken utterance.
+     * When it detects that the user has paused or stopped speaking, it will
+     * return an `END_OF_SINGLE_UTTERANCE` event and cease translation.
+     * When the client receives 'END_OF_SINGLE_UTTERANCE' event, the client should
+     * stop sending the requests. However, clients should keep receiving remaining
+     * responses until the stream is terminated. To construct the complete
+     * sentence in a streaming way, one should override (if 'is_final' of previous
+     * response is false), or append (if 'is_final' of previous response is true).
+     * 
+ * + * bool single_utterance = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The singleUtterance. + */ + public boolean getSingleUtterance() { + return singleUtterance_; + } + /** + * + * + *
+     * Optional. If `false` or omitted, the system performs
+     * continuous translation (continuing to wait for and process audio even if
+     * the user pauses speaking) until the client closes the input stream (gRPC
+     * API) or until the maximum time limit has been reached. May return multiple
+     * `StreamingTranslateSpeechResult`s with the `is_final` flag set to `true`.
+     * If `true`, the speech translator will detect a single spoken utterance.
+     * When it detects that the user has paused or stopped speaking, it will
+     * return an `END_OF_SINGLE_UTTERANCE` event and cease translation.
+     * When the client receives 'END_OF_SINGLE_UTTERANCE' event, the client should
+     * stop sending the requests. However, clients should keep receiving remaining
+     * responses until the stream is terminated. To construct the complete
+     * sentence in a streaming way, one should override (if 'is_final' of previous
+     * response is false), or append (if 'is_final' of previous response is true).
+     * 
+ * + * bool single_utterance = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The singleUtterance to set. + * @return This builder for chaining. + */ + public Builder setSingleUtterance(boolean value) { + + singleUtterance_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. If `false` or omitted, the system performs
+     * continuous translation (continuing to wait for and process audio even if
+     * the user pauses speaking) until the client closes the input stream (gRPC
+     * API) or until the maximum time limit has been reached. May return multiple
+     * `StreamingTranslateSpeechResult`s with the `is_final` flag set to `true`.
+     * If `true`, the speech translator will detect a single spoken utterance.
+     * When it detects that the user has paused or stopped speaking, it will
+     * return an `END_OF_SINGLE_UTTERANCE` event and cease translation.
+     * When the client receives 'END_OF_SINGLE_UTTERANCE' event, the client should
+     * stop sending the requests. However, clients should keep receiving remaining
+     * responses until the stream is terminated. To construct the complete
+     * sentence in a streaming way, one should override (if 'is_final' of previous
+     * response is false), or append (if 'is_final' of previous response is true).
+     * 
+ * + * bool single_utterance = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearSingleUtterance() { + + singleUtterance_ = false; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) + } + + // @@protoc_insertion_point(class_scope:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) + private static final com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig(); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public StreamingTranslateSpeechConfig parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new StreamingTranslateSpeechConfig(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechConfigOrBuilder.java b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechConfigOrBuilder.java new file mode 100644 index 00000000..0a58b909 --- /dev/null +++ b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechConfigOrBuilder.java @@ -0,0 +1,92 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/mediatranslation/v1beta1/media_translation.proto + +package com.google.cloud.mediatranslation.v1beta1; + +public interface StreamingTranslateSpeechConfigOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The common config for all the following audio contents.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audio_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the audioConfig field is set. + */ + boolean hasAudioConfig(); + /** + * + * + *
+   * Required. The common config for all the following audio contents.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audio_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The audioConfig. + */ + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig getAudioConfig(); + /** + * + * + *
+   * Required. The common config for all the following audio contents.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig audio_config = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfigOrBuilder + getAudioConfigOrBuilder(); + + /** + * + * + *
+   * Optional. If `false` or omitted, the system performs
+   * continuous translation (continuing to wait for and process audio even if
+   * the user pauses speaking) until the client closes the input stream (gRPC
+   * API) or until the maximum time limit has been reached. May return multiple
+   * `StreamingTranslateSpeechResult`s with the `is_final` flag set to `true`.
+   * If `true`, the speech translator will detect a single spoken utterance.
+   * When it detects that the user has paused or stopped speaking, it will
+   * return an `END_OF_SINGLE_UTTERANCE` event and cease translation.
+   * When the client receives 'END_OF_SINGLE_UTTERANCE' event, the client should
+   * stop sending the requests. However, clients should keep receiving remaining
+   * responses until the stream is terminated. To construct the complete
+   * sentence in a streaming way, one should override (if 'is_final' of previous
+   * response is false), or append (if 'is_final' of previous response is true).
+   * 
+ * + * bool single_utterance = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The singleUtterance. + */ + boolean getSingleUtterance(); +} diff --git a/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechRequest.java b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechRequest.java new file mode 100644 index 00000000..5c12b2f3 --- /dev/null +++ b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechRequest.java @@ -0,0 +1,1079 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/mediatranslation/v1beta1/media_translation.proto + +package com.google.cloud.mediatranslation.v1beta1; + +/** + * + * + *
+ * The top-level message sent by the client for the `StreamingTranslateSpeech`
+ * method. Multiple `StreamingTranslateSpeechRequest` messages are sent. The
+ * first message must contain a `streaming_config` message and must not contain
+ * `audio_content` data. All subsequent messages must contain `audio_content`
+ * data and must not contain a `streaming_config` message.
+ * 
+ * + * Protobuf type {@code google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest} + */ +public final class StreamingTranslateSpeechRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest) + StreamingTranslateSpeechRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use StreamingTranslateSpeechRequest.newBuilder() to construct. + private StreamingTranslateSpeechRequest( + com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private StreamingTranslateSpeechRequest() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new StreamingTranslateSpeechRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private StreamingTranslateSpeechRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig.Builder + subBuilder = null; + if (streamingRequestCase_ == 1) { + subBuilder = + ((com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) + streamingRequest_) + .toBuilder(); + } + streamingRequest_ = + input.readMessage( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + .parser(), + extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom( + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) + streamingRequest_); + streamingRequest_ = subBuilder.buildPartial(); + } + streamingRequestCase_ = 1; + break; + } + case 18: + { + streamingRequestCase_ = 2; + streamingRequest_ = input.readBytes(); + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest.class, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest.Builder + .class); + } + + private int streamingRequestCase_ = 0; + private java.lang.Object streamingRequest_; + + public enum StreamingRequestCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + STREAMING_CONFIG(1), + AUDIO_CONTENT(2), + STREAMINGREQUEST_NOT_SET(0); + private final int value; + + private StreamingRequestCase(int value) { + this.value = value; + } + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static StreamingRequestCase valueOf(int value) { + return forNumber(value); + } + + public static StreamingRequestCase forNumber(int value) { + switch (value) { + case 1: + return STREAMING_CONFIG; + case 2: + return AUDIO_CONTENT; + case 0: + return STREAMINGREQUEST_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public StreamingRequestCase getStreamingRequestCase() { + return StreamingRequestCase.forNumber(streamingRequestCase_); + } + + public static final int STREAMING_CONFIG_FIELD_NUMBER = 1; + /** + * + * + *
+   * Provides information to the recognizer that specifies how to process the
+   * request. The first `StreamingTranslateSpeechRequest` message must contain
+   * a `streaming_config` message.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig streaming_config = 1; + * + * + * @return Whether the streamingConfig field is set. + */ + public boolean hasStreamingConfig() { + return streamingRequestCase_ == 1; + } + /** + * + * + *
+   * Provides information to the recognizer that specifies how to process the
+   * request. The first `StreamingTranslateSpeechRequest` message must contain
+   * a `streaming_config` message.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig streaming_config = 1; + * + * + * @return The streamingConfig. + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + getStreamingConfig() { + if (streamingRequestCase_ == 1) { + return (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) + streamingRequest_; + } + return com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + .getDefaultInstance(); + } + /** + * + * + *
+   * Provides information to the recognizer that specifies how to process the
+   * request. The first `StreamingTranslateSpeechRequest` message must contain
+   * a `streaming_config` message.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig streaming_config = 1; + * + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfigOrBuilder + getStreamingConfigOrBuilder() { + if (streamingRequestCase_ == 1) { + return (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) + streamingRequest_; + } + return com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + .getDefaultInstance(); + } + + public static final int AUDIO_CONTENT_FIELD_NUMBER = 2; + /** + * + * + *
+   * The audio data to be translated. Sequential chunks of audio data are sent
+   * in sequential `StreamingTranslateSpeechRequest` messages. The first
+   * `StreamingTranslateSpeechRequest` message must not contain
+   * `audio_content` data and all subsequent `StreamingTranslateSpeechRequest`
+   * messages must contain `audio_content` data. The audio bytes must be
+   * encoded as specified in `StreamingTranslateSpeechConfig`. Note: as with
+   * all bytes fields, protobuffers use a pure binary representation (not
+   * base64).
+   * 
+ * + * bytes audio_content = 2; + * + * @return The audioContent. + */ + public com.google.protobuf.ByteString getAudioContent() { + if (streamingRequestCase_ == 2) { + return (com.google.protobuf.ByteString) streamingRequest_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (streamingRequestCase_ == 1) { + output.writeMessage( + 1, + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) + streamingRequest_); + } + if (streamingRequestCase_ == 2) { + output.writeBytes(2, (com.google.protobuf.ByteString) streamingRequest_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (streamingRequestCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 1, + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) + streamingRequest_); + } + if (streamingRequestCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeBytesSize( + 2, (com.google.protobuf.ByteString) streamingRequest_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj + instanceof com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest)) { + return super.equals(obj); + } + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest other = + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest) obj; + + if (!getStreamingRequestCase().equals(other.getStreamingRequestCase())) return false; + switch (streamingRequestCase_) { + case 1: + if (!getStreamingConfig().equals(other.getStreamingConfig())) return false; + break; + case 2: + if (!getAudioContent().equals(other.getAudioContent())) return false; + break; + case 0: + default: + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + switch (streamingRequestCase_) { + case 1: + hash = (37 * hash) + STREAMING_CONFIG_FIELD_NUMBER; + hash = (53 * hash) + getStreamingConfig().hashCode(); + break; + case 2: + hash = (37 * hash) + AUDIO_CONTENT_FIELD_NUMBER; + hash = (53 * hash) + getAudioContent().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest + parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The top-level message sent by the client for the `StreamingTranslateSpeech`
+   * method. Multiple `StreamingTranslateSpeechRequest` messages are sent. The
+   * first message must contain a `streaming_config` message and must not contain
+   * `audio_content` data. All subsequent messages must contain `audio_content`
+   * data and must not contain a `streaming_config` message.
+   * 
+ * + * Protobuf type {@code google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest) + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest.class, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest.Builder + .class); + } + + // Construct using + // com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + streamingRequestCase_ = 0; + streamingRequest_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechRequest_descriptor; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest + getDefaultInstanceForType() { + return com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest build() { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest + buildPartial() { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest result = + new com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest(this); + if (streamingRequestCase_ == 1) { + if (streamingConfigBuilder_ == null) { + result.streamingRequest_ = streamingRequest_; + } else { + result.streamingRequest_ = streamingConfigBuilder_.build(); + } + } + if (streamingRequestCase_ == 2) { + result.streamingRequest_ = streamingRequest_; + } + result.streamingRequestCase_ = streamingRequestCase_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other + instanceof com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest) { + return mergeFrom( + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest other) { + if (other + == com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest + .getDefaultInstance()) return this; + switch (other.getStreamingRequestCase()) { + case STREAMING_CONFIG: + { + mergeStreamingConfig(other.getStreamingConfig()); + break; + } + case AUDIO_CONTENT: + { + setAudioContent(other.getAudioContent()); + break; + } + case STREAMINGREQUEST_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest parsedMessage = + null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest) + e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int streamingRequestCase_ = 0; + private java.lang.Object streamingRequest_; + + public StreamingRequestCase getStreamingRequestCase() { + return StreamingRequestCase.forNumber(streamingRequestCase_); + } + + public Builder clearStreamingRequest() { + streamingRequestCase_ = 0; + streamingRequest_ = null; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig.Builder, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfigOrBuilder> + streamingConfigBuilder_; + /** + * + * + *
+     * Provides information to the recognizer that specifies how to process the
+     * request. The first `StreamingTranslateSpeechRequest` message must contain
+     * a `streaming_config` message.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig streaming_config = 1; + * + * + * @return Whether the streamingConfig field is set. + */ + public boolean hasStreamingConfig() { + return streamingRequestCase_ == 1; + } + /** + * + * + *
+     * Provides information to the recognizer that specifies how to process the
+     * request. The first `StreamingTranslateSpeechRequest` message must contain
+     * a `streaming_config` message.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig streaming_config = 1; + * + * + * @return The streamingConfig. + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + getStreamingConfig() { + if (streamingConfigBuilder_ == null) { + if (streamingRequestCase_ == 1) { + return (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) + streamingRequest_; + } + return com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + .getDefaultInstance(); + } else { + if (streamingRequestCase_ == 1) { + return streamingConfigBuilder_.getMessage(); + } + return com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + .getDefaultInstance(); + } + } + /** + * + * + *
+     * Provides information to the recognizer that specifies how to process the
+     * request. The first `StreamingTranslateSpeechRequest` message must contain
+     * a `streaming_config` message.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig streaming_config = 1; + * + */ + public Builder setStreamingConfig( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig value) { + if (streamingConfigBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + streamingRequest_ = value; + onChanged(); + } else { + streamingConfigBuilder_.setMessage(value); + } + streamingRequestCase_ = 1; + return this; + } + /** + * + * + *
+     * Provides information to the recognizer that specifies how to process the
+     * request. The first `StreamingTranslateSpeechRequest` message must contain
+     * a `streaming_config` message.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig streaming_config = 1; + * + */ + public Builder setStreamingConfig( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig.Builder + builderForValue) { + if (streamingConfigBuilder_ == null) { + streamingRequest_ = builderForValue.build(); + onChanged(); + } else { + streamingConfigBuilder_.setMessage(builderForValue.build()); + } + streamingRequestCase_ = 1; + return this; + } + /** + * + * + *
+     * Provides information to the recognizer that specifies how to process the
+     * request. The first `StreamingTranslateSpeechRequest` message must contain
+     * a `streaming_config` message.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig streaming_config = 1; + * + */ + public Builder mergeStreamingConfig( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig value) { + if (streamingConfigBuilder_ == null) { + if (streamingRequestCase_ == 1 + && streamingRequest_ + != com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + .getDefaultInstance()) { + streamingRequest_ = + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig.newBuilder( + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) + streamingRequest_) + .mergeFrom(value) + .buildPartial(); + } else { + streamingRequest_ = value; + } + onChanged(); + } else { + if (streamingRequestCase_ == 1) { + streamingConfigBuilder_.mergeFrom(value); + } + streamingConfigBuilder_.setMessage(value); + } + streamingRequestCase_ = 1; + return this; + } + /** + * + * + *
+     * Provides information to the recognizer that specifies how to process the
+     * request. The first `StreamingTranslateSpeechRequest` message must contain
+     * a `streaming_config` message.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig streaming_config = 1; + * + */ + public Builder clearStreamingConfig() { + if (streamingConfigBuilder_ == null) { + if (streamingRequestCase_ == 1) { + streamingRequestCase_ = 0; + streamingRequest_ = null; + onChanged(); + } + } else { + if (streamingRequestCase_ == 1) { + streamingRequestCase_ = 0; + streamingRequest_ = null; + } + streamingConfigBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Provides information to the recognizer that specifies how to process the
+     * request. The first `StreamingTranslateSpeechRequest` message must contain
+     * a `streaming_config` message.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig streaming_config = 1; + * + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig.Builder + getStreamingConfigBuilder() { + return getStreamingConfigFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Provides information to the recognizer that specifies how to process the
+     * request. The first `StreamingTranslateSpeechRequest` message must contain
+     * a `streaming_config` message.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig streaming_config = 1; + * + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfigOrBuilder + getStreamingConfigOrBuilder() { + if ((streamingRequestCase_ == 1) && (streamingConfigBuilder_ != null)) { + return streamingConfigBuilder_.getMessageOrBuilder(); + } else { + if (streamingRequestCase_ == 1) { + return (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) + streamingRequest_; + } + return com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + .getDefaultInstance(); + } + } + /** + * + * + *
+     * Provides information to the recognizer that specifies how to process the
+     * request. The first `StreamingTranslateSpeechRequest` message must contain
+     * a `streaming_config` message.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig streaming_config = 1; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig.Builder, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfigOrBuilder> + getStreamingConfigFieldBuilder() { + if (streamingConfigBuilder_ == null) { + if (!(streamingRequestCase_ == 1)) { + streamingRequest_ = + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig + .getDefaultInstance(); + } + streamingConfigBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig.Builder, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfigOrBuilder>( + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig) + streamingRequest_, + getParentForChildren(), + isClean()); + streamingRequest_ = null; + } + streamingRequestCase_ = 1; + onChanged(); + ; + return streamingConfigBuilder_; + } + + /** + * + * + *
+     * The audio data to be translated. Sequential chunks of audio data are sent
+     * in sequential `StreamingTranslateSpeechRequest` messages. The first
+     * `StreamingTranslateSpeechRequest` message must not contain
+     * `audio_content` data and all subsequent `StreamingTranslateSpeechRequest`
+     * messages must contain `audio_content` data. The audio bytes must be
+     * encoded as specified in `StreamingTranslateSpeechConfig`. Note: as with
+     * all bytes fields, protobuffers use a pure binary representation (not
+     * base64).
+     * 
+ * + * bytes audio_content = 2; + * + * @return The audioContent. + */ + public com.google.protobuf.ByteString getAudioContent() { + if (streamingRequestCase_ == 2) { + return (com.google.protobuf.ByteString) streamingRequest_; + } + return com.google.protobuf.ByteString.EMPTY; + } + /** + * + * + *
+     * The audio data to be translated. Sequential chunks of audio data are sent
+     * in sequential `StreamingTranslateSpeechRequest` messages. The first
+     * `StreamingTranslateSpeechRequest` message must not contain
+     * `audio_content` data and all subsequent `StreamingTranslateSpeechRequest`
+     * messages must contain `audio_content` data. The audio bytes must be
+     * encoded as specified in `StreamingTranslateSpeechConfig`. Note: as with
+     * all bytes fields, protobuffers use a pure binary representation (not
+     * base64).
+     * 
+ * + * bytes audio_content = 2; + * + * @param value The audioContent to set. + * @return This builder for chaining. + */ + public Builder setAudioContent(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + streamingRequestCase_ = 2; + streamingRequest_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * The audio data to be translated. Sequential chunks of audio data are sent
+     * in sequential `StreamingTranslateSpeechRequest` messages. The first
+     * `StreamingTranslateSpeechRequest` message must not contain
+     * `audio_content` data and all subsequent `StreamingTranslateSpeechRequest`
+     * messages must contain `audio_content` data. The audio bytes must be
+     * encoded as specified in `StreamingTranslateSpeechConfig`. Note: as with
+     * all bytes fields, protobuffers use a pure binary representation (not
+     * base64).
+     * 
+ * + * bytes audio_content = 2; + * + * @return This builder for chaining. + */ + public Builder clearAudioContent() { + if (streamingRequestCase_ == 2) { + streamingRequestCase_ = 0; + streamingRequest_ = null; + onChanged(); + } + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest) + } + + // @@protoc_insertion_point(class_scope:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest) + private static final com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest(); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public StreamingTranslateSpeechRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new StreamingTranslateSpeechRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechRequestOrBuilder.java b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechRequestOrBuilder.java new file mode 100644 index 00000000..cf832c06 --- /dev/null +++ b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechRequestOrBuilder.java @@ -0,0 +1,97 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/mediatranslation/v1beta1/media_translation.proto + +package com.google.cloud.mediatranslation.v1beta1; + +public interface StreamingTranslateSpeechRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Provides information to the recognizer that specifies how to process the
+   * request. The first `StreamingTranslateSpeechRequest` message must contain
+   * a `streaming_config` message.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig streaming_config = 1; + * + * + * @return Whether the streamingConfig field is set. + */ + boolean hasStreamingConfig(); + /** + * + * + *
+   * Provides information to the recognizer that specifies how to process the
+   * request. The first `StreamingTranslateSpeechRequest` message must contain
+   * a `streaming_config` message.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig streaming_config = 1; + * + * + * @return The streamingConfig. + */ + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig getStreamingConfig(); + /** + * + * + *
+   * Provides information to the recognizer that specifies how to process the
+   * request. The first `StreamingTranslateSpeechRequest` message must contain
+   * a `streaming_config` message.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfig streaming_config = 1; + * + */ + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechConfigOrBuilder + getStreamingConfigOrBuilder(); + + /** + * + * + *
+   * The audio data to be translated. Sequential chunks of audio data are sent
+   * in sequential `StreamingTranslateSpeechRequest` messages. The first
+   * `StreamingTranslateSpeechRequest` message must not contain
+   * `audio_content` data and all subsequent `StreamingTranslateSpeechRequest`
+   * messages must contain `audio_content` data. The audio bytes must be
+   * encoded as specified in `StreamingTranslateSpeechConfig`. Note: as with
+   * all bytes fields, protobuffers use a pure binary representation (not
+   * base64).
+   * 
+ * + * bytes audio_content = 2; + * + * @return The audioContent. + */ + com.google.protobuf.ByteString getAudioContent(); + + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest + .StreamingRequestCase + getStreamingRequestCase(); +} diff --git a/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechResponse.java b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechResponse.java new file mode 100644 index 00000000..8618b5bc --- /dev/null +++ b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechResponse.java @@ -0,0 +1,1414 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/mediatranslation/v1beta1/media_translation.proto + +package com.google.cloud.mediatranslation.v1beta1; + +/** + * + * + *
+ * A streaming speech translation response corresponding to a portion of
+ * the audio currently processed.
+ * 
+ * + * Protobuf type {@code google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse} + */ +public final class StreamingTranslateSpeechResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse) + StreamingTranslateSpeechResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use StreamingTranslateSpeechResponse.newBuilder() to construct. + private StreamingTranslateSpeechResponse( + com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private StreamingTranslateSpeechResponse() { + speechEventType_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new StreamingTranslateSpeechResponse(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private StreamingTranslateSpeechResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.rpc.Status.Builder subBuilder = null; + if (error_ != null) { + subBuilder = error_.toBuilder(); + } + error_ = input.readMessage(com.google.rpc.Status.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(error_); + error_ = subBuilder.buildPartial(); + } + + break; + } + case 18: + { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.Builder + subBuilder = null; + if (result_ != null) { + subBuilder = result_.toBuilder(); + } + result_ = + input.readMessage( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .parser(), + extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(result_); + result_ = subBuilder.buildPartial(); + } + + break; + } + case 24: + { + int rawValue = input.readEnum(); + + speechEventType_ = rawValue; + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.class, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.Builder + .class); + } + + /** + * + * + *
+   * Indicates the type of speech event.
+   * 
+ * + * Protobuf enum {@code + * google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType} + */ + public enum SpeechEventType implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * No speech event specified.
+     * 
+ * + * SPEECH_EVENT_TYPE_UNSPECIFIED = 0; + */ + SPEECH_EVENT_TYPE_UNSPECIFIED(0), + /** + * + * + *
+     * This event 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 (although it may subsequently return
+     * additional results). When the client receives 'END_OF_SINGLE_UTTERANCE'
+     * event, the client should stop sending the requests. However, clients
+     * should keep receiving remaining responses until the stream is terminated.
+     * To construct the complete sentence in a streaming way, one should
+     * override (if 'is_final' of previous response is false), or append (if
+     * 'is_final' of previous response is true). This event is only sent if
+     * `single_utterance` was set to `true`, and is not used otherwise.
+     * 
+ * + * END_OF_SINGLE_UTTERANCE = 1; + */ + END_OF_SINGLE_UTTERANCE(1), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * No speech event specified.
+     * 
+ * + * SPEECH_EVENT_TYPE_UNSPECIFIED = 0; + */ + public static final int SPEECH_EVENT_TYPE_UNSPECIFIED_VALUE = 0; + /** + * + * + *
+     * This event 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 (although it may subsequently return
+     * additional results). When the client receives 'END_OF_SINGLE_UTTERANCE'
+     * event, the client should stop sending the requests. However, clients
+     * should keep receiving remaining responses until the stream is terminated.
+     * To construct the complete sentence in a streaming way, one should
+     * override (if 'is_final' of previous response is false), or append (if
+     * 'is_final' of previous response is true). This event is only sent if
+     * `single_utterance` was set to `true`, and is not used otherwise.
+     * 
+ * + * END_OF_SINGLE_UTTERANCE = 1; + */ + public static final int END_OF_SINGLE_UTTERANCE_VALUE = 1; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static SpeechEventType valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static SpeechEventType forNumber(int value) { + switch (value) { + case 0: + return SPEECH_EVENT_TYPE_UNSPECIFIED; + case 1: + return END_OF_SINGLE_UTTERANCE; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public SpeechEventType findValueByNumber(int number) { + return SpeechEventType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + .getDescriptor() + .getEnumTypes() + .get(0); + } + + private static final SpeechEventType[] VALUES = values(); + + public static SpeechEventType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private SpeechEventType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType) + } + + public static final int ERROR_FIELD_NUMBER = 1; + private com.google.rpc.Status error_; + /** + * + * + *
+   * Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that
+   * specifies the error for the operation.
+   * 
+ * + * .google.rpc.Status error = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return Whether the error field is set. + */ + public boolean hasError() { + return error_ != null; + } + /** + * + * + *
+   * Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that
+   * specifies the error for the operation.
+   * 
+ * + * .google.rpc.Status error = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The error. + */ + public com.google.rpc.Status getError() { + return error_ == null ? com.google.rpc.Status.getDefaultInstance() : error_; + } + /** + * + * + *
+   * Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that
+   * specifies the error for the operation.
+   * 
+ * + * .google.rpc.Status error = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + public com.google.rpc.StatusOrBuilder getErrorOrBuilder() { + return getError(); + } + + public static final int RESULT_FIELD_NUMBER = 2; + private com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result_; + /** + * + * + *
+   * Output only. The translation result that is currently being processed (is_final could be
+   * true or false).
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the result field is set. + */ + public boolean hasResult() { + return result_ != null; + } + /** + * + * + *
+   * Output only. The translation result that is currently being processed (is_final could be
+   * true or false).
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The result. + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult getResult() { + return result_ == null + ? com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .getDefaultInstance() + : result_; + } + /** + * + * + *
+   * Output only. The translation result that is currently being processed (is_final could be
+   * true or false).
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResultOrBuilder + getResultOrBuilder() { + return getResult(); + } + + public static final int SPEECH_EVENT_TYPE_FIELD_NUMBER = 3; + private int speechEventType_; + /** + * + * + *
+   * Output only. Indicates the type of speech event.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType speech_event_type = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for speechEventType. + */ + public int getSpeechEventTypeValue() { + return speechEventType_; + } + /** + * + * + *
+   * Output only. Indicates the type of speech event.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType speech_event_type = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The speechEventType. + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType + getSpeechEventType() { + @SuppressWarnings("deprecation") + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType + result = + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + .SpeechEventType.valueOf(speechEventType_); + return result == null + ? com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType + .UNRECOGNIZED + : result; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (error_ != null) { + output.writeMessage(1, getError()); + } + if (result_ != null) { + output.writeMessage(2, getResult()); + } + if (speechEventType_ + != com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + .SpeechEventType.SPEECH_EVENT_TYPE_UNSPECIFIED + .getNumber()) { + output.writeEnum(3, speechEventType_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (error_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getError()); + } + if (result_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getResult()); + } + if (speechEventType_ + != com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + .SpeechEventType.SPEECH_EVENT_TYPE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(3, speechEventType_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj + instanceof com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse)) { + return super.equals(obj); + } + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse other = + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse) obj; + + if (hasError() != other.hasError()) return false; + if (hasError()) { + if (!getError().equals(other.getError())) return false; + } + if (hasResult() != other.hasResult()) return false; + if (hasResult()) { + if (!getResult().equals(other.getResult())) return false; + } + if (speechEventType_ != other.speechEventType_) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasError()) { + hash = (37 * hash) + ERROR_FIELD_NUMBER; + hash = (53 * hash) + getError().hashCode(); + } + if (hasResult()) { + hash = (37 * hash) + RESULT_FIELD_NUMBER; + hash = (53 * hash) + getResult().hashCode(); + } + hash = (37 * hash) + SPEECH_EVENT_TYPE_FIELD_NUMBER; + hash = (53 * hash) + speechEventType_; + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + parseFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * A streaming speech translation response corresponding to a portion of
+   * the audio currently processed.
+   * 
+ * + * Protobuf type {@code google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse) + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.class, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.Builder + .class); + } + + // Construct using + // com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + if (errorBuilder_ == null) { + error_ = null; + } else { + error_ = null; + errorBuilder_ = null; + } + if (resultBuilder_ == null) { + result_ = null; + } else { + result_ = null; + resultBuilder_ = null; + } + speechEventType_ = 0; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResponse_descriptor; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + getDefaultInstanceForType() { + return com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse build() { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + buildPartial() { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse result = + new com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse(this); + if (errorBuilder_ == null) { + result.error_ = error_; + } else { + result.error_ = errorBuilder_.build(); + } + if (resultBuilder_ == null) { + result.result_ = result_; + } else { + result.result_ = resultBuilder_.build(); + } + result.speechEventType_ = speechEventType_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other + instanceof com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse) { + return mergeFrom( + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse other) { + if (other + == com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + .getDefaultInstance()) return this; + if (other.hasError()) { + mergeError(other.getError()); + } + if (other.hasResult()) { + mergeResult(other.getResult()); + } + if (other.speechEventType_ != 0) { + setSpeechEventTypeValue(other.getSpeechEventTypeValue()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse parsedMessage = + null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse) + e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.rpc.Status error_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.rpc.Status, com.google.rpc.Status.Builder, com.google.rpc.StatusOrBuilder> + errorBuilder_; + /** + * + * + *
+     * Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that
+     * specifies the error for the operation.
+     * 
+ * + * .google.rpc.Status error = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return Whether the error field is set. + */ + public boolean hasError() { + return errorBuilder_ != null || error_ != null; + } + /** + * + * + *
+     * Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that
+     * specifies the error for the operation.
+     * 
+ * + * .google.rpc.Status error = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The error. + */ + public com.google.rpc.Status getError() { + if (errorBuilder_ == null) { + return error_ == null ? com.google.rpc.Status.getDefaultInstance() : error_; + } else { + return errorBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that
+     * specifies the error for the operation.
+     * 
+ * + * .google.rpc.Status error = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + public Builder setError(com.google.rpc.Status value) { + if (errorBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + error_ = value; + onChanged(); + } else { + errorBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that
+     * specifies the error for the operation.
+     * 
+ * + * .google.rpc.Status error = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + public Builder setError(com.google.rpc.Status.Builder builderForValue) { + if (errorBuilder_ == null) { + error_ = builderForValue.build(); + onChanged(); + } else { + errorBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that
+     * specifies the error for the operation.
+     * 
+ * + * .google.rpc.Status error = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + public Builder mergeError(com.google.rpc.Status value) { + if (errorBuilder_ == null) { + if (error_ != null) { + error_ = com.google.rpc.Status.newBuilder(error_).mergeFrom(value).buildPartial(); + } else { + error_ = value; + } + onChanged(); + } else { + errorBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that
+     * specifies the error for the operation.
+     * 
+ * + * .google.rpc.Status error = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + public Builder clearError() { + if (errorBuilder_ == null) { + error_ = null; + onChanged(); + } else { + error_ = null; + errorBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that
+     * specifies the error for the operation.
+     * 
+ * + * .google.rpc.Status error = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + public com.google.rpc.Status.Builder getErrorBuilder() { + + onChanged(); + return getErrorFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that
+     * specifies the error for the operation.
+     * 
+ * + * .google.rpc.Status error = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + public com.google.rpc.StatusOrBuilder getErrorOrBuilder() { + if (errorBuilder_ != null) { + return errorBuilder_.getMessageOrBuilder(); + } else { + return error_ == null ? com.google.rpc.Status.getDefaultInstance() : error_; + } + } + /** + * + * + *
+     * Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that
+     * specifies the error for the operation.
+     * 
+ * + * .google.rpc.Status error = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.rpc.Status, com.google.rpc.Status.Builder, com.google.rpc.StatusOrBuilder> + getErrorFieldBuilder() { + if (errorBuilder_ == null) { + errorBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.rpc.Status, + com.google.rpc.Status.Builder, + com.google.rpc.StatusOrBuilder>(getError(), getParentForChildren(), isClean()); + error_ = null; + } + return errorBuilder_; + } + + private com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.Builder, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResultOrBuilder> + resultBuilder_; + /** + * + * + *
+     * Output only. The translation result that is currently being processed (is_final could be
+     * true or false).
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the result field is set. + */ + public boolean hasResult() { + return resultBuilder_ != null || result_ != null; + } + /** + * + * + *
+     * Output only. The translation result that is currently being processed (is_final could be
+     * true or false).
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The result. + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult getResult() { + if (resultBuilder_ == null) { + return result_ == null + ? com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .getDefaultInstance() + : result_; + } else { + return resultBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Output only. The translation result that is currently being processed (is_final could be
+     * true or false).
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setResult( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult value) { + if (resultBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + result_ = value; + onChanged(); + } else { + resultBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * Output only. The translation result that is currently being processed (is_final could be
+     * true or false).
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setResult( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.Builder + builderForValue) { + if (resultBuilder_ == null) { + result_ = builderForValue.build(); + onChanged(); + } else { + resultBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * Output only. The translation result that is currently being processed (is_final could be
+     * true or false).
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeResult( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult value) { + if (resultBuilder_ == null) { + if (result_ != null) { + result_ = + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.newBuilder( + result_) + .mergeFrom(value) + .buildPartial(); + } else { + result_ = value; + } + onChanged(); + } else { + resultBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * Output only. The translation result that is currently being processed (is_final could be
+     * true or false).
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearResult() { + if (resultBuilder_ == null) { + result_ = null; + onChanged(); + } else { + result_ = null; + resultBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * Output only. The translation result that is currently being processed (is_final could be
+     * true or false).
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.Builder + getResultBuilder() { + + onChanged(); + return getResultFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Output only. The translation result that is currently being processed (is_final could be
+     * true or false).
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResultOrBuilder + getResultOrBuilder() { + if (resultBuilder_ != null) { + return resultBuilder_.getMessageOrBuilder(); + } else { + return result_ == null + ? com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .getDefaultInstance() + : result_; + } + } + /** + * + * + *
+     * Output only. The translation result that is currently being processed (is_final could be
+     * true or false).
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.Builder, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResultOrBuilder> + getResultFieldBuilder() { + if (resultBuilder_ == null) { + resultBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.Builder, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResultOrBuilder>( + getResult(), getParentForChildren(), isClean()); + result_ = null; + } + return resultBuilder_; + } + + private int speechEventType_ = 0; + /** + * + * + *
+     * Output only. Indicates the type of speech event.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType speech_event_type = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for speechEventType. + */ + public int getSpeechEventTypeValue() { + return speechEventType_; + } + /** + * + * + *
+     * Output only. Indicates the type of speech event.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType speech_event_type = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The enum numeric value on the wire for speechEventType to set. + * @return This builder for chaining. + */ + public Builder setSpeechEventTypeValue(int value) { + speechEventType_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Indicates the type of speech event.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType speech_event_type = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The speechEventType. + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + .SpeechEventType + getSpeechEventType() { + @SuppressWarnings("deprecation") + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType + result = + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + .SpeechEventType.valueOf(speechEventType_); + return result == null + ? com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + .SpeechEventType.UNRECOGNIZED + : result; + } + /** + * + * + *
+     * Output only. Indicates the type of speech event.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType speech_event_type = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The speechEventType to set. + * @return This builder for chaining. + */ + public Builder setSpeechEventType( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType + value) { + if (value == null) { + throw new NullPointerException(); + } + + speechEventType_ = value.getNumber(); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Indicates the type of speech event.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType speech_event_type = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return This builder for chaining. + */ + public Builder clearSpeechEventType() { + + speechEventType_ = 0; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse) + } + + // @@protoc_insertion_point(class_scope:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse) + private static final com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse(); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public StreamingTranslateSpeechResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new StreamingTranslateSpeechResponse(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechResponseOrBuilder.java b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechResponseOrBuilder.java new file mode 100644 index 00000000..a4f2f873 --- /dev/null +++ b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechResponseOrBuilder.java @@ -0,0 +1,138 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/mediatranslation/v1beta1/media_translation.proto + +package com.google.cloud.mediatranslation.v1beta1; + +public interface StreamingTranslateSpeechResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that
+   * specifies the error for the operation.
+   * 
+ * + * .google.rpc.Status error = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return Whether the error field is set. + */ + boolean hasError(); + /** + * + * + *
+   * Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that
+   * specifies the error for the operation.
+   * 
+ * + * .google.rpc.Status error = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The error. + */ + com.google.rpc.Status getError(); + /** + * + * + *
+   * Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that
+   * specifies the error for the operation.
+   * 
+ * + * .google.rpc.Status error = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + com.google.rpc.StatusOrBuilder getErrorOrBuilder(); + + /** + * + * + *
+   * Output only. The translation result that is currently being processed (is_final could be
+   * true or false).
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the result field is set. + */ + boolean hasResult(); + /** + * + * + *
+   * Output only. The translation result that is currently being processed (is_final could be
+   * true or false).
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The result. + */ + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult getResult(); + /** + * + * + *
+   * Output only. The translation result that is currently being processed (is_final could be
+   * true or false).
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResultOrBuilder + getResultOrBuilder(); + + /** + * + * + *
+   * Output only. Indicates the type of speech event.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType speech_event_type = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for speechEventType. + */ + int getSpeechEventTypeValue(); + /** + * + * + *
+   * Output only. Indicates the type of speech event.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType speech_event_type = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The speechEventType. + */ + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse.SpeechEventType + getSpeechEventType(); +} diff --git a/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechResult.java b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechResult.java new file mode 100644 index 00000000..2b4ff2c8 --- /dev/null +++ b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechResult.java @@ -0,0 +1,2221 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/mediatranslation/v1beta1/media_translation.proto + +package com.google.cloud.mediatranslation.v1beta1; + +/** + * + * + *
+ * A streaming speech translation result corresponding to a portion of the audio
+ * that is currently being processed.
+ * 
+ * + * Protobuf type {@code google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult} + */ +public final class StreamingTranslateSpeechResult extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult) + StreamingTranslateSpeechResultOrBuilder { + private static final long serialVersionUID = 0L; + // Use StreamingTranslateSpeechResult.newBuilder() to construct. + private StreamingTranslateSpeechResult( + com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private StreamingTranslateSpeechResult() { + recognitionResult_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new StreamingTranslateSpeechResult(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private StreamingTranslateSpeechResult( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.Builder + subBuilder = null; + if (resultCase_ == 1) { + subBuilder = + ((com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult) + result_) + .toBuilder(); + } + result_ = + input.readMessage( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.parser(), + extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom( + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult) + result_); + result_ = subBuilder.buildPartial(); + } + resultCase_ = 1; + break; + } + case 26: + { + java.lang.String s = input.readStringRequireUtf8(); + + recognitionResult_ = s; + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.class, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.Builder.class); + } + + public interface TextTranslationResultOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Output only. The translated sentence.
+     * 
+ * + * string translation = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The translation. + */ + java.lang.String getTranslation(); + /** + * + * + *
+     * Output only. The translated sentence.
+     * 
+ * + * string translation = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for translation. + */ + com.google.protobuf.ByteString getTranslationBytes(); + + /** + * + * + *
+     * Output only. If `false`, this `StreamingTranslateSpeechResult` represents
+     * an interim result that may change. If `true`, this is the final time the
+     * translation service will return this particular
+     * `StreamingTranslateSpeechResult`, the streaming translator will not
+     * return any further hypotheses for this portion of the transcript and
+     * corresponding audio.
+     * 
+ * + * bool is_final = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The isFinal. + */ + boolean getIsFinal(); + + /** + * + * + *
+     * Output only. The source language code (BCP-47) detected in the audio. Speech
+     * translation result will translate in the most likely language detected
+     * including the alternative source languages and main source_language_code.
+     * 
+ * + * string detected_source_language_code = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The detectedSourceLanguageCode. + */ + java.lang.String getDetectedSourceLanguageCode(); + /** + * + * + *
+     * Output only. The source language code (BCP-47) detected in the audio. Speech
+     * translation result will translate in the most likely language detected
+     * including the alternative source languages and main source_language_code.
+     * 
+ * + * string detected_source_language_code = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The bytes for detectedSourceLanguageCode. + */ + com.google.protobuf.ByteString getDetectedSourceLanguageCodeBytes(); + } + /** + * + * + *
+   * Text translation result.
+   * 
+ * + * Protobuf type {@code + * google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult} + */ + public static final class TextTranslationResult extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult) + TextTranslationResultOrBuilder { + private static final long serialVersionUID = 0L; + // Use TextTranslationResult.newBuilder() to construct. + private TextTranslationResult(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private TextTranslationResult() { + translation_ = ""; + detectedSourceLanguageCode_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new TextTranslationResult(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private TextTranslationResult( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + translation_ = s; + break; + } + case 16: + { + isFinal_ = input.readBool(); + break; + } + case 26: + { + java.lang.String s = input.readStringRequireUtf8(); + + detectedSourceLanguageCode_ = s; + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_TextTranslationResult_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_TextTranslationResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.class, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.Builder.class); + } + + public static final int TRANSLATION_FIELD_NUMBER = 1; + private volatile java.lang.Object translation_; + /** + * + * + *
+     * Output only. The translated sentence.
+     * 
+ * + * string translation = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The translation. + */ + public java.lang.String getTranslation() { + java.lang.Object ref = translation_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + translation_ = s; + return s; + } + } + /** + * + * + *
+     * Output only. The translated sentence.
+     * 
+ * + * string translation = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for translation. + */ + public com.google.protobuf.ByteString getTranslationBytes() { + java.lang.Object ref = translation_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + translation_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int IS_FINAL_FIELD_NUMBER = 2; + private boolean isFinal_; + /** + * + * + *
+     * Output only. If `false`, this `StreamingTranslateSpeechResult` represents
+     * an interim result that may change. If `true`, this is the final time the
+     * translation service will return this particular
+     * `StreamingTranslateSpeechResult`, the streaming translator will not
+     * return any further hypotheses for this portion of the transcript and
+     * corresponding audio.
+     * 
+ * + * bool is_final = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The isFinal. + */ + public boolean getIsFinal() { + return isFinal_; + } + + public static final int DETECTED_SOURCE_LANGUAGE_CODE_FIELD_NUMBER = 3; + private volatile java.lang.Object detectedSourceLanguageCode_; + /** + * + * + *
+     * Output only. The source language code (BCP-47) detected in the audio. Speech
+     * translation result will translate in the most likely language detected
+     * including the alternative source languages and main source_language_code.
+     * 
+ * + * string detected_source_language_code = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The detectedSourceLanguageCode. + */ + public java.lang.String getDetectedSourceLanguageCode() { + java.lang.Object ref = detectedSourceLanguageCode_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + detectedSourceLanguageCode_ = s; + return s; + } + } + /** + * + * + *
+     * Output only. The source language code (BCP-47) detected in the audio. Speech
+     * translation result will translate in the most likely language detected
+     * including the alternative source languages and main source_language_code.
+     * 
+ * + * string detected_source_language_code = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The bytes for detectedSourceLanguageCode. + */ + public com.google.protobuf.ByteString getDetectedSourceLanguageCodeBytes() { + java.lang.Object ref = detectedSourceLanguageCode_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + detectedSourceLanguageCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!getTranslationBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, translation_); + } + if (isFinal_ != false) { + output.writeBool(2, isFinal_); + } + if (!getDetectedSourceLanguageCodeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, detectedSourceLanguageCode_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getTranslationBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, translation_); + } + if (isFinal_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(2, isFinal_); + } + if (!getDetectedSourceLanguageCodeBytes().isEmpty()) { + size += + com.google.protobuf.GeneratedMessageV3.computeStringSize( + 3, detectedSourceLanguageCode_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj + instanceof + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult)) { + return super.equals(obj); + } + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult + other = + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult) + obj; + + if (!getTranslation().equals(other.getTranslation())) return false; + if (getIsFinal() != other.getIsFinal()) return false; + if (!getDetectedSourceLanguageCode().equals(other.getDetectedSourceLanguageCode())) + return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TRANSLATION_FIELD_NUMBER; + hash = (53 * hash) + getTranslation().hashCode(); + hash = (37 * hash) + IS_FINAL_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getIsFinal()); + hash = (37 * hash) + DETECTED_SOURCE_LANGUAGE_CODE_FIELD_NUMBER; + hash = (53 * hash) + getDetectedSourceLanguageCode().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + parseFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+     * Text translation result.
+     * 
+ * + * Protobuf type {@code + * google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult) + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResultOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_TextTranslationResult_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_TextTranslationResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.class, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.Builder.class); + } + + // Construct using + // com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + translation_ = ""; + + isFinal_ = false; + + detectedSourceLanguageCode_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_TextTranslationResult_descriptor; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + getDefaultInstanceForType() { + return com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + build() { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + buildPartial() { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + result = + new com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult(this); + result.translation_ = translation_; + result.isFinal_ = isFinal_; + result.detectedSourceLanguageCode_ = detectedSourceLanguageCode_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other + instanceof + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult) { + return mergeFrom( + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult) + other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + other) { + if (other + == com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.getDefaultInstance()) return this; + if (!other.getTranslation().isEmpty()) { + translation_ = other.translation_; + onChanged(); + } + if (other.getIsFinal() != false) { + setIsFinal(other.getIsFinal()); + } + if (!other.getDetectedSourceLanguageCode().isEmpty()) { + detectedSourceLanguageCode_ = other.detectedSourceLanguageCode_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult) + e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object translation_ = ""; + /** + * + * + *
+       * Output only. The translated sentence.
+       * 
+ * + * string translation = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The translation. + */ + public java.lang.String getTranslation() { + java.lang.Object ref = translation_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + translation_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+       * Output only. The translated sentence.
+       * 
+ * + * string translation = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for translation. + */ + public com.google.protobuf.ByteString getTranslationBytes() { + java.lang.Object ref = translation_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + translation_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+       * Output only. The translated sentence.
+       * 
+ * + * string translation = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The translation to set. + * @return This builder for chaining. + */ + public Builder setTranslation(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + translation_ = value; + onChanged(); + return this; + } + /** + * + * + *
+       * Output only. The translated sentence.
+       * 
+ * + * string translation = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearTranslation() { + + translation_ = getDefaultInstance().getTranslation(); + onChanged(); + return this; + } + /** + * + * + *
+       * Output only. The translated sentence.
+       * 
+ * + * string translation = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for translation to set. + * @return This builder for chaining. + */ + public Builder setTranslationBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + translation_ = value; + onChanged(); + return this; + } + + private boolean isFinal_; + /** + * + * + *
+       * Output only. If `false`, this `StreamingTranslateSpeechResult` represents
+       * an interim result that may change. If `true`, this is the final time the
+       * translation service will return this particular
+       * `StreamingTranslateSpeechResult`, the streaming translator will not
+       * return any further hypotheses for this portion of the transcript and
+       * corresponding audio.
+       * 
+ * + * bool is_final = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The isFinal. + */ + public boolean getIsFinal() { + return isFinal_; + } + /** + * + * + *
+       * Output only. If `false`, this `StreamingTranslateSpeechResult` represents
+       * an interim result that may change. If `true`, this is the final time the
+       * translation service will return this particular
+       * `StreamingTranslateSpeechResult`, the streaming translator will not
+       * return any further hypotheses for this portion of the transcript and
+       * corresponding audio.
+       * 
+ * + * bool is_final = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The isFinal to set. + * @return This builder for chaining. + */ + public Builder setIsFinal(boolean value) { + + isFinal_ = value; + onChanged(); + return this; + } + /** + * + * + *
+       * Output only. If `false`, this `StreamingTranslateSpeechResult` represents
+       * an interim result that may change. If `true`, this is the final time the
+       * translation service will return this particular
+       * `StreamingTranslateSpeechResult`, the streaming translator will not
+       * return any further hypotheses for this portion of the transcript and
+       * corresponding audio.
+       * 
+ * + * bool is_final = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearIsFinal() { + + isFinal_ = false; + onChanged(); + return this; + } + + private java.lang.Object detectedSourceLanguageCode_ = ""; + /** + * + * + *
+       * Output only. The source language code (BCP-47) detected in the audio. Speech
+       * translation result will translate in the most likely language detected
+       * including the alternative source languages and main source_language_code.
+       * 
+ * + * + * string detected_source_language_code = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The detectedSourceLanguageCode. + */ + public java.lang.String getDetectedSourceLanguageCode() { + java.lang.Object ref = detectedSourceLanguageCode_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + detectedSourceLanguageCode_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+       * Output only. The source language code (BCP-47) detected in the audio. Speech
+       * translation result will translate in the most likely language detected
+       * including the alternative source languages and main source_language_code.
+       * 
+ * + * + * string detected_source_language_code = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The bytes for detectedSourceLanguageCode. + */ + public com.google.protobuf.ByteString getDetectedSourceLanguageCodeBytes() { + java.lang.Object ref = detectedSourceLanguageCode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + detectedSourceLanguageCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+       * Output only. The source language code (BCP-47) detected in the audio. Speech
+       * translation result will translate in the most likely language detected
+       * including the alternative source languages and main source_language_code.
+       * 
+ * + * + * string detected_source_language_code = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The detectedSourceLanguageCode to set. + * @return This builder for chaining. + */ + public Builder setDetectedSourceLanguageCode(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + detectedSourceLanguageCode_ = value; + onChanged(); + return this; + } + /** + * + * + *
+       * Output only. The source language code (BCP-47) detected in the audio. Speech
+       * translation result will translate in the most likely language detected
+       * including the alternative source languages and main source_language_code.
+       * 
+ * + * + * string detected_source_language_code = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return This builder for chaining. + */ + public Builder clearDetectedSourceLanguageCode() { + + detectedSourceLanguageCode_ = getDefaultInstance().getDetectedSourceLanguageCode(); + onChanged(); + return this; + } + /** + * + * + *
+       * Output only. The source language code (BCP-47) detected in the audio. Speech
+       * translation result will translate in the most likely language detected
+       * including the alternative source languages and main source_language_code.
+       * 
+ * + * + * string detected_source_language_code = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The bytes for detectedSourceLanguageCode to set. + * @return This builder for chaining. + */ + public Builder setDetectedSourceLanguageCodeBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + detectedSourceLanguageCode_ = value; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult) + } + + // @@protoc_insertion_point(class_scope:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult) + private static final com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult(); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TextTranslationResult parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TextTranslationResult(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int resultCase_ = 0; + private java.lang.Object result_; + + public enum ResultCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + TEXT_TRANSLATION_RESULT(1), + RESULT_NOT_SET(0); + private final int value; + + private ResultCase(int value) { + this.value = value; + } + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ResultCase valueOf(int value) { + return forNumber(value); + } + + public static ResultCase forNumber(int value) { + switch (value) { + case 1: + return TEXT_TRANSLATION_RESULT; + case 0: + return RESULT_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ResultCase getResultCase() { + return ResultCase.forNumber(resultCase_); + } + + public static final int TEXT_TRANSLATION_RESULT_FIELD_NUMBER = 1; + /** + * + * + *
+   * Text translation result.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult text_translation_result = 1; + * + * + * @return Whether the textTranslationResult field is set. + */ + public boolean hasTextTranslationResult() { + return resultCase_ == 1; + } + /** + * + * + *
+   * Text translation result.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult text_translation_result = 1; + * + * + * @return The textTranslationResult. + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + getTextTranslationResult() { + if (resultCase_ == 1) { + return (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult) + result_; + } + return com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.getDefaultInstance(); + } + /** + * + * + *
+   * Text translation result.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult text_translation_result = 1; + * + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResultOrBuilder + getTextTranslationResultOrBuilder() { + if (resultCase_ == 1) { + return (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult) + result_; + } + return com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.getDefaultInstance(); + } + + public static final int RECOGNITION_RESULT_FIELD_NUMBER = 3; + private volatile java.lang.Object recognitionResult_; + /** + * + * + *
+   * Output only. The debug only recognition result in original language. This field is debug
+   * only and will be set to empty string if not available.
+   * This is implementation detail and will not be backward compatible.
+   * Still need to decide whether to expose this field by default.
+   * 
+ * + * string recognition_result = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The recognitionResult. + */ + public java.lang.String getRecognitionResult() { + java.lang.Object ref = recognitionResult_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + recognitionResult_ = s; + return s; + } + } + /** + * + * + *
+   * Output only. The debug only recognition result in original language. This field is debug
+   * only and will be set to empty string if not available.
+   * This is implementation detail and will not be backward compatible.
+   * Still need to decide whether to expose this field by default.
+   * 
+ * + * string recognition_result = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for recognitionResult. + */ + public com.google.protobuf.ByteString getRecognitionResultBytes() { + java.lang.Object ref = recognitionResult_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + recognitionResult_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (resultCase_ == 1) { + output.writeMessage( + 1, + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult) + result_); + } + if (!getRecognitionResultBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, recognitionResult_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (resultCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 1, + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult) + result_); + } + if (!getRecognitionResultBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, recognitionResult_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj + instanceof com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult)) { + return super.equals(obj); + } + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult other = + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult) obj; + + if (!getRecognitionResult().equals(other.getRecognitionResult())) return false; + if (!getResultCase().equals(other.getResultCase())) return false; + switch (resultCase_) { + case 1: + if (!getTextTranslationResult().equals(other.getTextTranslationResult())) return false; + break; + case 0: + default: + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + RECOGNITION_RESULT_FIELD_NUMBER; + hash = (53 * hash) + getRecognitionResult().hashCode(); + switch (resultCase_) { + case 1: + hash = (37 * hash) + TEXT_TRANSLATION_RESULT_FIELD_NUMBER; + hash = (53 * hash) + getTextTranslationResult().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * A streaming speech translation result corresponding to a portion of the audio
+   * that is currently being processed.
+   * 
+ * + * Protobuf type {@code google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult) + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResultOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.class, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.Builder + .class); + } + + // Construct using + // com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + recognitionResult_ = ""; + + resultCase_ = 0; + result_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_StreamingTranslateSpeechResult_descriptor; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + getDefaultInstanceForType() { + return com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult build() { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult buildPartial() { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult result = + new com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult(this); + if (resultCase_ == 1) { + if (textTranslationResultBuilder_ == null) { + result.result_ = result_; + } else { + result.result_ = textTranslationResultBuilder_.build(); + } + } + result.recognitionResult_ = recognitionResult_; + result.resultCase_ = resultCase_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other + instanceof com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult) { + return mergeFrom( + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult other) { + if (other + == com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .getDefaultInstance()) return this; + if (!other.getRecognitionResult().isEmpty()) { + recognitionResult_ = other.recognitionResult_; + onChanged(); + } + switch (other.getResultCase()) { + case TEXT_TRANSLATION_RESULT: + { + mergeTextTranslationResult(other.getTextTranslationResult()); + break; + } + case RESULT_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult) + e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int resultCase_ = 0; + private java.lang.Object result_; + + public ResultCase getResultCase() { + return ResultCase.forNumber(resultCase_); + } + + public Builder clearResult() { + resultCase_ = 0; + result_ = null; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.Builder, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResultOrBuilder> + textTranslationResultBuilder_; + /** + * + * + *
+     * Text translation result.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult text_translation_result = 1; + * + * + * @return Whether the textTranslationResult field is set. + */ + public boolean hasTextTranslationResult() { + return resultCase_ == 1; + } + /** + * + * + *
+     * Text translation result.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult text_translation_result = 1; + * + * + * @return The textTranslationResult. + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + getTextTranslationResult() { + if (textTranslationResultBuilder_ == null) { + if (resultCase_ == 1) { + return (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult) + result_; + } + return com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.getDefaultInstance(); + } else { + if (resultCase_ == 1) { + return textTranslationResultBuilder_.getMessage(); + } + return com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.getDefaultInstance(); + } + } + /** + * + * + *
+     * Text translation result.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult text_translation_result = 1; + * + */ + public Builder setTextTranslationResult( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + value) { + if (textTranslationResultBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + result_ = value; + onChanged(); + } else { + textTranslationResultBuilder_.setMessage(value); + } + resultCase_ = 1; + return this; + } + /** + * + * + *
+     * Text translation result.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult text_translation_result = 1; + * + */ + public Builder setTextTranslationResult( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.Builder + builderForValue) { + if (textTranslationResultBuilder_ == null) { + result_ = builderForValue.build(); + onChanged(); + } else { + textTranslationResultBuilder_.setMessage(builderForValue.build()); + } + resultCase_ = 1; + return this; + } + /** + * + * + *
+     * Text translation result.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult text_translation_result = 1; + * + */ + public Builder mergeTextTranslationResult( + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult + value) { + if (textTranslationResultBuilder_ == null) { + if (resultCase_ == 1 + && result_ + != com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.getDefaultInstance()) { + result_ = + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.newBuilder( + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult) + result_) + .mergeFrom(value) + .buildPartial(); + } else { + result_ = value; + } + onChanged(); + } else { + if (resultCase_ == 1) { + textTranslationResultBuilder_.mergeFrom(value); + } + textTranslationResultBuilder_.setMessage(value); + } + resultCase_ = 1; + return this; + } + /** + * + * + *
+     * Text translation result.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult text_translation_result = 1; + * + */ + public Builder clearTextTranslationResult() { + if (textTranslationResultBuilder_ == null) { + if (resultCase_ == 1) { + resultCase_ = 0; + result_ = null; + onChanged(); + } + } else { + if (resultCase_ == 1) { + resultCase_ = 0; + result_ = null; + } + textTranslationResultBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Text translation result.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult text_translation_result = 1; + * + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.Builder + getTextTranslationResultBuilder() { + return getTextTranslationResultFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Text translation result.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult text_translation_result = 1; + * + */ + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResultOrBuilder + getTextTranslationResultOrBuilder() { + if ((resultCase_ == 1) && (textTranslationResultBuilder_ != null)) { + return textTranslationResultBuilder_.getMessageOrBuilder(); + } else { + if (resultCase_ == 1) { + return (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult) + result_; + } + return com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.getDefaultInstance(); + } + } + /** + * + * + *
+     * Text translation result.
+     * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult text_translation_result = 1; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.Builder, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResultOrBuilder> + getTextTranslationResultFieldBuilder() { + if (textTranslationResultBuilder_ == null) { + if (!(resultCase_ == 1)) { + result_ = + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.getDefaultInstance(); + } + textTranslationResultBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult.Builder, + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResultOrBuilder>( + (com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResult) + result_, + getParentForChildren(), + isClean()); + result_ = null; + } + resultCase_ = 1; + onChanged(); + ; + return textTranslationResultBuilder_; + } + + private java.lang.Object recognitionResult_ = ""; + /** + * + * + *
+     * Output only. The debug only recognition result in original language. This field is debug
+     * only and will be set to empty string if not available.
+     * This is implementation detail and will not be backward compatible.
+     * Still need to decide whether to expose this field by default.
+     * 
+ * + * string recognition_result = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The recognitionResult. + */ + public java.lang.String getRecognitionResult() { + java.lang.Object ref = recognitionResult_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + recognitionResult_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Output only. The debug only recognition result in original language. This field is debug
+     * only and will be set to empty string if not available.
+     * This is implementation detail and will not be backward compatible.
+     * Still need to decide whether to expose this field by default.
+     * 
+ * + * string recognition_result = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for recognitionResult. + */ + public com.google.protobuf.ByteString getRecognitionResultBytes() { + java.lang.Object ref = recognitionResult_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + recognitionResult_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Output only. The debug only recognition result in original language. This field is debug
+     * only and will be set to empty string if not available.
+     * This is implementation detail and will not be backward compatible.
+     * Still need to decide whether to expose this field by default.
+     * 
+ * + * string recognition_result = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The recognitionResult to set. + * @return This builder for chaining. + */ + public Builder setRecognitionResult(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + recognitionResult_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The debug only recognition result in original language. This field is debug
+     * only and will be set to empty string if not available.
+     * This is implementation detail and will not be backward compatible.
+     * Still need to decide whether to expose this field by default.
+     * 
+ * + * string recognition_result = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearRecognitionResult() { + + recognitionResult_ = getDefaultInstance().getRecognitionResult(); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The debug only recognition result in original language. This field is debug
+     * only and will be set to empty string if not available.
+     * This is implementation detail and will not be backward compatible.
+     * Still need to decide whether to expose this field by default.
+     * 
+ * + * string recognition_result = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for recognitionResult to set. + * @return This builder for chaining. + */ + public Builder setRecognitionResultBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + recognitionResult_ = value; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult) + } + + // @@protoc_insertion_point(class_scope:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult) + private static final com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult(); + } + + public static com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public StreamingTranslateSpeechResult parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new StreamingTranslateSpeechResult(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechResultOrBuilder.java b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechResultOrBuilder.java new file mode 100644 index 00000000..4805e77c --- /dev/null +++ b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/StreamingTranslateSpeechResultOrBuilder.java @@ -0,0 +1,103 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/mediatranslation/v1beta1/media_translation.proto + +package com.google.cloud.mediatranslation.v1beta1; + +public interface StreamingTranslateSpeechResultOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Text translation result.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult text_translation_result = 1; + * + * + * @return Whether the textTranslationResult field is set. + */ + boolean hasTextTranslationResult(); + /** + * + * + *
+   * Text translation result.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult text_translation_result = 1; + * + * + * @return The textTranslationResult. + */ + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult + getTextTranslationResult(); + /** + * + * + *
+   * Text translation result.
+   * 
+ * + * + * .google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.TextTranslationResult text_translation_result = 1; + * + */ + com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult + .TextTranslationResultOrBuilder + getTextTranslationResultOrBuilder(); + + /** + * + * + *
+   * Output only. The debug only recognition result in original language. This field is debug
+   * only and will be set to empty string if not available.
+   * This is implementation detail and will not be backward compatible.
+   * Still need to decide whether to expose this field by default.
+   * 
+ * + * string recognition_result = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The recognitionResult. + */ + java.lang.String getRecognitionResult(); + /** + * + * + *
+   * Output only. The debug only recognition result in original language. This field is debug
+   * only and will be set to empty string if not available.
+   * This is implementation detail and will not be backward compatible.
+   * Still need to decide whether to expose this field by default.
+   * 
+ * + * string recognition_result = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for recognitionResult. + */ + com.google.protobuf.ByteString getRecognitionResultBytes(); + + public com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResult.ResultCase + getResultCase(); +} diff --git a/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/TranslateSpeechConfig.java b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/TranslateSpeechConfig.java new file mode 100644 index 00000000..d96decc2 --- /dev/null +++ b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/TranslateSpeechConfig.java @@ -0,0 +1,1676 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/mediatranslation/v1beta1/media_translation.proto + +package com.google.cloud.mediatranslation.v1beta1; + +/** + * + * + *
+ * Provides information to the speech translation that specifies how to process
+ * the request.
+ * 
+ * + * Protobuf type {@code google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig} + */ +public final class TranslateSpeechConfig extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig) + TranslateSpeechConfigOrBuilder { + private static final long serialVersionUID = 0L; + // Use TranslateSpeechConfig.newBuilder() to construct. + private TranslateSpeechConfig(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private TranslateSpeechConfig() { + audioEncoding_ = ""; + sourceLanguageCode_ = ""; + alternativeSourceLanguageCodes_ = com.google.protobuf.LazyStringArrayList.EMPTY; + targetLanguageCode_ = ""; + model_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new TranslateSpeechConfig(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private TranslateSpeechConfig( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + audioEncoding_ = s; + break; + } + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + + sourceLanguageCode_ = s; + break; + } + case 26: + { + java.lang.String s = input.readStringRequireUtf8(); + + targetLanguageCode_ = s; + break; + } + case 32: + { + sampleRateHertz_ = input.readInt32(); + break; + } + case 42: + { + java.lang.String s = input.readStringRequireUtf8(); + + model_ = s; + break; + } + case 50: + { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + alternativeSourceLanguageCodes_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + alternativeSourceLanguageCodes_.add(s); + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + alternativeSourceLanguageCodes_ = alternativeSourceLanguageCodes_.getUnmodifiableView(); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_TranslateSpeechConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_TranslateSpeechConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.class, + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.Builder.class); + } + + public static final int AUDIO_ENCODING_FIELD_NUMBER = 1; + private volatile java.lang.Object audioEncoding_; + /** + * + * + *
+   * Required. Encoding of audio data.
+   * Supported formats:
+   * - `linear16`
+   *   Uncompressed 16-bit signed little-endian samples (Linear PCM).
+   * 
+ * + * string audio_encoding = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The audioEncoding. + */ + public java.lang.String getAudioEncoding() { + java.lang.Object ref = audioEncoding_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + audioEncoding_ = s; + return s; + } + } + /** + * + * + *
+   * Required. Encoding of audio data.
+   * Supported formats:
+   * - `linear16`
+   *   Uncompressed 16-bit signed little-endian samples (Linear PCM).
+   * 
+ * + * string audio_encoding = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for audioEncoding. + */ + public com.google.protobuf.ByteString getAudioEncodingBytes() { + java.lang.Object ref = audioEncoding_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + audioEncoding_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SOURCE_LANGUAGE_CODE_FIELD_NUMBER = 2; + private volatile java.lang.Object sourceLanguageCode_; + /** + * + * + *
+   * Required. Source language code (BCP-47) of the input audio.
+   * 
+ * + * string source_language_code = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The sourceLanguageCode. + */ + public java.lang.String getSourceLanguageCode() { + java.lang.Object ref = sourceLanguageCode_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + sourceLanguageCode_ = s; + return s; + } + } + /** + * + * + *
+   * Required. Source language code (BCP-47) of the input audio.
+   * 
+ * + * string source_language_code = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for sourceLanguageCode. + */ + public com.google.protobuf.ByteString getSourceLanguageCodeBytes() { + java.lang.Object ref = sourceLanguageCode_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + sourceLanguageCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ALTERNATIVE_SOURCE_LANGUAGE_CODES_FIELD_NUMBER = 6; + private com.google.protobuf.LazyStringList alternativeSourceLanguageCodes_; + /** + * + * + *
+   * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+   * alternative languages of the supplied audio. If alternative source
+   * languages are listed, speech translation result will translate in the most
+   * likely language detected including the main source_language_code. The
+   * translated result will include the language code of the language detected
+   * in the audio.
+   * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return A list containing the alternativeSourceLanguageCodes. + */ + public com.google.protobuf.ProtocolStringList getAlternativeSourceLanguageCodesList() { + return alternativeSourceLanguageCodes_; + } + /** + * + * + *
+   * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+   * alternative languages of the supplied audio. If alternative source
+   * languages are listed, speech translation result will translate in the most
+   * likely language detected including the main source_language_code. The
+   * translated result will include the language code of the language detected
+   * in the audio.
+   * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The count of alternativeSourceLanguageCodes. + */ + public int getAlternativeSourceLanguageCodesCount() { + return alternativeSourceLanguageCodes_.size(); + } + /** + * + * + *
+   * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+   * alternative languages of the supplied audio. If alternative source
+   * languages are listed, speech translation result will translate in the most
+   * likely language detected including the main source_language_code. The
+   * translated result will include the language code of the language detected
+   * in the audio.
+   * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @param index The index of the element to return. + * @return The alternativeSourceLanguageCodes at the given index. + */ + public java.lang.String getAlternativeSourceLanguageCodes(int index) { + return alternativeSourceLanguageCodes_.get(index); + } + /** + * + * + *
+   * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+   * alternative languages of the supplied audio. If alternative source
+   * languages are listed, speech translation result will translate in the most
+   * likely language detected including the main source_language_code. The
+   * translated result will include the language code of the language detected
+   * in the audio.
+   * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @param index The index of the value to return. + * @return The bytes of the alternativeSourceLanguageCodes at the given index. + */ + public com.google.protobuf.ByteString getAlternativeSourceLanguageCodesBytes(int index) { + return alternativeSourceLanguageCodes_.getByteString(index); + } + + public static final int TARGET_LANGUAGE_CODE_FIELD_NUMBER = 3; + private volatile java.lang.Object targetLanguageCode_; + /** + * + * + *
+   * Required. Target language code (BCP-47) of the output.
+   * 
+ * + * string target_language_code = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The targetLanguageCode. + */ + public java.lang.String getTargetLanguageCode() { + java.lang.Object ref = targetLanguageCode_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + targetLanguageCode_ = s; + return s; + } + } + /** + * + * + *
+   * Required. Target language code (BCP-47) of the output.
+   * 
+ * + * string target_language_code = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for targetLanguageCode. + */ + public com.google.protobuf.ByteString getTargetLanguageCodeBytes() { + java.lang.Object ref = targetLanguageCode_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + targetLanguageCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SAMPLE_RATE_HERTZ_FIELD_NUMBER = 4; + private int sampleRateHertz_; + /** + * + * + *
+   * Optional. Sample rate in Hertz of the audio data. Valid values are:
+   * 8000-48000. 16000 is optimal. For best results, set the sampling rate of
+   * the audio source to 16000 Hz. If that's not possible, use the native sample
+   * rate of the audio source (instead of re-sampling). This field can only be
+   * omitted for `FLAC` and `WAV` audio files.
+   * 
+ * + * int32 sample_rate_hertz = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The sampleRateHertz. + */ + public int getSampleRateHertz() { + return sampleRateHertz_; + } + + public static final int MODEL_FIELD_NUMBER = 5; + private volatile java.lang.Object model_; + /** + * + * + *
+   * Optional.
+   * 
+ * + * string model = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The model. + */ + public java.lang.String getModel() { + java.lang.Object ref = model_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + model_ = s; + return s; + } + } + /** + * + * + *
+   * Optional.
+   * 
+ * + * string model = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for model. + */ + public com.google.protobuf.ByteString getModelBytes() { + java.lang.Object ref = model_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + model_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!getAudioEncodingBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, audioEncoding_); + } + if (!getSourceLanguageCodeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, sourceLanguageCode_); + } + if (!getTargetLanguageCodeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, targetLanguageCode_); + } + if (sampleRateHertz_ != 0) { + output.writeInt32(4, sampleRateHertz_); + } + if (!getModelBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, model_); + } + for (int i = 0; i < alternativeSourceLanguageCodes_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString( + output, 6, alternativeSourceLanguageCodes_.getRaw(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getAudioEncodingBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, audioEncoding_); + } + if (!getSourceLanguageCodeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, sourceLanguageCode_); + } + if (!getTargetLanguageCodeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, targetLanguageCode_); + } + if (sampleRateHertz_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(4, sampleRateHertz_); + } + if (!getModelBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, model_); + } + { + int dataSize = 0; + for (int i = 0; i < alternativeSourceLanguageCodes_.size(); i++) { + dataSize += computeStringSizeNoTag(alternativeSourceLanguageCodes_.getRaw(i)); + } + size += dataSize; + size += 1 * getAlternativeSourceLanguageCodesList().size(); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig)) { + return super.equals(obj); + } + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig other = + (com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig) obj; + + if (!getAudioEncoding().equals(other.getAudioEncoding())) return false; + if (!getSourceLanguageCode().equals(other.getSourceLanguageCode())) return false; + if (!getAlternativeSourceLanguageCodesList() + .equals(other.getAlternativeSourceLanguageCodesList())) return false; + if (!getTargetLanguageCode().equals(other.getTargetLanguageCode())) return false; + if (getSampleRateHertz() != other.getSampleRateHertz()) return false; + if (!getModel().equals(other.getModel())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + AUDIO_ENCODING_FIELD_NUMBER; + hash = (53 * hash) + getAudioEncoding().hashCode(); + hash = (37 * hash) + SOURCE_LANGUAGE_CODE_FIELD_NUMBER; + hash = (53 * hash) + getSourceLanguageCode().hashCode(); + if (getAlternativeSourceLanguageCodesCount() > 0) { + hash = (37 * hash) + ALTERNATIVE_SOURCE_LANGUAGE_CODES_FIELD_NUMBER; + hash = (53 * hash) + getAlternativeSourceLanguageCodesList().hashCode(); + } + hash = (37 * hash) + TARGET_LANGUAGE_CODE_FIELD_NUMBER; + hash = (53 * hash) + getTargetLanguageCode().hashCode(); + hash = (37 * hash) + SAMPLE_RATE_HERTZ_FIELD_NUMBER; + hash = (53 * hash) + getSampleRateHertz(); + hash = (37 * hash) + MODEL_FIELD_NUMBER; + hash = (53 * hash) + getModel().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Provides information to the speech translation that specifies how to process
+   * the request.
+   * 
+ * + * Protobuf type {@code google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig) + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfigOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_TranslateSpeechConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_TranslateSpeechConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.class, + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.Builder.class); + } + + // Construct using com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + audioEncoding_ = ""; + + sourceLanguageCode_ = ""; + + alternativeSourceLanguageCodes_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + targetLanguageCode_ = ""; + + sampleRateHertz_ = 0; + + model_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.mediatranslation.v1beta1.MediaTranslationProto + .internal_static_google_cloud_mediatranslation_v1beta1_TranslateSpeechConfig_descriptor; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig + getDefaultInstanceForType() { + return com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig build() { + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig buildPartial() { + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig result = + new com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig(this); + int from_bitField0_ = bitField0_; + result.audioEncoding_ = audioEncoding_; + result.sourceLanguageCode_ = sourceLanguageCode_; + if (((bitField0_ & 0x00000001) != 0)) { + alternativeSourceLanguageCodes_ = alternativeSourceLanguageCodes_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.alternativeSourceLanguageCodes_ = alternativeSourceLanguageCodes_; + result.targetLanguageCode_ = targetLanguageCode_; + result.sampleRateHertz_ = sampleRateHertz_; + result.model_ = model_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig) { + return mergeFrom((com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig other) { + if (other + == com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig.getDefaultInstance()) + return this; + if (!other.getAudioEncoding().isEmpty()) { + audioEncoding_ = other.audioEncoding_; + onChanged(); + } + if (!other.getSourceLanguageCode().isEmpty()) { + sourceLanguageCode_ = other.sourceLanguageCode_; + onChanged(); + } + if (!other.alternativeSourceLanguageCodes_.isEmpty()) { + if (alternativeSourceLanguageCodes_.isEmpty()) { + alternativeSourceLanguageCodes_ = other.alternativeSourceLanguageCodes_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureAlternativeSourceLanguageCodesIsMutable(); + alternativeSourceLanguageCodes_.addAll(other.alternativeSourceLanguageCodes_); + } + onChanged(); + } + if (!other.getTargetLanguageCode().isEmpty()) { + targetLanguageCode_ = other.targetLanguageCode_; + onChanged(); + } + if (other.getSampleRateHertz() != 0) { + setSampleRateHertz(other.getSampleRateHertz()); + } + if (!other.getModel().isEmpty()) { + model_ = other.model_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig) + e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private java.lang.Object audioEncoding_ = ""; + /** + * + * + *
+     * Required. Encoding of audio data.
+     * Supported formats:
+     * - `linear16`
+     *   Uncompressed 16-bit signed little-endian samples (Linear PCM).
+     * 
+ * + * string audio_encoding = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The audioEncoding. + */ + public java.lang.String getAudioEncoding() { + java.lang.Object ref = audioEncoding_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + audioEncoding_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. Encoding of audio data.
+     * Supported formats:
+     * - `linear16`
+     *   Uncompressed 16-bit signed little-endian samples (Linear PCM).
+     * 
+ * + * string audio_encoding = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for audioEncoding. + */ + public com.google.protobuf.ByteString getAudioEncodingBytes() { + java.lang.Object ref = audioEncoding_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + audioEncoding_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. Encoding of audio data.
+     * Supported formats:
+     * - `linear16`
+     *   Uncompressed 16-bit signed little-endian samples (Linear PCM).
+     * 
+ * + * string audio_encoding = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The audioEncoding to set. + * @return This builder for chaining. + */ + public Builder setAudioEncoding(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + audioEncoding_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Encoding of audio data.
+     * Supported formats:
+     * - `linear16`
+     *   Uncompressed 16-bit signed little-endian samples (Linear PCM).
+     * 
+ * + * string audio_encoding = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearAudioEncoding() { + + audioEncoding_ = getDefaultInstance().getAudioEncoding(); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Encoding of audio data.
+     * Supported formats:
+     * - `linear16`
+     *   Uncompressed 16-bit signed little-endian samples (Linear PCM).
+     * 
+ * + * string audio_encoding = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for audioEncoding to set. + * @return This builder for chaining. + */ + public Builder setAudioEncodingBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + audioEncoding_ = value; + onChanged(); + return this; + } + + private java.lang.Object sourceLanguageCode_ = ""; + /** + * + * + *
+     * Required. Source language code (BCP-47) of the input audio.
+     * 
+ * + * string source_language_code = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The sourceLanguageCode. + */ + public java.lang.String getSourceLanguageCode() { + java.lang.Object ref = sourceLanguageCode_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + sourceLanguageCode_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. Source language code (BCP-47) of the input audio.
+     * 
+ * + * string source_language_code = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for sourceLanguageCode. + */ + public com.google.protobuf.ByteString getSourceLanguageCodeBytes() { + java.lang.Object ref = sourceLanguageCode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + sourceLanguageCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. Source language code (BCP-47) of the input audio.
+     * 
+ * + * string source_language_code = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The sourceLanguageCode to set. + * @return This builder for chaining. + */ + public Builder setSourceLanguageCode(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + sourceLanguageCode_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Source language code (BCP-47) of the input audio.
+     * 
+ * + * string source_language_code = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearSourceLanguageCode() { + + sourceLanguageCode_ = getDefaultInstance().getSourceLanguageCode(); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Source language code (BCP-47) of the input audio.
+     * 
+ * + * string source_language_code = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for sourceLanguageCode to set. + * @return This builder for chaining. + */ + public Builder setSourceLanguageCodeBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + sourceLanguageCode_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringList alternativeSourceLanguageCodes_ = + com.google.protobuf.LazyStringArrayList.EMPTY; + + private void ensureAlternativeSourceLanguageCodesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + alternativeSourceLanguageCodes_ = + new com.google.protobuf.LazyStringArrayList(alternativeSourceLanguageCodes_); + bitField0_ |= 0x00000001; + } + } + /** + * + * + *
+     * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+     * alternative languages of the supplied audio. If alternative source
+     * languages are listed, speech translation result will translate in the most
+     * likely language detected including the main source_language_code. The
+     * translated result will include the language code of the language detected
+     * in the audio.
+     * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return A list containing the alternativeSourceLanguageCodes. + */ + public com.google.protobuf.ProtocolStringList getAlternativeSourceLanguageCodesList() { + return alternativeSourceLanguageCodes_.getUnmodifiableView(); + } + /** + * + * + *
+     * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+     * alternative languages of the supplied audio. If alternative source
+     * languages are listed, speech translation result will translate in the most
+     * likely language detected including the main source_language_code. The
+     * translated result will include the language code of the language detected
+     * in the audio.
+     * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The count of alternativeSourceLanguageCodes. + */ + public int getAlternativeSourceLanguageCodesCount() { + return alternativeSourceLanguageCodes_.size(); + } + /** + * + * + *
+     * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+     * alternative languages of the supplied audio. If alternative source
+     * languages are listed, speech translation result will translate in the most
+     * likely language detected including the main source_language_code. The
+     * translated result will include the language code of the language detected
+     * in the audio.
+     * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @param index The index of the element to return. + * @return The alternativeSourceLanguageCodes at the given index. + */ + public java.lang.String getAlternativeSourceLanguageCodes(int index) { + return alternativeSourceLanguageCodes_.get(index); + } + /** + * + * + *
+     * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+     * alternative languages of the supplied audio. If alternative source
+     * languages are listed, speech translation result will translate in the most
+     * likely language detected including the main source_language_code. The
+     * translated result will include the language code of the language detected
+     * in the audio.
+     * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @param index The index of the value to return. + * @return The bytes of the alternativeSourceLanguageCodes at the given index. + */ + public com.google.protobuf.ByteString getAlternativeSourceLanguageCodesBytes(int index) { + return alternativeSourceLanguageCodes_.getByteString(index); + } + /** + * + * + *
+     * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+     * alternative languages of the supplied audio. If alternative source
+     * languages are listed, speech translation result will translate in the most
+     * likely language detected including the main source_language_code. The
+     * translated result will include the language code of the language detected
+     * in the audio.
+     * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @param index The index to set the value at. + * @param value The alternativeSourceLanguageCodes to set. + * @return This builder for chaining. + */ + public Builder setAlternativeSourceLanguageCodes(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureAlternativeSourceLanguageCodesIsMutable(); + alternativeSourceLanguageCodes_.set(index, value); + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+     * alternative languages of the supplied audio. If alternative source
+     * languages are listed, speech translation result will translate in the most
+     * likely language detected including the main source_language_code. The
+     * translated result will include the language code of the language detected
+     * in the audio.
+     * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @param value The alternativeSourceLanguageCodes to add. + * @return This builder for chaining. + */ + public Builder addAlternativeSourceLanguageCodes(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureAlternativeSourceLanguageCodesIsMutable(); + alternativeSourceLanguageCodes_.add(value); + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+     * alternative languages of the supplied audio. If alternative source
+     * languages are listed, speech translation result will translate in the most
+     * likely language detected including the main source_language_code. The
+     * translated result will include the language code of the language detected
+     * in the audio.
+     * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @param values The alternativeSourceLanguageCodes to add. + * @return This builder for chaining. + */ + public Builder addAllAlternativeSourceLanguageCodes( + java.lang.Iterable values) { + ensureAlternativeSourceLanguageCodesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, alternativeSourceLanguageCodes_); + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+     * alternative languages of the supplied audio. If alternative source
+     * languages are listed, speech translation result will translate in the most
+     * likely language detected including the main source_language_code. The
+     * translated result will include the language code of the language detected
+     * in the audio.
+     * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return This builder for chaining. + */ + public Builder clearAlternativeSourceLanguageCodes() { + alternativeSourceLanguageCodes_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+     * alternative languages of the supplied audio. If alternative source
+     * languages are listed, speech translation result will translate in the most
+     * likely language detected including the main source_language_code. The
+     * translated result will include the language code of the language detected
+     * in the audio.
+     * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @param value The bytes of the alternativeSourceLanguageCodes to add. + * @return This builder for chaining. + */ + public Builder addAlternativeSourceLanguageCodesBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureAlternativeSourceLanguageCodesIsMutable(); + alternativeSourceLanguageCodes_.add(value); + onChanged(); + return this; + } + + private java.lang.Object targetLanguageCode_ = ""; + /** + * + * + *
+     * Required. Target language code (BCP-47) of the output.
+     * 
+ * + * string target_language_code = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The targetLanguageCode. + */ + public java.lang.String getTargetLanguageCode() { + java.lang.Object ref = targetLanguageCode_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + targetLanguageCode_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. Target language code (BCP-47) of the output.
+     * 
+ * + * string target_language_code = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for targetLanguageCode. + */ + public com.google.protobuf.ByteString getTargetLanguageCodeBytes() { + java.lang.Object ref = targetLanguageCode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + targetLanguageCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. Target language code (BCP-47) of the output.
+     * 
+ * + * string target_language_code = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The targetLanguageCode to set. + * @return This builder for chaining. + */ + public Builder setTargetLanguageCode(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + targetLanguageCode_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Target language code (BCP-47) of the output.
+     * 
+ * + * string target_language_code = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearTargetLanguageCode() { + + targetLanguageCode_ = getDefaultInstance().getTargetLanguageCode(); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Target language code (BCP-47) of the output.
+     * 
+ * + * string target_language_code = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for targetLanguageCode to set. + * @return This builder for chaining. + */ + public Builder setTargetLanguageCodeBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + targetLanguageCode_ = value; + onChanged(); + return this; + } + + private int sampleRateHertz_; + /** + * + * + *
+     * Optional. Sample rate in Hertz of the audio data. Valid values are:
+     * 8000-48000. 16000 is optimal. For best results, set the sampling rate of
+     * the audio source to 16000 Hz. If that's not possible, use the native sample
+     * rate of the audio source (instead of re-sampling). This field can only be
+     * omitted for `FLAC` and `WAV` audio files.
+     * 
+ * + * int32 sample_rate_hertz = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The sampleRateHertz. + */ + public int getSampleRateHertz() { + return sampleRateHertz_; + } + /** + * + * + *
+     * Optional. Sample rate in Hertz of the audio data. Valid values are:
+     * 8000-48000. 16000 is optimal. For best results, set the sampling rate of
+     * the audio source to 16000 Hz. If that's not possible, use the native sample
+     * rate of the audio source (instead of re-sampling). This field can only be
+     * omitted for `FLAC` and `WAV` audio files.
+     * 
+ * + * int32 sample_rate_hertz = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The sampleRateHertz to set. + * @return This builder for chaining. + */ + public Builder setSampleRateHertz(int value) { + + sampleRateHertz_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. Sample rate in Hertz of the audio data. Valid values are:
+     * 8000-48000. 16000 is optimal. For best results, set the sampling rate of
+     * the audio source to 16000 Hz. If that's not possible, use the native sample
+     * rate of the audio source (instead of re-sampling). This field can only be
+     * omitted for `FLAC` and `WAV` audio files.
+     * 
+ * + * int32 sample_rate_hertz = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearSampleRateHertz() { + + sampleRateHertz_ = 0; + onChanged(); + return this; + } + + private java.lang.Object model_ = ""; + /** + * + * + *
+     * Optional.
+     * 
+ * + * string model = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The model. + */ + public java.lang.String getModel() { + java.lang.Object ref = model_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + model_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Optional.
+     * 
+ * + * string model = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for model. + */ + public com.google.protobuf.ByteString getModelBytes() { + java.lang.Object ref = model_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + model_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Optional.
+     * 
+ * + * string model = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The model to set. + * @return This builder for chaining. + */ + public Builder setModel(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + model_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional.
+     * 
+ * + * string model = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearModel() { + + model_ = getDefaultInstance().getModel(); + onChanged(); + return this; + } + /** + * + * + *
+     * Optional.
+     * 
+ * + * string model = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The bytes for model to set. + * @return This builder for chaining. + */ + public Builder setModelBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + model_ = value; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig) + } + + // @@protoc_insertion_point(class_scope:google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig) + private static final com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig(); + } + + public static com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TranslateSpeechConfig parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TranslateSpeechConfig(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/TranslateSpeechConfigOrBuilder.java b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/TranslateSpeechConfigOrBuilder.java new file mode 100644 index 00000000..0fbd2283 --- /dev/null +++ b/proto-google-cloud-mediatranslation-v1beta1/src/main/java/com/google/cloud/mediatranslation/v1beta1/TranslateSpeechConfigOrBuilder.java @@ -0,0 +1,227 @@ +/* + * Copyright 2020 Google LLC + * + * 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 + * + * https://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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/mediatranslation/v1beta1/media_translation.proto + +package com.google.cloud.mediatranslation.v1beta1; + +public interface TranslateSpeechConfigOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.mediatranslation.v1beta1.TranslateSpeechConfig) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. Encoding of audio data.
+   * Supported formats:
+   * - `linear16`
+   *   Uncompressed 16-bit signed little-endian samples (Linear PCM).
+   * 
+ * + * string audio_encoding = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The audioEncoding. + */ + java.lang.String getAudioEncoding(); + /** + * + * + *
+   * Required. Encoding of audio data.
+   * Supported formats:
+   * - `linear16`
+   *   Uncompressed 16-bit signed little-endian samples (Linear PCM).
+   * 
+ * + * string audio_encoding = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for audioEncoding. + */ + com.google.protobuf.ByteString getAudioEncodingBytes(); + + /** + * + * + *
+   * Required. Source language code (BCP-47) of the input audio.
+   * 
+ * + * string source_language_code = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The sourceLanguageCode. + */ + java.lang.String getSourceLanguageCode(); + /** + * + * + *
+   * Required. Source language code (BCP-47) of the input audio.
+   * 
+ * + * string source_language_code = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for sourceLanguageCode. + */ + com.google.protobuf.ByteString getSourceLanguageCodeBytes(); + + /** + * + * + *
+   * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+   * alternative languages of the supplied audio. If alternative source
+   * languages are listed, speech translation result will translate in the most
+   * likely language detected including the main source_language_code. The
+   * translated result will include the language code of the language detected
+   * in the audio.
+   * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return A list containing the alternativeSourceLanguageCodes. + */ + java.util.List getAlternativeSourceLanguageCodesList(); + /** + * + * + *
+   * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+   * alternative languages of the supplied audio. If alternative source
+   * languages are listed, speech translation result will translate in the most
+   * likely language detected including the main source_language_code. The
+   * translated result will include the language code of the language detected
+   * in the audio.
+   * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The count of alternativeSourceLanguageCodes. + */ + int getAlternativeSourceLanguageCodesCount(); + /** + * + * + *
+   * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+   * alternative languages of the supplied audio. If alternative source
+   * languages are listed, speech translation result will translate in the most
+   * likely language detected including the main source_language_code. The
+   * translated result will include the language code of the language detected
+   * in the audio.
+   * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @param index The index of the element to return. + * @return The alternativeSourceLanguageCodes at the given index. + */ + java.lang.String getAlternativeSourceLanguageCodes(int index); + /** + * + * + *
+   * Optional. A list of up to 3 additional language codes (BCP-47), listing possible
+   * alternative languages of the supplied audio. If alternative source
+   * languages are listed, speech translation result will translate in the most
+   * likely language detected including the main source_language_code. The
+   * translated result will include the language code of the language detected
+   * in the audio.
+   * 
+ * + * + * repeated string alternative_source_language_codes = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @param index The index of the value to return. + * @return The bytes of the alternativeSourceLanguageCodes at the given index. + */ + com.google.protobuf.ByteString getAlternativeSourceLanguageCodesBytes(int index); + + /** + * + * + *
+   * Required. Target language code (BCP-47) of the output.
+   * 
+ * + * string target_language_code = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The targetLanguageCode. + */ + java.lang.String getTargetLanguageCode(); + /** + * + * + *
+   * Required. Target language code (BCP-47) of the output.
+   * 
+ * + * string target_language_code = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for targetLanguageCode. + */ + com.google.protobuf.ByteString getTargetLanguageCodeBytes(); + + /** + * + * + *
+   * Optional. Sample rate in Hertz of the audio data. Valid values are:
+   * 8000-48000. 16000 is optimal. For best results, set the sampling rate of
+   * the audio source to 16000 Hz. If that's not possible, use the native sample
+   * rate of the audio source (instead of re-sampling). This field can only be
+   * omitted for `FLAC` and `WAV` audio files.
+   * 
+ * + * int32 sample_rate_hertz = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The sampleRateHertz. + */ + int getSampleRateHertz(); + + /** + * + * + *
+   * Optional.
+   * 
+ * + * string model = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The model. + */ + java.lang.String getModel(); + /** + * + * + *
+   * Optional.
+   * 
+ * + * string model = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for model. + */ + com.google.protobuf.ByteString getModelBytes(); +} diff --git a/proto-google-cloud-mediatranslation-v1beta1/src/main/proto/google/cloud/mediatranslation/v1beta1/media_translation.proto b/proto-google-cloud-mediatranslation-v1beta1/src/main/proto/google/cloud/mediatranslation/v1beta1/media_translation.proto new file mode 100644 index 00000000..88eed82a --- /dev/null +++ b/proto-google-cloud-mediatranslation-v1beta1/src/main/proto/google/cloud/mediatranslation/v1beta1/media_translation.proto @@ -0,0 +1,197 @@ +// Copyright 2020 Google LLC +// +// 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.mediatranslation.v1beta1; + +import "google/api/field_behavior.proto"; +import "google/rpc/status.proto"; +import "google/api/client.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/mediatranslation/v1beta1;mediatranslation"; +option java_multiple_files = true; +option java_outer_classname = "MediaTranslationProto"; +option java_package = "com.google.cloud.mediatranslation.v1beta1"; +option csharp_namespace = "Google.Cloud.MediaTranslation.V1Beta1"; +option ruby_package = "Google::Cloud::MediaTranslation::V1beta1"; +option php_namespace = "Google\\Cloud\\MediaTranslation\\V1beta1"; + +// Provides translation from/to media types. +service SpeechTranslationService { + option (google.api.default_host) = "mediatranslation.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Performs bidirectional streaming speech translation: receive results while + // sending audio. This method is only available via the gRPC API (not REST). + rpc StreamingTranslateSpeech(stream StreamingTranslateSpeechRequest) returns (stream StreamingTranslateSpeechResponse) { + } +} + +// Provides information to the speech translation that specifies how to process +// the request. +message TranslateSpeechConfig { + // Required. Encoding of audio data. + // Supported formats: + // + // - `linear16` + // + // Uncompressed 16-bit signed little-endian samples (Linear PCM). + // + // + string audio_encoding = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Source language code (BCP-47) of the input audio. + string source_language_code = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. A list of up to 3 additional language codes (BCP-47), listing possible + // alternative languages of the supplied audio. If alternative source + // languages are listed, speech translation result will translate in the most + // likely language detected including the main source_language_code. The + // translated result will include the language code of the language detected + // in the audio. + repeated string alternative_source_language_codes = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Required. Target language code (BCP-47) of the output. + string target_language_code = 3 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Sample rate in Hertz of the audio data. Valid values are: + // 8000-48000. 16000 is optimal. For best results, set the sampling rate of + // the audio source to 16000 Hz. If that's not possible, use the native sample + // rate of the audio source (instead of re-sampling). This field can only be + // omitted for `FLAC` and `WAV` audio files. + int32 sample_rate_hertz = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. + string model = 5 [(google.api.field_behavior) = OPTIONAL]; +} + +// Config used for streaming translation. +message StreamingTranslateSpeechConfig { + // Required. The common config for all the following audio contents. + TranslateSpeechConfig audio_config = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. If `false` or omitted, the system performs + // continuous translation (continuing to wait for and process audio even if + // the user pauses speaking) until the client closes the input stream (gRPC + // API) or until the maximum time limit has been reached. May return multiple + // `StreamingTranslateSpeechResult`s with the `is_final` flag set to `true`. + // + // If `true`, the speech translator will detect a single spoken utterance. + // When it detects that the user has paused or stopped speaking, it will + // return an `END_OF_SINGLE_UTTERANCE` event and cease translation. + // When the client receives 'END_OF_SINGLE_UTTERANCE' event, the client should + // stop sending the requests. However, clients should keep receiving remaining + // responses until the stream is terminated. To construct the complete + // sentence in a streaming way, one should override (if 'is_final' of previous + // response is false), or append (if 'is_final' of previous response is true). + bool single_utterance = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// The top-level message sent by the client for the `StreamingTranslateSpeech` +// method. Multiple `StreamingTranslateSpeechRequest` messages are sent. The +// first message must contain a `streaming_config` message and must not contain +// `audio_content` data. All subsequent messages must contain `audio_content` +// data and must not contain a `streaming_config` message. +message StreamingTranslateSpeechRequest { + // The streaming request, which is either a streaming config or content. + oneof streaming_request { + // Provides information to the recognizer that specifies how to process the + // request. The first `StreamingTranslateSpeechRequest` message must contain + // a `streaming_config` message. + StreamingTranslateSpeechConfig streaming_config = 1; + + // The audio data to be translated. Sequential chunks of audio data are sent + // in sequential `StreamingTranslateSpeechRequest` messages. The first + // `StreamingTranslateSpeechRequest` message must not contain + // `audio_content` data and all subsequent `StreamingTranslateSpeechRequest` + // messages must contain `audio_content` data. The audio bytes must be + // encoded as specified in `StreamingTranslateSpeechConfig`. Note: as with + // all bytes fields, protobuffers use a pure binary representation (not + // base64). + bytes audio_content = 2; + } +} + +// A streaming speech translation result corresponding to a portion of the audio +// that is currently being processed. +message StreamingTranslateSpeechResult { + // Text translation result. + message TextTranslationResult { + // Output only. The translated sentence. + string translation = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If `false`, this `StreamingTranslateSpeechResult` represents + // an interim result that may change. If `true`, this is the final time the + // translation service will return this particular + // `StreamingTranslateSpeechResult`, the streaming translator will not + // return any further hypotheses for this portion of the transcript and + // corresponding audio. + bool is_final = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The source language code (BCP-47) detected in the audio. Speech + // translation result will translate in the most likely language detected + // including the alternative source languages and main source_language_code. + string detected_source_language_code = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + } + + // Translation result. + // + // Use oneof field to reserve for future tts result. + oneof result { + // Text translation result. + TextTranslationResult text_translation_result = 1; + } + + // Output only. The debug only recognition result in original language. This field is debug + // only and will be set to empty string if not available. + // This is implementation detail and will not be backward compatible. + // + // Still need to decide whether to expose this field by default. + string recognition_result = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A streaming speech translation response corresponding to a portion of +// the audio currently processed. +message StreamingTranslateSpeechResponse { + // Indicates the type of speech event. + enum SpeechEventType { + // No speech event specified. + SPEECH_EVENT_TYPE_UNSPECIFIED = 0; + + // This event 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 (although it may subsequently return + // additional results). When the client receives 'END_OF_SINGLE_UTTERANCE' + // event, the client should stop sending the requests. However, clients + // should keep receiving remaining responses until the stream is terminated. + // To construct the complete sentence in a streaming way, one should + // override (if 'is_final' of previous response is false), or append (if + // 'is_final' of previous response is true). This event is only sent if + // `single_utterance` was set to `true`, and is not used otherwise. + END_OF_SINGLE_UTTERANCE = 1; + } + + // Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that + // specifies the error for the operation. + google.rpc.Status error = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The translation result that is currently being processed (is_final could be + // true or false). + StreamingTranslateSpeechResult result = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Indicates the type of speech event. + SpeechEventType speech_event_type = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/renovate.json b/renovate.json new file mode 100644 index 00000000..fc641270 --- /dev/null +++ b/renovate.json @@ -0,0 +1,78 @@ +{ + "extends": [ + ":separateMajorReleases", + ":combinePatchMinorReleases", + ":ignoreUnstable", + ":prImmediately", + ":updateNotScheduled", + ":automergeDisabled", + ":ignoreModulesAndTests", + ":maintainLockFilesDisabled", + ":autodetectPinVersions" + ], + "packageRules": [ + { + "packagePatterns": [ + "^com.google.guava:" + ], + "versionScheme": "docker" + }, + { + "packagePatterns": [ + "^com.google.api:gax", + "^com.google.auth:", + "^com.google.cloud:google-cloud-core", + "^io.grpc:", + "^com.google.guava:" + ], + "groupName": "core dependencies" + }, + { + "packagePatterns": [ + "^com.google.http-client:", + "^com.google.oauth-client:", + "^com.google.api-client:" + ], + "groupName": "core transport dependencies" + }, + { + "packagePatterns": [ + "*" + ], + "semanticCommitType": "deps", + "semanticCommitScope": null + }, + { + "packagePatterns": [ + "^org.apache.maven", + "^org.jacoco:", + "^org.codehaus.mojo:", + "^org.sonatype.plugins:", + "^com.coveo:", + "^com.google.cloud:google-cloud-shared-config" + ], + "semanticCommitType": "build", + "semanticCommitScope": "deps" + }, + { + "packagePatterns": [ + "^com.google.cloud:libraries-bom" + ], + "semanticCommitType": "chore", + "semanticCommitScope": "deps" + }, + { + "packagePatterns": [ + "^com.google.cloud:google-cloud-" + ], + "ignoreUnstable": false + }, + { + "packagePatterns": [ + "^com.fasterxml.jackson.core" + ], + "groupName": "jackson dependencies" + } + ], + "semanticCommits": true +} diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml new file mode 100644 index 00000000..73725b0e --- /dev/null +++ b/samples/install-without-bom/pom.xml @@ -0,0 +1,84 @@ + + + 4.0.0 + com.google.cloud + mediatranslation-install-without-bom + jar + Google Media Translation API Install Without Bom + https://github.com/googleapis/java-mediatranslation + + + + com.google.cloud.samples + shared-configuration + 1.0.12 + + + + 1.8 + 1.8 + UTF-8 + + + + + + + com.google.cloud + google-cloud-mediatranslation + 0.0.0 + + + + + junit + junit + 4.13 + test + + + com.google.truth + truth + 1.0.1 + test + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.1.0 + + + add-snippets-source + + add-source + + + + ../snippets/src/main/java + + + + + add-snippets-tests + + add-test-source + + + + ../snippets/src/test/java + + + + + + + + diff --git a/samples/pom.xml b/samples/pom.xml new file mode 100644 index 00000000..05141fc5 --- /dev/null +++ b/samples/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + com.google.cloud + google-cloud-mediatranslation-samples + 0.0.1-SNAPSHOT + pom + Google Media Translation API Samples Parent + https://github.com/googleapis/java-mediatranslation + + Java idiomatic client for Google Cloud Platform services. + + + + + com.google.cloud.samples + shared-configuration + 1.0.12 + + + + 1.8 + 1.8 + UTF-8 + + + + install-without-bom + snapshot + snippets + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.8.2 + + true + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + + true + + + + + diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml new file mode 100644 index 00000000..c5141a4d --- /dev/null +++ b/samples/snapshot/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + com.google.cloud + mediatranslation-snapshot + jar + Google Media Translation API Snapshot Samples + https://github.com/googleapis/java-mediatranslation + + + + com.google.cloud.samples + shared-configuration + 1.0.12 + + + + 1.8 + 1.8 + UTF-8 + + + + + + com.google.cloud + google-cloud-mediatranslation + 0.0.0 + + + + junit + junit + 4.13 + test + + + com.google.truth + truth + 1.0.1 + test + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.1.0 + + + add-snippets-source + + add-source + + + + ../snippets/src/main/java + + + + + add-snippets-tests + + add-test-source + + + + ../snippets/src/test/java + + + + + + + + \ No newline at end of file diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml new file mode 100644 index 00000000..48ac74d9 --- /dev/null +++ b/samples/snippets/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + com.google.cloud + mediatranslation-snippets + jar + Google Media Translation API Snippets + https://github.com/googleapis/java-mediatranslation + + + + com.google.cloud.samples + shared-configuration + 1.0.12 + + + + 1.8 + 1.8 + UTF-8 + + + + + + + + com.google.cloud + libraries-bom + 4.2.0 + pom + import + + + + + + + com.google.cloud + google-cloud-mediatranslation + + + + + junit + junit + 4.13 + test + + + com.google.truth + truth + 1.0.1 + test + + + diff --git a/synth.metadata b/synth.metadata new file mode 100644 index 00000000..f3de6189 --- /dev/null +++ b/synth.metadata @@ -0,0 +1,31 @@ +{ + "updateTime": "2020-03-18T14:36:40.309106Z", + "sources": [ + { + "git": { + "name": "googleapis", + "remote": "https://github.com/googleapis/googleapis.git", + "sha": "e7b10591c5408a67cf14ffafa267556f3290e262", + "internalRef": "301585144" + } + }, + { + "template": { + "name": "java_library", + "origin": "synthtool.gcp", + "version": "2020.2.4" + } + } + ], + "destinations": [ + { + "client": { + "source": "googleapis", + "apiName": "mediatranslation", + "apiVersion": "v1beta1", + "language": "java", + "generator": "bazel" + } + } + ] +} \ No newline at end of file diff --git a/synth.py b/synth.py new file mode 100644 index 00000000..9b2b5733 --- /dev/null +++ b/synth.py @@ -0,0 +1,33 @@ +# Copyright 2020 Google LLC +# +# 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. + +"""This script is used to synthesize generated parts of this library.""" + +import synthtool as s +import synthtool.gcp as gcp +import synthtool.languages.java as java + +service = 'mediatranslation' +versions = ['v1beta1'] + +for version in versions: + java.bazel_library( + service=service, + version=version, + package_pattern='com.google.cloud.{service}.{version}', + proto_path=f'google/cloud/{service}/{version}', + bazel_target=f'//google/cloud/{service}/{version}:google-cloud-{service}-{version}-java', + ) + +java.common_templates() \ No newline at end of file diff --git a/versions.txt b/versions.txt new file mode 100644 index 00000000..eef78fd5 --- /dev/null +++ b/versions.txt @@ -0,0 +1,6 @@ +# Format: +# module:released-version:current-version + +google-cloud-mediatranslation:0.0.0:0.0.1-SNAPSHOT +proto-google-cloud-mediatranslation-v1beta1:0.0.0:0.0.1-SNAPSHOT +grpc-google-cloud-mediatranslation-v1beta1:0.0.0:0.0.1-SNAPSHOT \ No newline at end of file