From dcd171d04bda5b67db13049320f97eca3ace3731 Mon Sep 17 00:00:00 2001 From: Google APIs Date: Mon, 16 Mar 2020 09:59:09 -0700 Subject: [PATCH] Publish Media Translation API V1Beta1 PiperOrigin-RevId: 301180096 --- .../mediatranslation/v1beta1/BUILD.bazel | 357 ++++++++++++++++++ .../v1beta1/media_translation.proto | 197 ++++++++++ .../v1beta1/mediatranslation_gapic.yaml | 18 + .../mediatranslation_grpc_service_config.json | 19 + .../v1beta1/mediatranslation_v1beta1.yaml | 19 + 5 files changed, 610 insertions(+) create mode 100644 google/cloud/mediatranslation/v1beta1/BUILD.bazel create mode 100644 google/cloud/mediatranslation/v1beta1/media_translation.proto create mode 100644 google/cloud/mediatranslation/v1beta1/mediatranslation_gapic.yaml create mode 100644 google/cloud/mediatranslation/v1beta1/mediatranslation_grpc_service_config.json create mode 100644 google/cloud/mediatranslation/v1beta1/mediatranslation_v1beta1.yaml diff --git a/google/cloud/mediatranslation/v1beta1/BUILD.bazel b/google/cloud/mediatranslation/v1beta1/BUILD.bazel new file mode 100644 index 00000000..85afb90a --- /dev/null +++ b/google/cloud/mediatranslation/v1beta1/BUILD.bazel @@ -0,0 +1,357 @@ +# This file was automatically generated by BuildFileGenerator + +# This is an API workspace, having public visibility by default makes perfect sense. +package(default_visibility = ["//visibility:public"]) + +############################################################################## +# Common +############################################################################## +load("@rules_proto//proto:defs.bzl", "proto_library") +load("@com_google_googleapis_imports//:imports.bzl", "proto_library_with_info") + +proto_library( + name = "mediatranslation_proto", + srcs = [ + "media_translation.proto", + ], + deps = [ + "//google/api:client_proto", + "//google/api:field_behavior_proto", + "//google/rpc:status_proto", + ], +) + +proto_library_with_info( + name = "mediatranslation_proto_with_info", + deps = [ + ":mediatranslation_proto", + "//google/cloud:common_resources_proto", + ], +) + +############################################################################## +# Java +############################################################################## +load( + "@com_google_googleapis_imports//:imports.bzl", + "java_gapic_assembly_gradle_pkg", + "java_gapic_library", + "java_gapic_test", + "java_grpc_library", + "java_proto_library", +) + +java_proto_library( + name = "mediatranslation_java_proto", + deps = [":mediatranslation_proto"], +) + +java_grpc_library( + name = "mediatranslation_java_grpc", + srcs = [":mediatranslation_proto"], + deps = [":mediatranslation_java_proto"], +) + +java_gapic_library( + name = "mediatranslation_java_gapic", + src = ":mediatranslation_proto_with_info", + gapic_yaml = "mediatranslation_gapic.yaml", + package = "google.cloud.mediatranslation.v1beta1", + service_yaml = "mediatranslation_v1beta1.yaml", + test_deps = [ + ":mediatranslation_java_grpc", + ], + deps = [ + ":mediatranslation_java_proto", + ], +) + +java_gapic_test( + name = "mediatranslation_java_gapic_test_suite", + test_classes = [ + "com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceClientTest", + ], + runtime_deps = [":mediatranslation_java_gapic_test"], +) + +# Open Source Packages +java_gapic_assembly_gradle_pkg( + name = "google-cloud-mediatranslation-v1beta1-java", + deps = [ + ":mediatranslation_java_gapic", + ":mediatranslation_java_grpc", + ":mediatranslation_java_proto", + ":mediatranslation_proto", + ], +) + +############################################################################## +# Go +############################################################################## +load( + "@com_google_googleapis_imports//:imports.bzl", + "go_gapic_assembly_pkg", + "go_gapic_library", + "go_proto_library", + "go_test", +) + +go_proto_library( + name = "mediatranslation_go_proto", + compilers = ["@io_bazel_rules_go//proto:go_grpc"], + importpath = "google.golang.org/genproto/googleapis/cloud/mediatranslation/v1beta1", + protos = [":mediatranslation_proto"], + deps = [ + "//google/api:annotations_go_proto", + "//google/rpc:status_go_proto", + ], +) + +go_gapic_library( + name = "mediatranslation_go_gapic", + src = ":mediatranslation_proto_with_info", + gapic_yaml = "mediatranslation_gapic.yaml", + importpath = "cloud.google.com/go/mediatranslation/apiv1beta1", + package = "google.cloud.mediatranslation.v1beta1", + service_yaml = "mediatranslation_v1beta1.yaml", + deps = [ + ":mediatranslation_go_proto", + ], +) + +go_test( + name = "mediatranslation_go_gapic_test", + srcs = [":mediatranslation_go_gapic_srcjar_test"], + embed = [":mediatranslation_go_gapic"], + importpath = "cloud.google.com/go/mediatranslation/apiv1beta1", +) + +# Open Source Packages +go_gapic_assembly_pkg( + name = "gapi-cloud-mediatranslation-v1beta1-go", + deps = [ + ":mediatranslation_go_gapic", + ":mediatranslation_go_gapic_srcjar-smoke-test.srcjar", + ":mediatranslation_go_gapic_srcjar-test.srcjar", + ":mediatranslation_go_proto", + ], +) + +############################################################################## +# Python +############################################################################## +load( + "@com_google_googleapis_imports//:imports.bzl", + "moved_proto_library", + "py_gapic_assembly_pkg", + "py_gapic_library", + "py_grpc_library", + "py_proto_library", +) + +moved_proto_library( + name = "mediatranslation_moved_proto", + srcs = [":mediatranslation_proto"], + deps = [ + "//google/api:client_proto", + "//google/api:field_behavior_proto", + "//google/rpc:status_proto", + ], +) + +py_proto_library( + name = "mediatranslation_py_proto", + plugin = "@protoc_docs_plugin//:docs_plugin", + deps = [":mediatranslation_moved_proto"], +) + +py_grpc_library( + name = "mediatranslation_py_grpc", + srcs = [":mediatranslation_moved_proto"], + deps = [":mediatranslation_py_proto"], +) + +py_gapic_library( + name = "mediatranslation_py_gapic", + src = ":mediatranslation_proto_with_info", + gapic_yaml = "mediatranslation_gapic.yaml", + package = "google.cloud.mediatranslation.v1beta1", + service_yaml = "mediatranslation_v1beta1.yaml", + deps = [ + ":mediatranslation_py_grpc", + ":mediatranslation_py_proto", + ], +) + +# Open Source Packages +py_gapic_assembly_pkg( + name = "mediatranslation-v1beta1-py", + deps = [ + ":mediatranslation_py_gapic", + ":mediatranslation_py_grpc", + ":mediatranslation_py_proto", + ], +) + +############################################################################## +# PHP +############################################################################## +load( + "@com_google_googleapis_imports//:imports.bzl", + "php_gapic_assembly_pkg", + "php_gapic_library", + "php_grpc_library", + "php_proto_library", +) + +php_proto_library( + name = "mediatranslation_php_proto", + deps = [":mediatranslation_proto"], +) + +php_grpc_library( + name = "mediatranslation_php_grpc", + srcs = [":mediatranslation_proto"], + deps = [":mediatranslation_php_proto"], +) + +php_gapic_library( + name = "mediatranslation_php_gapic", + src = ":mediatranslation_proto_with_info", + gapic_yaml = "mediatranslation_gapic.yaml", + package = "google.cloud.mediatranslation.v1beta1", + service_yaml = "mediatranslation_v1beta1.yaml", + deps = [ + ":mediatranslation_php_grpc", + ":mediatranslation_php_proto", + ], +) + +# Open Source Packages +php_gapic_assembly_pkg( + name = "google-cloud-mediatranslation-v1beta1-php", + deps = [ + ":mediatranslation_php_gapic", + ":mediatranslation_php_grpc", + ":mediatranslation_php_proto", + ], +) + +############################################################################## +# Node.js +############################################################################## +load( + "@com_google_googleapis_imports//:imports.bzl", + "nodejs_gapic_assembly_pkg", + "nodejs_gapic_library", +) + +nodejs_gapic_library( + name = "mediatranslation_nodejs_gapic", + src = ":mediatranslation_proto_with_info", + gapic_yaml = "mediatranslation_gapic.yaml", + package = "google.cloud.mediatranslation.v1beta1", + service_yaml = "mediatranslation_v1beta1.yaml", + deps = [], +) + +nodejs_gapic_assembly_pkg( + name = "mediatranslation-v1beta1-nodejs", + deps = [ + ":mediatranslation_nodejs_gapic", + ":mediatranslation_proto", + ], +) + +############################################################################## +# Ruby +############################################################################## +load( + "@com_google_googleapis_imports//:imports.bzl", + "ruby_gapic_assembly_pkg", + "ruby_gapic_library", + "ruby_grpc_library", + "ruby_proto_library", +) + +ruby_proto_library( + name = "mediatranslation_ruby_proto", + deps = [":mediatranslation_proto"], +) + +ruby_grpc_library( + name = "mediatranslation_ruby_grpc", + srcs = [":mediatranslation_proto"], + deps = [":mediatranslation_ruby_proto"], +) + +ruby_gapic_library( + name = "mediatranslation_ruby_gapic", + src = ":mediatranslation_proto_with_info", + gapic_yaml = "mediatranslation_gapic.yaml", + package = "google.cloud.mediatranslation.v1beta1", + service_yaml = "mediatranslation_v1beta1.yaml", + deps = [ + ":mediatranslation_ruby_grpc", + ":mediatranslation_ruby_proto", + ], +) + +# Open Source Packages +ruby_gapic_assembly_pkg( + name = "google-cloud-mediatranslation-v1beta1-ruby", + deps = [ + ":mediatranslation_ruby_gapic", + ":mediatranslation_ruby_grpc", + ":mediatranslation_ruby_proto", + ], +) + +############################################################################## +# C# +############################################################################## +load( + "@com_google_googleapis_imports//:imports.bzl", + "csharp_gapic_assembly_pkg", + "csharp_gapic_library", + "csharp_grpc_library", + "csharp_proto_library", +) + +csharp_proto_library( + name = "mediatranslation_csharp_proto", + deps = [":mediatranslation_proto"], +) + +csharp_grpc_library( + name = "mediatranslation_csharp_grpc", + srcs = [":mediatranslation_proto"], + deps = [":mediatranslation_csharp_proto"], +) + +csharp_gapic_library( + name = "mediatranslation_csharp_gapic", + src = ":mediatranslation_proto_with_info", + gapic_yaml = "mediatranslation_gapic.yaml", + package = "google.cloud.mediatranslation.v1beta1", + service_yaml = "mediatranslation_v1beta1.yaml", + deps = [ + ":mediatranslation_csharp_grpc", + ":mediatranslation_csharp_proto", + ], +) + +# Open Source Packages +csharp_gapic_assembly_pkg( + name = "google-cloud-mediatranslation-v1beta1-csharp", + deps = [ + ":mediatranslation_csharp_gapic", + ":mediatranslation_csharp_grpc", + ":mediatranslation_csharp_proto", + ], +) + +############################################################################## +# C++ +############################################################################## +# Put your C++ rules here diff --git a/google/cloud/mediatranslation/v1beta1/media_translation.proto b/google/cloud/mediatranslation/v1beta1/media_translation.proto new file mode 100644 index 00000000..88eed82a --- /dev/null +++ b/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/google/cloud/mediatranslation/v1beta1/mediatranslation_gapic.yaml b/google/cloud/mediatranslation/v1beta1/mediatranslation_gapic.yaml new file mode 100644 index 00000000..16eefc40 --- /dev/null +++ b/google/cloud/mediatranslation/v1beta1/mediatranslation_gapic.yaml @@ -0,0 +1,18 @@ +type: com.google.api.codegen.ConfigProto +config_schema_version: 2.0.0 +language_settings: + java: + package_name: com.google.cloud.mediatranslation.v1beta1 + python: + package_name: google.cloud.mediatranslation_v1beta1.gapic + go: + package_name: cloud.google.com/go/mediatranslation/apiv1beta1 + csharp: + package_name: Google.Cloud.MediaTranslation.V1Beta1 + ruby: + package_name: Google::Cloud::MediaTranslation::V1beta1 + php: + package_name: Google\Cloud\MediaTranslation\V1beta1 + nodejs: + package_name: mediatranslation.v1beta1 + domain_layer_location: google-cloud diff --git a/google/cloud/mediatranslation/v1beta1/mediatranslation_grpc_service_config.json b/google/cloud/mediatranslation/v1beta1/mediatranslation_grpc_service_config.json new file mode 100644 index 00000000..beb0dde7 --- /dev/null +++ b/google/cloud/mediatranslation/v1beta1/mediatranslation_grpc_service_config.json @@ -0,0 +1,19 @@ +{ + "methodConfig": [{ + "name": [{ "service": "google.cloud.mediatranslation.v1beta1.SpeechTranslationService" }], + "timeout": "400s", + "retryPolicy": { + "maxAttempts": 5, + "initialBackoff": "1s", + "maxBackoff": "60s", + "backoffMultiplier": 1.3, + "retryableStatusCodes": ["UNAVAILABLE", "UNKNOWN", "DEADLINE_EXCEEDED"] + } + }, + { + "name": [ + { "service": "google.cloud.mediatranslation.v1beta1.SpeechTranslationService", "method": "StreamingTranslateSpeech" } + ], + "timeout": "400s" + }] +} diff --git a/google/cloud/mediatranslation/v1beta1/mediatranslation_v1beta1.yaml b/google/cloud/mediatranslation/v1beta1/mediatranslation_v1beta1.yaml new file mode 100644 index 00000000..f4f9a37a --- /dev/null +++ b/google/cloud/mediatranslation/v1beta1/mediatranslation_v1beta1.yaml @@ -0,0 +1,19 @@ +type: google.api.Service +config_version: 3 +name: mediatranslation.googleapis.com +title: Media Translation API + +apis: +- name: google.cloud.mediatranslation.v1beta1.SpeechTranslationService + +backend: + rules: + - selector: google.cloud.mediatranslation.v1beta1.SpeechTranslationService.StreamingTranslateSpeech + deadline: 355.0 + +authentication: + rules: + - selector: google.cloud.mediatranslation.v1beta1.SpeechTranslationService.StreamingTranslateSpeech + oauth: + canonical_scopes: |- + https://www.googleapis.com/auth/cloud-platform