google-cloud-text_to_speech-v1beta1 0.9.1 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,163 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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/texttospeech/v1beta1/cloud_tts_pb"
20
+
21
+ module Google
22
+ module Cloud
23
+ module TextToSpeech
24
+ module V1beta1
25
+ module TextToSpeech
26
+ module Rest
27
+ ##
28
+ # REST service stub for the TextToSpeech service.
29
+ # Service stub contains baseline method implementations
30
+ # including transcoding, making the REST call, and deserialing the response.
31
+ #
32
+ class ServiceStub
33
+ def initialize endpoint:, credentials:
34
+ # These require statements are intentionally placed here to initialize
35
+ # the REST modules only when it's required.
36
+ require "gapic/rest"
37
+
38
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials,
39
+ numeric_enums: true,
40
+ raise_faraday_errors: false
41
+ end
42
+
43
+ ##
44
+ # Baseline implementation for the list_voices REST call
45
+ #
46
+ # @param request_pb [::Google::Cloud::TextToSpeech::V1beta1::ListVoicesRequest]
47
+ # A request object representing the call parameters. Required.
48
+ # @param options [::Gapic::CallOptions]
49
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
50
+ #
51
+ # @yield [result, operation] Access the result along with the TransportOperation object
52
+ # @yieldparam result [::Google::Cloud::TextToSpeech::V1beta1::ListVoicesResponse]
53
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
54
+ #
55
+ # @return [::Google::Cloud::TextToSpeech::V1beta1::ListVoicesResponse]
56
+ # A result object deserialized from the server's reply
57
+ def list_voices request_pb, options = nil
58
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
59
+
60
+ verb, uri, query_string_params, body = ServiceStub.transcode_list_voices_request request_pb
61
+ query_string_params = if query_string_params.any?
62
+ query_string_params.to_h { |p| p.split("=", 2) }
63
+ else
64
+ {}
65
+ end
66
+
67
+ response = @client_stub.make_http_request(
68
+ verb,
69
+ uri: uri,
70
+ body: body || "",
71
+ params: query_string_params,
72
+ options: options
73
+ )
74
+ operation = ::Gapic::Rest::TransportOperation.new response
75
+ result = ::Google::Cloud::TextToSpeech::V1beta1::ListVoicesResponse.decode_json response.body, ignore_unknown_fields: true
76
+
77
+ yield result, operation if block_given?
78
+ result
79
+ end
80
+
81
+ ##
82
+ # Baseline implementation for the synthesize_speech REST call
83
+ #
84
+ # @param request_pb [::Google::Cloud::TextToSpeech::V1beta1::SynthesizeSpeechRequest]
85
+ # A request object representing the call parameters. Required.
86
+ # @param options [::Gapic::CallOptions]
87
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
88
+ #
89
+ # @yield [result, operation] Access the result along with the TransportOperation object
90
+ # @yieldparam result [::Google::Cloud::TextToSpeech::V1beta1::SynthesizeSpeechResponse]
91
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
92
+ #
93
+ # @return [::Google::Cloud::TextToSpeech::V1beta1::SynthesizeSpeechResponse]
94
+ # A result object deserialized from the server's reply
95
+ def synthesize_speech request_pb, options = nil
96
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
97
+
98
+ verb, uri, query_string_params, body = ServiceStub.transcode_synthesize_speech_request request_pb
99
+ query_string_params = if query_string_params.any?
100
+ query_string_params.to_h { |p| p.split("=", 2) }
101
+ else
102
+ {}
103
+ end
104
+
105
+ response = @client_stub.make_http_request(
106
+ verb,
107
+ uri: uri,
108
+ body: body || "",
109
+ params: query_string_params,
110
+ options: options
111
+ )
112
+ operation = ::Gapic::Rest::TransportOperation.new response
113
+ result = ::Google::Cloud::TextToSpeech::V1beta1::SynthesizeSpeechResponse.decode_json response.body, ignore_unknown_fields: true
114
+
115
+ yield result, operation if block_given?
116
+ result
117
+ end
118
+
119
+ ##
120
+ # @private
121
+ #
122
+ # GRPC transcoding helper method for the list_voices REST call
123
+ #
124
+ # @param request_pb [::Google::Cloud::TextToSpeech::V1beta1::ListVoicesRequest]
125
+ # A request object representing the call parameters. Required.
126
+ # @return [Array(String, [String, nil], Hash{String => String})]
127
+ # Uri, Body, Query string parameters
128
+ def self.transcode_list_voices_request request_pb
129
+ transcoder = Gapic::Rest::GrpcTranscoder.new
130
+ .with_bindings(
131
+ uri_method: :get,
132
+ uri_template: "/v1beta1/voices",
133
+ matches: []
134
+ )
135
+ transcoder.transcode request_pb
136
+ end
137
+
138
+ ##
139
+ # @private
140
+ #
141
+ # GRPC transcoding helper method for the synthesize_speech REST call
142
+ #
143
+ # @param request_pb [::Google::Cloud::TextToSpeech::V1beta1::SynthesizeSpeechRequest]
144
+ # A request object representing the call parameters. Required.
145
+ # @return [Array(String, [String, nil], Hash{String => String})]
146
+ # Uri, Body, Query string parameters
147
+ def self.transcode_synthesize_speech_request request_pb
148
+ transcoder = Gapic::Rest::GrpcTranscoder.new
149
+ .with_bindings(
150
+ uri_method: :post,
151
+ uri_template: "/v1beta1/text:synthesize",
152
+ body: "*",
153
+ matches: []
154
+ )
155
+ transcoder.transcode request_pb
156
+ end
157
+ end
158
+ end
159
+ end
160
+ end
161
+ end
162
+ end
163
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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/rest"
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/paths"
27
+ require "google/cloud/text_to_speech/v1beta1/text_to_speech/rest/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module TextToSpeech
32
+ module V1beta1
33
+ ##
34
+ # Service that implements Google Cloud Text-to-Speech API.
35
+ #
36
+ # To load this service and instantiate a REST client:
37
+ #
38
+ # require "google/cloud/text_to_speech/v1beta1/text_to_speech/rest"
39
+ # client = ::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Rest::Client.new
40
+ #
41
+ module TextToSpeech
42
+ # Client for the REST transport
43
+ module Rest
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ helper_path = ::File.join __dir__, "rest", "helpers.rb"
52
+ require "google/cloud/text_to_speech/v1beta1/text_to_speech/rest/helpers" if ::File.file? helper_path
@@ -25,6 +25,7 @@ require "google/cloud/text_to_speech/v1beta1/version"
25
25
  require "google/cloud/text_to_speech/v1beta1/text_to_speech/credentials"
