google-cloud-text_to_speech-v1beta1 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +12 -0
- data/AUTHENTICATION.md +169 -0
- data/LICENSE.md +203 -0
- data/README.md +71 -0
- data/lib/google-cloud-text_to_speech-v1beta1.rb +21 -0
- data/lib/google/cloud/common_resources_pb.rb +15 -0
- data/lib/google/cloud/text_to_speech/v1beta1.rb +35 -0
- data/lib/google/cloud/text_to_speech/v1beta1/text_to_speech.rb +48 -0
- data/lib/google/cloud/text_to_speech/v1beta1/text_to_speech/client.rb +451 -0
- data/lib/google/cloud/text_to_speech/v1beta1/text_to_speech/credentials.rb +51 -0
- data/lib/google/cloud/text_to_speech/v1beta1/version.rb +28 -0
- data/lib/google/cloud/texttospeech/v1beta1/cloud_tts_pb.rb +82 -0
- data/lib/google/cloud/texttospeech/v1beta1/cloud_tts_services_pb.rb +49 -0
- data/proto_docs/README.md +4 -0
- data/proto_docs/google/api/field_behavior.rb +59 -0
- data/proto_docs/google/api/resource.rb +247 -0
- data/proto_docs/google/cloud/texttospeech/v1beta1/cloud_tts.rb +234 -0
- metadata +172 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
# This gem does not autoload during Bundler.require. To load this gem,
|
20
|
+
# issue explicit require statements for the packages desired, e.g.:
|
21
|
+
# require "google/cloud/text_to_speech/v1beta1"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: google/cloud/common_resources.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
require 'google/api/resource_pb'
|
7
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
8
|
+
add_file("google/cloud/common_resources.proto", :syntax => :proto3) do
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module Google
|
13
|
+
module Cloud
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
require "google/cloud/text_to_speech/v1beta1/text_to_speech"
|
20
|
+
require "google/cloud/text_to_speech/v1beta1/version"
|
21
|
+
|
22
|
+
module Google
|
23
|
+
module Cloud
|
24
|
+
module TextToSpeech
|
25
|
+
##
|
26
|
+
# To load this package, including all its services, and instantiate a client:
|
27
|
+
#
|
28
|
+
# require "google/cloud/text_to_speech/v1beta1"
|
29
|
+
# client = ::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Client.new
|
30
|
+
#
|
31
|
+
module V1beta1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
require "gapic/common"
|
20
|
+
require "gapic/config"
|
21
|
+
require "gapic/config/method"
|
22
|
+
|
23
|
+
require "google/cloud/text_to_speech/v1beta1/version"
|
24
|
+
|
25
|
+
require "google/cloud/text_to_speech/v1beta1/text_to_speech/credentials"
|
26
|
+
require "google/cloud/text_to_speech/v1beta1/text_to_speech/client"
|
27
|
+
|
28
|
+
module Google
|
29
|
+
module Cloud
|
30
|
+
module TextToSpeech
|
31
|
+
module V1beta1
|
32
|
+
##
|
33
|
+
# Service that implements Google Cloud Text-to-Speech API.
|
34
|
+
#
|
35
|
+
# To load this service and instantiate a client:
|
36
|
+
#
|
37
|
+
# require "google/cloud/text_to_speech/v1beta1/text_to_speech"
|
38
|
+
# client = ::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Client.new
|
39
|
+
#
|
40
|
+
module TextToSpeech
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
helper_path = ::File.join __dir__, "text_to_speech", "helpers.rb"
|
48
|
+
require "google/cloud/text_to_speech/v1beta1/text_to_speech/helpers" if ::File.file? helper_path
|
@@ -0,0 +1,451 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
require "google/cloud/errors"
|
20
|
+
require "google/cloud/texttospeech/v1beta1/cloud_tts_pb"
|
21
|
+
|
22
|
+
module Google
|
23
|
+
module Cloud
|
24
|
+
module TextToSpeech
|
25
|
+
module V1beta1
|
26
|
+
module TextToSpeech
|
27
|
+
##
|
28
|
+
# Client for the TextToSpeech service.
|
29
|
+
#
|
30
|
+
# Service that implements Google Cloud Text-to-Speech API.
|
31
|
+
#
|
32
|
+
class Client
|
33
|
+
# @private
|
34
|
+
attr_reader :text_to_speech_stub
|
35
|
+
|
36
|
+
##
|
37
|
+
# Configure the TextToSpeech Client class.
|
38
|
+
#
|
39
|
+
# See {::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Client::Configuration}
|
40
|
+
# for a description of the configuration fields.
|
41
|
+
#
|
42
|
+
# ## Example
|
43
|
+
#
|
44
|
+
# To modify the configuration for all TextToSpeech clients:
|
45
|
+
#
|
46
|
+
# ::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Client.configure do |config|
|
47
|
+
# config.timeout = 10.0
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# @yield [config] Configure the Client client.
|
51
|
+
# @yieldparam config [Client::Configuration]
|
52
|
+
#
|
53
|
+
# @return [Client::Configuration]
|
54
|
+
#
|
55
|
+
def self.configure
|
56
|
+
@configure ||= begin
|
57
|
+
namespace = ["Google", "Cloud", "TextToSpeech", "V1beta1"]
|
58
|
+
parent_config = while namespace.any?
|
59
|
+
parent_name = namespace.join "::"
|
60
|
+
parent_const = const_get parent_name
|
61
|
+
break parent_const.configure if parent_const&.respond_to? :configure
|
62
|
+
namespace.pop
|
63
|
+
end
|
64
|
+
default_config = Client::Configuration.new parent_config
|
65
|
+
|
66
|
+
default_config.rpcs.list_voices.timeout = 600.0
|
67
|
+
default_config.rpcs.list_voices.retry_policy = {
|
68
|
+
initial_delay: 0.1,
|
69
|
+
max_delay: 60.0,
|
70
|
+
multiplier: 1.3,
|
71
|
+
retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
|
72
|
+
}
|
73
|
+
|
74
|
+
default_config.rpcs.synthesize_speech.timeout = 600.0
|
75
|
+
default_config.rpcs.synthesize_speech.retry_policy = {
|
76
|
+
initial_delay: 0.1,
|
77
|
+
max_delay: 60.0,
|
78
|
+
multiplier: 1.3,
|
79
|
+
retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
|
80
|
+
}
|
81
|
+
|
82
|
+
default_config
|
83
|
+
end
|
84
|
+
yield @configure if block_given?
|
85
|
+
@configure
|
86
|
+
end
|
87
|
+
|
88
|
+
##
|
89
|
+
# Configure the TextToSpeech Client instance.
|
90
|
+
#
|
91
|
+
# The configuration is set to the derived mode, meaning that values can be changed,
|
92
|
+
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
93
|
+
# should be made on {Client.configure}.
|
94
|
+
#
|
95
|
+
# See {::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Client::Configuration}
|
96
|
+
# for a description of the configuration fields.
|
97
|
+
#
|
98
|
+
# @yield [config] Configure the Client client.
|
99
|
+
# @yieldparam config [Client::Configuration]
|
100
|
+
#
|
101
|
+
# @return [Client::Configuration]
|
102
|
+
#
|
103
|
+
def configure
|
104
|
+
yield @config if block_given?
|
105
|
+
@config
|
106
|
+
end
|
107
|
+
|
108
|
+
##
|
109
|
+
# Create a new TextToSpeech client object.
|
110
|
+
#
|
111
|
+
# ## Examples
|
112
|
+
#
|
113
|
+
# To create a new TextToSpeech client with the default
|
114
|
+
# configuration:
|
115
|
+
#
|
116
|
+
# client = ::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Client.new
|
117
|
+
#
|
118
|
+
# To create a new TextToSpeech client with a custom
|
119
|
+
# configuration:
|
120
|
+
#
|
121
|
+
# client = ::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Client.new do |config|
|
122
|
+
# config.timeout = 10.0
|
123
|
+
# end
|
124
|
+
#
|
125
|
+
# @yield [config] Configure the TextToSpeech client.
|
126
|
+
# @yieldparam config [Client::Configuration]
|
127
|
+
#
|
128
|
+
def initialize
|
129
|
+
# These require statements are intentionally placed here to initialize
|
130
|
+
# the gRPC module only when it's required.
|
131
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
132
|
+
require "gapic/grpc"
|
133
|
+
require "google/cloud/texttospeech/v1beta1/cloud_tts_services_pb"
|
134
|
+
|
135
|
+
# Create the configuration object
|
136
|
+
@config = Configuration.new Client.configure
|
137
|
+
|
138
|
+
# Yield the configuration if needed
|
139
|
+
yield @config if block_given?
|
140
|
+
|
141
|
+
# Create credentials
|
142
|
+
credentials = @config.credentials
|
143
|
+
credentials ||= Credentials.default scope: @config.scope
|
144
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
145
|
+
credentials = Credentials.new credentials, scope: @config.scope
|
146
|
+
end
|
147
|
+
@quota_project_id = credentials.respond_to?(:quota_project_id) ? credentials.quota_project_id : nil
|
148
|
+
|
149
|
+
@text_to_speech_stub = ::Gapic::ServiceStub.new(
|
150
|
+
::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Stub,
|
151
|
+
credentials: credentials,
|
152
|
+
endpoint: @config.endpoint,
|
153
|
+
channel_args: @config.channel_args,
|
154
|
+
interceptors: @config.interceptors
|
155
|
+
)
|
156
|
+
end
|
157
|
+
|
158
|
+
# Service calls
|
159
|
+
|
160
|
+
##
|
161
|
+
# Returns a list of Voice supported for synthesis.
|
162
|
+
#
|
163
|
+
# @overload list_voices(request, options = nil)
|
164
|
+
# Pass arguments to `list_voices` via a request object, either of type
|
165
|
+
# {::Google::Cloud::TextToSpeech::V1beta1::ListVoicesRequest} or an equivalent Hash.
|
166
|
+
#
|
167
|
+
# @param request [::Google::Cloud::TextToSpeech::V1beta1::ListVoicesRequest, ::Hash]
|
168
|
+
# A request object representing the call parameters. Required. To specify no
|
169
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
170
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
171
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
172
|
+
#
|
173
|
+
# @overload list_voices(language_code: nil)
|
174
|
+
# Pass arguments to `list_voices` via keyword arguments. Note that at
|
175
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
176
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
177
|
+
#
|
178
|
+
# @param language_code [::String]
|
179
|
+
# Optional. Recommended.
|
180
|
+
# [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. If
|
181
|
+
# specified, the ListVoices call will only return voices that can be used to
|
182
|
+
# synthesize this language_code. E.g. when specifying "en-NZ", you will get
|
183
|
+
# supported "en-*" voices; when specifying "no", you will get supported
|
184
|
+
# "no-*" (Norwegian) and "nb-*" (Norwegian Bokmal) voices; specifying "zh"
|
185
|
+
# will also get supported "cmn-*" voices; specifying "zh-hk" will also get
|
186
|
+
# supported "yue-*" voices.
|
187
|
+
#
|
188
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
189
|
+
# @yieldparam response [::Google::Cloud::TextToSpeech::V1beta1::ListVoicesResponse]
|
190
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
191
|
+
#
|
192
|
+
# @return [::Google::Cloud::TextToSpeech::V1beta1::ListVoicesResponse]
|
193
|
+
#
|
194
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
195
|
+
#
|
196
|
+
def list_voices request, options = nil
|
197
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
198
|
+
|
199
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::TextToSpeech::V1beta1::ListVoicesRequest
|
200
|
+
|
201
|
+
# Converts hash and nil to an options object
|
202
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
203
|
+
|
204
|
+
# Customize the options with defaults
|
205
|
+
metadata = @config.rpcs.list_voices.metadata.to_h
|
206
|
+
|
207
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
208
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
209
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
210
|
+
gapic_version: ::Google::Cloud::TextToSpeech::V1beta1::VERSION
|
211
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
212
|
+
|
213
|
+
options.apply_defaults timeout: @config.rpcs.list_voices.timeout,
|
214
|
+
metadata: metadata,
|
215
|
+
retry_policy: @config.rpcs.list_voices.retry_policy
|
216
|
+
options.apply_defaults metadata: @config.metadata,
|
217
|
+
retry_policy: @config.retry_policy
|
218
|
+
|
219
|
+
@text_to_speech_stub.call_rpc :list_voices, request, options: options do |response, operation|
|
220
|
+
yield response, operation if block_given?
|
221
|
+
return response
|
222
|
+
end
|
223
|
+
rescue ::GRPC::BadStatus => e
|
224
|
+
raise ::Google::Cloud::Error.from_error(e)
|
225
|
+
end
|
226
|
+
|
227
|
+
##
|
228
|
+
# Synthesizes speech synchronously: receive results after all text input
|
229
|
+
# has been processed.
|
230
|
+
#
|
231
|
+
# @overload synthesize_speech(request, options = nil)
|
232
|
+
# Pass arguments to `synthesize_speech` via a request object, either of type
|
233
|
+
# {::Google::Cloud::TextToSpeech::V1beta1::SynthesizeSpeechRequest} or an equivalent Hash.
|
234
|
+
#
|
235
|
+
# @param request [::Google::Cloud::TextToSpeech::V1beta1::SynthesizeSpeechRequest, ::Hash]
|
236
|
+
# A request object representing the call parameters. Required. To specify no
|
237
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
238
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
239
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
240
|
+
#
|
241
|
+
# @overload synthesize_speech(input: nil, voice: nil, audio_config: nil)
|
242
|
+
# Pass arguments to `synthesize_speech` via keyword arguments. Note that at
|
243
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
244
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
245
|
+
#
|
246
|
+
# @param input [::Google::Cloud::TextToSpeech::V1beta1::SynthesisInput, ::Hash]
|
247
|
+
# Required. The Synthesizer requires either plain text or SSML as input.
|
248
|
+
# @param voice [::Google::Cloud::TextToSpeech::V1beta1::VoiceSelectionParams, ::Hash]
|
249
|
+
# Required. The desired voice of the synthesized audio.
|
250
|
+
# @param audio_config [::Google::Cloud::TextToSpeech::V1beta1::AudioConfig, ::Hash]
|
251
|
+
# Required. The configuration of the synthesized audio.
|
252
|
+
#
|
253
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
254
|
+
# @yieldparam response [::Google::Cloud::TextToSpeech::V1beta1::SynthesizeSpeechResponse]
|
255
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
256
|
+
#
|
257
|
+
# @return [::Google::Cloud::TextToSpeech::V1beta1::SynthesizeSpeechResponse]
|
258
|
+
#
|
259
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
260
|
+
#
|
261
|
+
def synthesize_speech request, options = nil
|
262
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
263
|
+
|
264
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::TextToSpeech::V1beta1::SynthesizeSpeechRequest
|
265
|
+
|
266
|
+
# Converts hash and nil to an options object
|
267
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
268
|
+
|
269
|
+
# Customize the options with defaults
|
270
|
+
metadata = @config.rpcs.synthesize_speech.metadata.to_h
|
271
|
+
|
272
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
273
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
274
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
275
|
+
gapic_version: ::Google::Cloud::TextToSpeech::V1beta1::VERSION
|
276
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
277
|
+
|
278
|
+
options.apply_defaults timeout: @config.rpcs.synthesize_speech.timeout,
|
279
|
+
metadata: metadata,
|
280
|
+
retry_policy: @config.rpcs.synthesize_speech.retry_policy
|
281
|
+
options.apply_defaults metadata: @config.metadata,
|
282
|
+
retry_policy: @config.retry_policy
|
283
|
+
|
284
|
+
@text_to_speech_stub.call_rpc :synthesize_speech, request, options: options do |response, operation|
|
285
|
+
yield response, operation if block_given?
|
286
|
+
return response
|
287
|
+
end
|
288
|
+
rescue ::GRPC::BadStatus => e
|
289
|
+
raise ::Google::Cloud::Error.from_error(e)
|
290
|
+
end
|
291
|
+
|
292
|
+
##
|
293
|
+
# Configuration class for the TextToSpeech API.
|
294
|
+
#
|
295
|
+
# This class represents the configuration for TextToSpeech,
|
296
|
+
# providing control over timeouts, retry behavior, logging, transport
|
297
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
298
|
+
# applied individually to specific RPCs. See
|
299
|
+
# {::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Client::Configuration::Rpcs}
|
300
|
+
# for a list of RPCs that can be configured independently.
|
301
|
+
#
|
302
|
+
# Configuration can be applied globally to all clients, or to a single client
|
303
|
+
# on construction.
|
304
|
+
#
|
305
|
+
# # Examples
|
306
|
+
#
|
307
|
+
# To modify the global config, setting the timeout for list_voices
|
308
|
+
# to 20 seconds, and all remaining timeouts to 10 seconds:
|
309
|
+
#
|
310
|
+
# ::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Client.configure do |config|
|
311
|
+
# config.timeout = 10.0
|
312
|
+
# config.rpcs.list_voices.timeout = 20.0
|
313
|
+
# end
|
314
|
+
#
|
315
|
+
# To apply the above configuration only to a new client:
|
316
|
+
#
|
317
|
+
# client = ::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Client.new do |config|
|
318
|
+
# config.timeout = 10.0
|
319
|
+
# config.rpcs.list_voices.timeout = 20.0
|
320
|
+
# end
|
321
|
+
#
|
322
|
+
# @!attribute [rw] endpoint
|
323
|
+
# The hostname or hostname:port of the service endpoint.
|
324
|
+
# Defaults to `"texttospeech.googleapis.com"`.
|
325
|
+
# @return [::String]
|
326
|
+
# @!attribute [rw] credentials
|
327
|
+
# Credentials to send with calls. You may provide any of the following types:
|
328
|
+
# * (`String`) The path to a service account key file in JSON format
|
329
|
+
# * (`Hash`) A service account key as a Hash
|
330
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
331
|
+
# (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
|
332
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
333
|
+
# (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
|
334
|
+
# * (`GRPC::Core::Channel`) a gRPC channel with included credentials
|
335
|
+
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
|
336
|
+
# * (`nil`) indicating no credentials
|
337
|
+
# @return [::Object]
|
338
|
+
# @!attribute [rw] scope
|
339
|
+
# The OAuth scopes
|
340
|
+
# @return [::Array<::String>]
|
341
|
+
# @!attribute [rw] lib_name
|
342
|
+
# The library name as recorded in instrumentation and logging
|
343
|
+
# @return [::String]
|
344
|
+
# @!attribute [rw] lib_version
|
345
|
+
# The library version as recorded in instrumentation and logging
|
346
|
+
# @return [::String]
|
347
|
+
# @!attribute [rw] channel_args
|
348
|
+
# Extra parameters passed to the gRPC channel. Note: this is ignored if a
|
349
|
+
# `GRPC::Core::Channel` object is provided as the credential.
|
350
|
+
# @return [::Hash]
|
351
|
+
# @!attribute [rw] interceptors
|
352
|
+
# An array of interceptors that are run before calls are executed.
|
353
|
+
# @return [::Array<::GRPC::ClientInterceptor>]
|
354
|
+
# @!attribute [rw] timeout
|
355
|
+
# The call timeout in seconds.
|
356
|
+
# @return [::Numeric]
|
357
|
+
# @!attribute [rw] metadata
|
358
|
+
# Additional gRPC headers to be sent with the call.
|
359
|
+
# @return [::Hash{::Symbol=>::String}]
|
360
|
+
# @!attribute [rw] retry_policy
|
361
|
+
# The retry policy. The value is a hash with the following keys:
|
362
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
363
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
364
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
365
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
366
|
+
# trigger a retry.
|
367
|
+
# @return [::Hash]
|
368
|
+
#
|
369
|
+
class Configuration
|
370
|
+
extend ::Gapic::Config
|
371
|
+
|
372
|
+
config_attr :endpoint, "texttospeech.googleapis.com", String
|
373
|
+
config_attr :credentials, nil do |value|
|
374
|
+
allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
375
|
+
allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
|
376
|
+
allowed.any? { |klass| klass === value }
|
377
|
+
end
|
378
|
+
config_attr :scope, nil, ::String, ::Array, nil
|
379
|
+
config_attr :lib_name, nil, ::String, nil
|
380
|
+
config_attr :lib_version, nil, ::String, nil
|
381
|
+
config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
|
382
|
+
config_attr :interceptors, nil, ::Array, nil
|
383
|
+
config_attr :timeout, nil, ::Numeric, nil
|
384
|
+
config_attr :metadata, nil, ::Hash, nil
|
385
|
+
config_attr :retry_policy, nil, ::Hash, Proc, nil
|
386
|
+
|
387
|
+
# @private
|
388
|
+
def initialize parent_config = nil
|
389
|
+
@parent_config = parent_config unless parent_config.nil?
|
390
|
+
|
391
|
+
yield self if block_given?
|
392
|
+
end
|
393
|
+
|
394
|
+
##
|
395
|
+
# Configurations for individual RPCs
|
396
|
+
# @return [Rpcs]
|
397
|
+
#
|
398
|
+
def rpcs
|
399
|
+
@rpcs ||= begin
|
400
|
+
parent_rpcs = nil
|
401
|
+
parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
|
402
|
+
Rpcs.new parent_rpcs
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
##
|
407
|
+
# Configuration RPC class for the TextToSpeech API.
|
408
|
+
#
|
409
|
+
# Includes fields providing the configuration for each RPC in this service.
|
410
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
411
|
+
# the following configuration fields:
|
412
|
+
#
|
413
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
|
414
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
|
415
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
416
|
+
# include the following keys:
|
417
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
418
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
419
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
420
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
421
|
+
# trigger a retry.
|
422
|
+
#
|
423
|
+
class Rpcs
|
424
|
+
##
|
425
|
+
# RPC-specific configuration for `list_voices`
|
426
|
+
# @return [::Gapic::Config::Method]
|
427
|
+
#
|
428
|
+
attr_reader :list_voices
|
429
|
+
##
|
430
|
+
# RPC-specific configuration for `synthesize_speech`
|
431
|
+
# @return [::Gapic::Config::Method]
|
432
|
+
#
|
433
|
+
attr_reader :synthesize_speech
|
434
|
+
|
435
|
+
# @private
|
436
|
+
def initialize parent_rpcs = nil
|
437
|
+
list_voices_config = parent_rpcs&.list_voices if parent_rpcs&.respond_to? :list_voices
|
438
|
+
@list_voices = ::Gapic::Config::Method.new list_voices_config
|
439
|
+
synthesize_speech_config = parent_rpcs&.synthesize_speech if parent_rpcs&.respond_to? :synthesize_speech
|
440
|
+
@synthesize_speech = ::Gapic::Config::Method.new synthesize_speech_config
|
441
|
+
|
442
|
+
yield self if block_given?
|
443
|
+
end
|
444
|
+
end
|
445
|
+
end
|
446
|
+
end
|
447
|
+
end
|
448
|
+
end
|
449
|
+
end
|
450
|
+
end
|
451
|
+
end
|