google-cloud-text_to_speech 0.1.0

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,32 @@
1
+ # Copyright 2018 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require "googleauth"
16
+
17
+ module Google
18
+ module Cloud
19
+ module TextToSpeech
20
+ module V1
21
+ class Credentials < Google::Auth::Credentials
22
+ SCOPE = [
23
+ "https://www.googleapis.com/auth/cloud-platform"
24
+ ].freeze
25
+ PATH_ENV_VARS = %w(TEXTTOSPEECH_KEYFILE GOOGLE_CLOUD_KEYFILE GCLOUD_KEYFILE)
26
+ JSON_ENV_VARS = %w(TEXTTOSPEECH_KEYFILE_JSON GOOGLE_CLOUD_KEYFILE_JSON GCLOUD_KEYFILE_JSON)
27
+ DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"]
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,206 @@
1
+ # Copyright 2018 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Google
16
+ module Cloud
17
+ module Texttospeech
18
+ ##
19
+ # # Cloud Text-to-Speech API Contents
20
+ #
21
+ # | Class | Description |
22
+ # | ----- | ----------- |
23
+ # | [TextToSpeechClient][] | Service that implements Google Cloud Text-to-Speech API. |
24
+ # | [Data Types][] | Data types for Google::Cloud::TextToSpeech::V1 |
25
+ #
26
+ # [TextToSpeechClient]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-text_to_speech/latest/google/cloud/texttospeech/v1/texttospeechclient
27
+ # [Data Types]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-text_to_speech/latest/google/cloud/texttospeech/v1/datatypes
28
+ #
29
+ module V1
30
+ # The top-level message sent by the client for the +ListVoices+ method.
31
+ # @!attribute [rw] language_code
32
+ # @return [String]
33
+ # Optional (but recommended)
34
+ # [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. If
35
+ # specified, the ListVoices call will only return voices that can be used to
36
+ # synthesize this language_code. E.g. when specifying "en-NZ", you will get
37
+ # supported "en-*" voices; when specifying "no", you will get supported
38
+ # "no-*" (Norwegian) and "nb-*" (Norwegian Bokmal) voices; specifying "zh"
39
+ # will also get supported "cmn-*" voices; specifying "zh-hk" will also get
40
+ # supported "yue-*" voices.
41
+ class ListVoicesRequest; end
42
+
43
+ # The message returned to the client by the +ListVoices+ method.
44
+ # @!attribute [rw] voices
45
+ # @return [Array<Google::Cloud::Texttospeech::V1::Voice>]
46
+ # The list of voices.
47
+ class ListVoicesResponse; end
48
+
49
+ # Description of a voice supported by the TTS service.
50
+ # @!attribute [rw] language_codes
51
+ # @return [Array<String>]
52
+ # The languages that this voice supports, expressed as
53
+ # [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tags (e.g.
54
+ # "en-US", "es-419", "cmn-tw").
55
+ # @!attribute [rw] name
56
+ # @return [String]
57
+ # The name of this voice. Each distinct voice has a unique name.
58
+ # @!attribute [rw] ssml_gender
59
+ # @return [Google::Cloud::Texttospeech::V1::SsmlVoiceGender]
60
+ # The gender of this voice.
61
+ # @!attribute [rw] natural_sample_rate_hertz
62
+ # @return [Integer]
63
+ # The natural sample rate (in hertz) for this voice.
64
+ class Voice; end
65
+
66
+ # The top-level message sent by the client for the +SynthesizeSpeech+ method.
67
+ # @!attribute [rw] input
68
+ # @return [Google::Cloud::Texttospeech::V1::SynthesisInput]
69
+ # Required. The Synthesizer requires either plain text or SSML as input.
70
+ # @!attribute [rw] voice
71
+ # @return [Google::Cloud::Texttospeech::V1::VoiceSelectionParams]
72
+ # Required. The desired voice of the synthesized audio.
73
+ # @!attribute [rw] audio_config
74
+ # @return [Google::Cloud::Texttospeech::V1::AudioConfig]
75
+ # Required. The configuration of the synthesized audio.
76
+ class SynthesizeSpeechRequest; end
77
+
78
+ # Contains text input to be synthesized. Either +text+ or +ssml+ must be
79
+ # supplied. Supplying both or neither returns
80
+ # {Google::Rpc::Code::INVALID_ARGUMENT}. The input size is limited to 5000
81
+ # characters.
82
+ # @!attribute [rw] text
83
+ # @return [String]
84
+ # The raw text to be synthesized.
85
+ # @!attribute [rw] ssml
86
+ # @return [String]
87
+ # The SSML document to be synthesized. The SSML document must be valid
88
+ # and well-formed. Otherwise the RPC will fail and return
89
+ # {Google::Rpc::Code::INVALID_ARGUMENT}. For more information, see
90
+ # [SSML](https://cloud.google.com/speech/text-to-speech/docs/ssml).
91
+ class SynthesisInput; end
92
+
93
+ # Description of which voice to use for a synthesis request.
94
+ # @!attribute [rw] language_code
95
+ # @return [String]
96
+ # The language (and optionally also the region) of the voice expressed as a
97
+ # [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag, e.g.
98
+ # "en-US". Required. This should not include a script tag (e.g. use
99
+ # "cmn-cn" rather than "cmn-Hant-cn"), because the script will be inferred
100
+ # from the input provided in the SynthesisInput. The TTS service
101
+ # will use this parameter to help choose an appropriate voice. Note that
102
+ # the TTS service may choose a voice with a slightly different language code
103
+ # than the one selected; it may substitute a different region
104
+ # (e.g. using en-US rather than en-CA if there isn't a Canadian voice
105
+ # available), or even a different language, e.g. using "nb" (Norwegian
106
+ # Bokmal) instead of "no" (Norwegian)".
107
+ # @!attribute [rw] name
108
+ # @return [String]
109
+ # The name of the voice. Optional; if not set, the service will choose a
110
+ # voice based on the other parameters such as language_code and gender.
111
+ # @!attribute [rw] ssml_gender
112
+ # @return [Google::Cloud::Texttospeech::V1::SsmlVoiceGender]
113
+ # The preferred gender of the voice. Optional; if not set, the service will
114
+ # choose a voice based on the other parameters such as language_code and
115
+ # name. Note that this is only a preference, not requirement; if a
116
+ # voice of the appropriate gender is not available, the synthesizer should
117
+ # substitute a voice with a different gender rather than failing the request.
118
+ class VoiceSelectionParams; end
119
+
120
+ # Description of audio data to be synthesized.
121
+ # @!attribute [rw] audio_encoding
122
+ # @return [Google::Cloud::Texttospeech::V1::AudioEncoding]
123
+ # Required. The format of the requested audio byte stream.
124
+ # @!attribute [rw] speaking_rate
125
+ # @return [Float]
126
+ # Optional speaking rate/speed, in the range [0.25, 4.0]. 1.0 is the normal
127
+ # native speed supported by the specific voice. 2.0 is twice as fast, and
128
+ # 0.5 is half as fast. If unset(0.0), defaults to the native 1.0 speed. Any
129
+ # other values < 0.25 or > 4.0 will return an error.
130
+ # @!attribute [rw] pitch
131
+ # @return [Float]
132
+ # Optional speaking pitch, in the range [-20.0, 20.0]. 20 means increase 20
133
+ # semitones from the original pitch. -20 means decrease 20 semitones from the
134
+ # original pitch.
135
+ # @!attribute [rw] volume_gain_db
136
+ # @return [Float]
137
+ # Optional volume gain (in dB) of the normal native volume supported by the
138
+ # specific voice, in the range [-96.0, 16.0]. If unset, or set to a value of
139
+ # 0.0 (dB), will play at normal native signal amplitude. A value of -6.0 (dB)
140
+ # will play at approximately half the amplitude of the normal native signal
141
+ # amplitude. A value of +6.0 (dB) will play at approximately twice the
142
+ # amplitude of the normal native signal amplitude. Strongly recommend not to
143
+ # exceed +10 (dB) as there's usually no effective increase in loudness for
144
+ # any value greater than that.
145
+ # @!attribute [rw] sample_rate_hertz
146
+ # @return [Integer]
147
+ # The synthesis sample rate (in hertz) for this audio. Optional. If this is
148
+ # different from the voice's natural sample rate, then the synthesizer will
149
+ # honor this request by converting to the desired sample rate (which might
150
+ # result in worse audio quality), unless the specified sample rate is not
151
+ # supported for the encoding chosen, in which case it will fail the request
152
+ # and return {Google::Rpc::Code::INVALID_ARGUMENT}.
153
+ class AudioConfig; end
154
+
155
+ # The message returned to the client by the +SynthesizeSpeech+ method.
156
+ # @!attribute [rw] audio_content
157
+ # @return [String]
158
+ # The audio data bytes encoded as specified in the request, including the
159
+ # header (For LINEAR16 audio, we include the WAV header). Note: as
160
+ # with all bytes fields, protobuffers use a pure binary representation,
161
+ # whereas JSON representations use base64.
162
+ class SynthesizeSpeechResponse; end
163
+
164
+ # Gender of the voice as described in
165
+ # [SSML voice element](https://www.w3.org/TR/speech-synthesis11/#edef_voice).
166
+ module SsmlVoiceGender
167
+ # An unspecified gender.
168
+ # In VoiceSelectionParams, this means that the client doesn't care which
169
+ # gender the selected voice will have. In the Voice field of
170
+ # ListVoicesResponse, this may mean that the voice doesn't fit any of the
171
+ # other categories in this enum, or that the gender of the voice isn't known.
172
+ SSML_VOICE_GENDER_UNSPECIFIED = 0
173
+
174
+ # A male voice.
175
+ MALE = 1
176
+
177
+ # A female voice.
178
+ FEMALE = 2
179
+
180
+ # A gender-neutral voice.
181
+ NEUTRAL = 3
182
+ end
183
+
184
+ # Configuration to set up audio encoder. The encoding determines the output
185
+ # audio format that we'd like.
186
+ module AudioEncoding
187
+ # Not specified. Will return result {Google::Rpc::Code::INVALID_ARGUMENT}.
188
+ AUDIO_ENCODING_UNSPECIFIED = 0
189
+
190
+ # Uncompressed 16-bit signed little-endian samples (Linear PCM).
191
+ # Audio content returned as LINEAR16 also contains a WAV header.
192
+ LINEAR16 = 1
193
+
194
+ # MP3 audio.
195
+ MP3 = 2
196
+
197
+ # Opus encoded audio wrapped in an ogg container. The result will be a
198
+ # file which can be played natively on Android, and in browsers (at least
199
+ # Chrome and Firefox). The quality of the encoding is considerably higher
200
+ # than MP3 while using approximately the same bitrate.
201
+ OGG_OPUS = 3
202
+ end
203
+ end
204
+ end
205
+ end
206
+ end
@@ -0,0 +1,80 @@
1
+ # Copyright 2018 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Google
16
+ module Cloud
17
+ # rubocop:disable LineLength
18
+
19
+ ##
20
+ # # Ruby Client for Cloud Text-to-Speech API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
21
+ #
22
+ # [Cloud Text-to-Speech API][Product Documentation]:
23
+ # Synthesizes natural-sounding speech by applying powerful neural network
24
+ # models.
25
+ # - [Product Documentation][]
26
+ #
27
+ # ## Quick Start
28
+ # In order to use this library, you first need to go through the following
29
+ # steps:
30
+ #
31
+ # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
32
+ # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
33
+ # 3. [Enable the Cloud Text-to-Speech API.](https://console.cloud.google.com/apis/api/texttospeech)
34
+ # 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
35
+ #
36
+ # ### Installation
37
+ # ```
38
+ # $ gem install google-cloud-text_to_speech
39
+ # ```
40
+ #
41
+ # ### Next Steps
42
+ # - Read the [Cloud Text-to-Speech API Product documentation][Product Documentation]
43
+ # to learn more about the product and see How-to Guides.
44
+ # - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
45
+ # to see the full list of Cloud APIs that we cover.
46
+ #
47
+ # [Product Documentation]: https://cloud.google.com/texttospeech
48
+ #
49
+ # ## Enabling Logging
50
+ #
51
+ # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
52
+ # The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
53
+ # or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
54
+ # that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
55
+ # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
56
+ #
57
+ # Configuring a Ruby stdlib logger:
58
+ #
59
+ # ```ruby
60
+ # require "logger"
61
+ #
62
+ # module MyLogger
63
+ # LOGGER = Logger.new $stderr, level: Logger::WARN
64
+ # def logger
65
+ # LOGGER
66
+ # end
67
+ # end
68
+ #
69
+ # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
70
+ # module GRPC
71
+ # extend MyLogger
72
+ # end
73
+ # ```
74
+ #
75
+ module TextToSpeech
76
+ module V1
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,268 @@
1
+ # Copyright 2018 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+ # EDITING INSTRUCTIONS
16
+ # This file was generated from the file
17
+ # https://github.com/googleapis/googleapis/blob/master/google/cloud/texttospeech/v1/cloud_tts.proto,
18
+ # and updates to that file get reflected here through a refresh process.
19
+ # For the short term, the refresh process will only be runnable by Google
20
+ # engineers.
21
+
22
+ require "json"
23
+ require "pathname"
24
+
25
+ require "google/gax"
26
+
27
+ require "google/cloud/texttospeech/v1/cloud_tts_pb"
28
+ require "google/cloud/text_to_speech/v1/credentials"
29
+
30
+ module Google
31
+ module Cloud
32
+ module TextToSpeech
33
+ module V1
34
+ # Service that implements Google Cloud Text-to-Speech API.
35
+ #
36
+ # @!attribute [r] text_to_speech_stub
37
+ # @return [Google::Cloud::Texttospeech::V1::TextToSpeech::Stub]
38
+ class TextToSpeechClient
39
+ attr_reader :text_to_speech_stub
40
+
41
+ # The default address of the service.
42
+ SERVICE_ADDRESS = "texttospeech.googleapis.com".freeze
43
+
44
+ # The default port of the service.
45
+ DEFAULT_SERVICE_PORT = 443
46
+
47
+ # The default set of gRPC interceptors.
48
+ GRPC_INTERCEPTORS = []
49
+
50
+ DEFAULT_TIMEOUT = 30
51
+
52
+ # The scopes needed to make gRPC calls to all of the methods defined in
53
+ # this service.
54
+ ALL_SCOPES = [
55
+ "https://www.googleapis.com/auth/cloud-platform"
56
+ ].freeze
57
+
58
+
59
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
60
+ # Provides the means for authenticating requests made by the client. This parameter can
61
+ # be many types.
62
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
63
+ # authenticating requests made by this client.
64
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
65
+ # credentials for this client.
66
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
67
+ # credentials for this client.
68
+ # A `GRPC::Core::Channel` will be used to make calls through.
69
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
70
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
71
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
72
+ # metadata for requests, generally, to give OAuth credentials.
73
+ # @param scopes [Array<String>]
74
+ # The OAuth scopes for this service. This parameter is ignored if
75
+ # an updater_proc is supplied.
76
+ # @param client_config [Hash]
77
+ # A Hash for call options for each method. See
78
+ # Google::Gax#construct_settings for the structure of
79
+ # this data. Falls back to the default config if not specified
80
+ # or the specified config is missing data points.
81
+ # @param timeout [Numeric]
82
+ # The default timeout, in seconds, for calls made through this client.
83
+ # @param metadata [Hash]
84
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
85
+ # @param exception_transformer [Proc]
86
+ # An optional proc that intercepts any exceptions raised during an API call to inject
87
+ # custom error handling.
88
+ def initialize \
89
+ credentials: nil,
90
+ scopes: ALL_SCOPES,
91
+ client_config: {},
92
+ timeout: DEFAULT_TIMEOUT,
93
+ metadata: nil,
94
+ exception_transformer: nil,
95
+ lib_name: nil,
96
+ lib_version: ""
97
+ # These require statements are intentionally placed here to initialize
98
+ # the gRPC module only when it's required.
99
+ # See https://github.com/googleapis/toolkit/issues/446
100
+ require "google/gax/grpc"
101
+ require "google/cloud/texttospeech/v1/cloud_tts_services_pb"
102
+
103
+ credentials ||= Google::Cloud::TextToSpeech::V1::Credentials.default
104
+
105
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
106
+ updater_proc = Google::Cloud::TextToSpeech::V1::Credentials.new(credentials).updater_proc
107
+ end
108
+ if credentials.is_a?(GRPC::Core::Channel)
109
+ channel = credentials
110
+ end
111
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
112
+ chan_creds = credentials
113
+ end
114
+ if credentials.is_a?(Proc)
115
+ updater_proc = credentials
116
+ end
117
+ if credentials.is_a?(Google::Auth::Credentials)
118
+ updater_proc = credentials.updater_proc
119
+ end
120
+
121
+ package_version = Gem.loaded_specs['google-cloud-text_to_speech'].version.version
122
+
123
+ google_api_client = "gl-ruby/#{RUBY_VERSION}"
124
+ google_api_client << " #{lib_name}/#{lib_version}" if lib_name
125
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
126
+ google_api_client << " grpc/#{GRPC::VERSION}"
127
+ google_api_client.freeze
128
+
129
+ headers = { :"x-goog-api-client" => google_api_client }
130
+ headers.merge!(metadata) unless metadata.nil?
131
+ client_config_file = Pathname.new(__dir__).join(
132
+ "text_to_speech_client_config.json"
133
+ )
134
+ defaults = client_config_file.open do |f|
135
+ Google::Gax.construct_settings(
136
+ "google.cloud.texttospeech.v1.TextToSpeech",
137
+ JSON.parse(f.read),
138
+ client_config,
139
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
140
+ timeout,
141
+ errors: Google::Gax::Grpc::API_ERRORS,
142
+ metadata: headers
143
+ )
144
+ end
145
+
146
+ # Allow overriding the service path/port in subclasses.
147
+ service_path = self.class::SERVICE_ADDRESS
148
+ port = self.class::DEFAULT_SERVICE_PORT
149
+ interceptors = self.class::GRPC_INTERCEPTORS
150
+ @text_to_speech_stub = Google::Gax::Grpc.create_stub(
151
+ service_path,
152
+ port,
153
+ chan_creds: chan_creds,
154
+ channel: channel,
155
+ updater_proc: updater_proc,
156
+ scopes: scopes,
157
+ interceptors: interceptors,
158
+ &Google::Cloud::Texttospeech::V1::TextToSpeech::Stub.method(:new)
159
+ )
160
+
161
+ @list_voices = Google::Gax.create_api_call(
162
+ @text_to_speech_stub.method(:list_voices),
163
+ defaults["list_voices"],
164
+ exception_transformer: exception_transformer
165
+ )
166
+ @synthesize_speech = Google::Gax.create_api_call(
167
+ @text_to_speech_stub.method(:synthesize_speech),
168
+ defaults["synthesize_speech"],
169
+ exception_transformer: exception_transformer
170
+ )
171
+ end
172
+
173
+ # Service calls
174
+
175
+ # Returns a list of {Google::Cloud::Texttospeech::V1::Voice Voice}
176
+ # supported for synthesis.
177
+ #
178
+ # @param language_code [String]
179
+ # Optional (but 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
+ # @param options [Google::Gax::CallOptions]
188
+ # Overrides the default settings for this call, e.g, timeout,
189
+ # retries, etc.
190
+ # @yield [result, operation] Access the result along with the RPC operation
191
+ # @yieldparam result [Google::Cloud::Texttospeech::V1::ListVoicesResponse]
192
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
193
+ # @return [Google::Cloud::Texttospeech::V1::ListVoicesResponse]
194
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
195
+ # @example
196
+ # require "google/cloud/text_to_speech/v1"
197
+ #
198
+ # text_to_speech_client = Google::Cloud::TextToSpeech::V1.new
199
+ # response = text_to_speech_client.list_voices
200
+
201
+ def list_voices \
202
+ language_code: nil,
203
+ options: nil,
204
+ &block
205
+ req = {
206
+ language_code: language_code
207
+ }.delete_if { |_, v| v.nil? }
208
+ req = Google::Gax::to_proto(req, Google::Cloud::Texttospeech::V1::ListVoicesRequest)
209
+ @list_voices.call(req, options, &block)
210
+ end
211
+
212
+ # Synthesizes speech synchronously: receive results after all text input
213
+ # has been processed.
214
+ #
215
+ # @param input [Google::Cloud::Texttospeech::V1::SynthesisInput | Hash]
216
+ # Required. The Synthesizer requires either plain text or SSML as input.
217
+ # A hash of the same form as `Google::Cloud::Texttospeech::V1::SynthesisInput`
218
+ # can also be provided.
219
+ # @param voice [Google::Cloud::Texttospeech::V1::VoiceSelectionParams | Hash]
220
+ # Required. The desired voice of the synthesized audio.
221
+ # A hash of the same form as `Google::Cloud::Texttospeech::V1::VoiceSelectionParams`
222
+ # can also be provided.
223
+ # @param audio_config [Google::Cloud::Texttospeech::V1::AudioConfig | Hash]
224
+ # Required. The configuration of the synthesized audio.
225
+ # A hash of the same form as `Google::Cloud::Texttospeech::V1::AudioConfig`
226
+ # can also be provided.
227
+ # @param options [Google::Gax::CallOptions]
228
+ # Overrides the default settings for this call, e.g, timeout,
229
+ # retries, etc.
230
+ # @yield [result, operation] Access the result along with the RPC operation
231
+ # @yieldparam result [Google::Cloud::Texttospeech::V1::SynthesizeSpeechResponse]
232
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
233
+ # @return [Google::Cloud::Texttospeech::V1::SynthesizeSpeechResponse]
234
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
235
+ # @example
236
+ # require "google/cloud/text_to_speech/v1"
237
+ #
238
+ # text_to_speech_client = Google::Cloud::TextToSpeech::V1.new
239
+ #
240
+ # # TODO: Initialize +input+:
241
+ # input = {}
242
+ #
243
+ # # TODO: Initialize +voice+:
244
+ # voice = {}
245
+ #
246
+ # # TODO: Initialize +audio_config+:
247
+ # audio_config = {}
248
+ # response = text_to_speech_client.synthesize_speech(input, voice, audio_config)
249
+
250
+ def synthesize_speech \
251
+ input,
252
+ voice,
253
+ audio_config,
254
+ options: nil,
255
+ &block
256
+ req = {
257
+ input: input,
258
+ voice: voice,
259
+ audio_config: audio_config
260
+ }.delete_if { |_, v| v.nil? }
261
+ req = Google::Gax::to_proto(req, Google::Cloud::Texttospeech::V1::SynthesizeSpeechRequest)
262
+ @synthesize_speech.call(req, options, &block)
263
+ end
264
+ end
265
+ end
266
+ end
267
+ end
268
+ end