26
26
  require "google/cloud/text_to_speech/v1beta1/text_to_speech/paths"
27
27
  require "google/cloud/text_to_speech/v1beta1/text_to_speech/client"
28
+ require "google/cloud/text_to_speech/v1beta1/text_to_speech/rest"
28
29
 
29
30
  module Google
30
31
  module Cloud
@@ -33,11 +34,16 @@ module Google
33
34
  ##
34
35
  # Service that implements Google Cloud Text-to-Speech API.
35
36
  #
36
- # To load this service and instantiate a client:
37
+ # @example Load this service and instantiate a gRPC client
37
38
  #
38
39
  # require "google/cloud/text_to_speech/v1beta1/text_to_speech"
39
40
  # client = ::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Client.new
40
41
  #
42
+ # @example Load this service and instantiate a REST client
43
+ #
44
+ # require "google/cloud/text_to_speech/v1beta1/text_to_speech/rest"
45
+ # client = ::Google::Cloud::TextToSpeech::V1beta1::TextToSpeech::Rest::Client.new
46
+ #
41
47
  module TextToSpeech
42
48
  end
43
49
  end
@@ -179,17 +179,18 @@ module Google
179
179
  #
180
180
  # @param parent [::String]
181
181
  # The resource states of the request in the form of
182
- # `projects/*/locations/*/voices/*`.
182
+ # `projects/*/locations/*`.
183
183
  # @param input [::Google::Cloud::TextToSpeech::V1beta1::SynthesisInput, ::Hash]
184
184
  # Required. The Synthesizer requires either plain text or SSML as input.
185
+ # While Long Audio is in preview, SSML is temporarily unsupported.
185
186
  # @param audio_config [::Google::Cloud::TextToSpeech::V1beta1::AudioConfig, ::Hash]
186
187
  # Required. The configuration of the synthesized audio.
187
188
  # @param output_gcs_uri [::String]
188
- # Specifies a Cloud Storage URI for the synthesis results. Must be
189
+ # Required. Specifies a Cloud Storage URI for the synthesis results. Must be
189
190
  # specified in the format: `gs://bucket_name/object_name`, and the bucket
190
191
  # must already exist.
191
192
  # @param voice [::Google::Cloud::TextToSpeech::V1beta1::VoiceSelectionParams, ::Hash]
192
- # The desired voice of the synthesized audio.
193
+ # Required. The desired voice of the synthesized audio.
193
194
  #
194
195
  # @yield [response, operation] Access the result along with the RPC operation
195
196
  # @yieldparam response [::Gapic::Operation]
@@ -211,14 +212,14 @@ module Google
211
212
  # # Call the synthesize_long_audio method.
212
213
  # result = client.synthesize_long_audio request
213
214
  #
214
- # # The returned object is of type Gapic::Operation. You can use this
215
- # # object to check the status of an operation, cancel it, or wait
216
- # # for results. Here is how to block until completion:
215
+ # # The returned object is of type Gapic::Operation. You can use it to
216
+ # # check the status of an operation, cancel it, or wait for results.
217
+ # # Here is how to wait for a response.
217
218
  # result.wait_until_done! timeout: 60
218
219
  # if result.response?
219
220
  # p result.response
220
221
  # else
221
- # puts "Error!"
222
+ # puts "No response received."
222
223
  # end
223
224
  #
224
225
  def synthesize_long_audio request, options = nil
@@ -301,9 +302,9 @@ module Google
301
302
  # * (`String`) The path to a service account key file in JSON format
302
303
  # * (`Hash`) A service account key as a Hash
303
304
  # * (`Google::Auth::Credentials`) A googleauth credentials object
304
- # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
305
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
305
306
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
306
- # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
307
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
307
308
  # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
308
309
  # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
309
310
  # * (`nil`) indicating no credentials
@@ -158,13 +158,11 @@ module Google
158
158
  # # Call the list_operations method.
159
159
  # result = client.list_operations request
160
160
  #
161
- # # The returned object is of type Gapic::PagedEnumerable. You can
162
- # # iterate over all elements by calling #each, and the enumerable
163
- # # will lazily make API calls to fetch subsequent pages. Other
164
- # # methods are also available for managing paging directly.
165
- # result.each do |response|
161
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
162
+ # # over elements, and API calls will be issued to fetch pages as needed.
163
+ # result.each do |item|
166
164
  # # Each element is of type ::Google::Longrunning::Operation.
167
- # p response
165
+ # p item
168
166
  # end
169
167
  #
170
168
  def list_operations request, options = nil
@@ -253,14 +251,14 @@ module Google
253
251
  # # Call the get_operation method.
254
252
  # result = client.get_operation request
255
253
  #
256
- # # The returned object is of type Gapic::Operation. You can use this
257
- # # object to check the status of an operation, cancel it, or wait
258
- # # for results. Here is how to block until completion:
254
+ # # The returned object is of type Gapic::Operation. You can use it to
255
+ # # check the status of an operation, cancel it, or wait for results.
256
+ # # Here is how to wait for a response.
259
257
  # result.wait_until_done! timeout: 60
260
258
  # if result.response?
261
259
  # p result.response
262
260
  # else
263
- # puts "Error!"
261
+ # puts "No response received."
264
262
  # end
265
263
  #
266
264
  def get_operation request, options = nil
@@ -540,14 +538,14 @@ module Google
540
538
  # # Call the wait_operation method.
541
539
  # result = client.wait_operation request
542
540
  #
543
- # # The returned object is of type Gapic::Operation. You can use this
544
- # # object to check the status of an operation, cancel it, or wait
545
- # # for results. Here is how to block until completion:
541
+ # # The returned object is of type Gapic::Operation. You can use it to
542
+ # # check the status of an operation, cancel it, or wait for results.
543
+ # # Here is how to wait for a response.
546
544
  # result.wait_until_done! timeout: 60
547
545
  # if result.response?
548
546
  # p result.response
549
547
  # else
550
- # puts "Error!"
548
+ # puts "No response received."
551
549
  # end
552
550
  #
553
551
  def wait_operation request, options = nil
@@ -622,9 +620,9 @@ module Google
622
620
  # * (`String`) The path to a service account key file in JSON format
623
621
  # * (`Hash`) A service account key as a Hash
624
622
  # * (`Google::Auth::Credentials`) A googleauth credentials object
625
- # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
623
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
626
624
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
627
- # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
625
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
628
626
  # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
629
627
  # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
630
628
  # * (`nil`) indicating no credentials