diff --git a/google/cloud/texttospeech_v1/services/text_to_speech/async_client.py b/google/cloud/texttospeech_v1/services/text_to_speech/async_client.py index dfb75dfb..f0c632b1 100644 --- a/google/cloud/texttospeech_v1/services/text_to_speech/async_client.py +++ b/google/cloud/texttospeech_v1/services/text_to_speech/async_client.py @@ -206,6 +206,24 @@ async def list_voices( ) -> cloud_tts.ListVoicesResponse: r"""Returns a list of Voice supported for synthesis. + .. code-block:: + + from google.cloud import texttospeech_v1 + + def sample_list_voices(): + # Create a client + client = texttospeech_v1.TextToSpeechClient() + + # Initialize request argument(s) + request = texttospeech_v1.ListVoicesRequest( + ) + + # Make the request + response = client.list_voices(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.texttospeech_v1.types.ListVoicesRequest, dict]): The request object. The top-level message sent by the @@ -281,6 +299,37 @@ async def synthesize_speech( r"""Synthesizes speech synchronously: receive results after all text input has been processed. + + .. code-block:: + + from google.cloud import texttospeech_v1 + + def sample_synthesize_speech(): + # Create a client + client = texttospeech_v1.TextToSpeechClient() + + # Initialize request argument(s) + input = texttospeech_v1.SynthesisInput() + input.text = "text_value" + + voice = texttospeech_v1.VoiceSelectionParams() + voice.language_code = "language_code_value" + + audio_config = texttospeech_v1.AudioConfig() + audio_config.audio_encoding = "ALAW" + + request = texttospeech_v1.SynthesizeSpeechRequest( + input=input, + voice=voice, + audio_config=audio_config, + ) + + # Make the request + response = client.synthesize_speech(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.texttospeech_v1.types.SynthesizeSpeechRequest, dict]): The request object. The top-level message sent by the diff --git a/google/cloud/texttospeech_v1/services/text_to_speech/client.py b/google/cloud/texttospeech_v1/services/text_to_speech/client.py index 0efab338..ebb42276 100644 --- a/google/cloud/texttospeech_v1/services/text_to_speech/client.py +++ b/google/cloud/texttospeech_v1/services/text_to_speech/client.py @@ -391,6 +391,25 @@ def list_voices( ) -> cloud_tts.ListVoicesResponse: r"""Returns a list of Voice supported for synthesis. + + .. code-block:: + + from google.cloud import texttospeech_v1 + + def sample_list_voices(): + # Create a client + client = texttospeech_v1.TextToSpeechClient() + + # Initialize request argument(s) + request = texttospeech_v1.ListVoicesRequest( + ) + + # Make the request + response = client.list_voices(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.texttospeech_v1.types.ListVoicesRequest, dict]): The request object. The top-level message sent by the @@ -466,6 +485,38 @@ def synthesize_speech( r"""Synthesizes speech synchronously: receive results after all text input has been processed. + + + .. code-block:: + + from google.cloud import texttospeech_v1 + + def sample_synthesize_speech(): + # Create a client + client = texttospeech_v1.TextToSpeechClient() + + # Initialize request argument(s) + input = texttospeech_v1.SynthesisInput() + input.text = "text_value" + + voice = texttospeech_v1.VoiceSelectionParams() + voice.language_code = "language_code_value" + + audio_config = texttospeech_v1.AudioConfig() + audio_config.audio_encoding = "ALAW" + + request = texttospeech_v1.SynthesizeSpeechRequest( + input=input, + voice=voice, + audio_config=audio_config, + ) + + # Make the request + response = client.synthesize_speech(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.texttospeech_v1.types.SynthesizeSpeechRequest, dict]): The request object. The top-level message sent by the diff --git a/google/cloud/texttospeech_v1beta1/services/text_to_speech/async_client.py b/google/cloud/texttospeech_v1beta1/services/text_to_speech/async_client.py index 5416b406..fd0cc2e4 100644 --- a/google/cloud/texttospeech_v1beta1/services/text_to_speech/async_client.py +++ b/google/cloud/texttospeech_v1beta1/services/text_to_speech/async_client.py @@ -208,6 +208,24 @@ async def list_voices( ) -> cloud_tts.ListVoicesResponse: r"""Returns a list of Voice supported for synthesis. + .. code-block:: + + from google.cloud import texttospeech_v1beta1 + + def sample_list_voices(): + # Create a client + client = texttospeech_v1beta1.TextToSpeechClient() + + # Initialize request argument(s) + request = texttospeech_v1beta1.ListVoicesRequest( + ) + + # Make the request + response = client.list_voices(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.texttospeech_v1beta1.types.ListVoicesRequest, dict]): The request object. The top-level message sent by the @@ -283,6 +301,37 @@ async def synthesize_speech( r"""Synthesizes speech synchronously: receive results after all text input has been processed. + + .. code-block:: + + from google.cloud import texttospeech_v1beta1 + + def sample_synthesize_speech(): + # Create a client + client = texttospeech_v1beta1.TextToSpeechClient() + + # Initialize request argument(s) + input = texttospeech_v1beta1.SynthesisInput() + input.text = "text_value" + + voice = texttospeech_v1beta1.VoiceSelectionParams() + voice.language_code = "language_code_value" + + audio_config = texttospeech_v1beta1.AudioConfig() + audio_config.audio_encoding = "ALAW" + + request = texttospeech_v1beta1.SynthesizeSpeechRequest( + input=input, + voice=voice, + audio_config=audio_config, + ) + + # Make the request + response = client.synthesize_speech(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.texttospeech_v1beta1.types.SynthesizeSpeechRequest, dict]): The request object. The top-level message sent by the diff --git a/google/cloud/texttospeech_v1beta1/services/text_to_speech/client.py b/google/cloud/texttospeech_v1beta1/services/text_to_speech/client.py index 7ae71148..c36baa27 100644 --- a/google/cloud/texttospeech_v1beta1/services/text_to_speech/client.py +++ b/google/cloud/texttospeech_v1beta1/services/text_to_speech/client.py @@ -407,6 +407,25 @@ def list_voices( ) -> cloud_tts.ListVoicesResponse: r"""Returns a list of Voice supported for synthesis. + + .. code-block:: + + from google.cloud import texttospeech_v1beta1 + + def sample_list_voices(): + # Create a client + client = texttospeech_v1beta1.TextToSpeechClient() + + # Initialize request argument(s) + request = texttospeech_v1beta1.ListVoicesRequest( + ) + + # Make the request + response = client.list_voices(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.texttospeech_v1beta1.types.ListVoicesRequest, dict]): The request object. The top-level message sent by the @@ -482,6 +501,38 @@ def synthesize_speech( r"""Synthesizes speech synchronously: receive results after all text input has been processed. + + + .. code-block:: + + from google.cloud import texttospeech_v1beta1 + + def sample_synthesize_speech(): + # Create a client + client = texttospeech_v1beta1.TextToSpeechClient() + + # Initialize request argument(s) + input = texttospeech_v1beta1.SynthesisInput() + input.text = "text_value" + + voice = texttospeech_v1beta1.VoiceSelectionParams() + voice.language_code = "language_code_value" + + audio_config = texttospeech_v1beta1.AudioConfig() + audio_config.audio_encoding = "ALAW" + + request = texttospeech_v1beta1.SynthesizeSpeechRequest( + input=input, + voice=voice, + audio_config=audio_config, + ) + + # Make the request + response = client.synthesize_speech(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.texttospeech_v1beta1.types.SynthesizeSpeechRequest, dict]): The request object. The top-level message sent by the diff --git a/samples/generated_samples/snippet_metadata_texttospeech_v1.json b/samples/generated_samples/snippet_metadata_texttospeech_v1.json new file mode 100644 index 00000000..66d90b41 --- /dev/null +++ b/samples/generated_samples/snippet_metadata_texttospeech_v1.json @@ -0,0 +1,182 @@ +{ + "snippets": [ + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TextToSpeech" + }, + "shortName": "ListVoices" + } + }, + "file": "texttospeech_generated_texttospeech_v1_text_to_speech_list_voices_async.py", + "regionTag": "texttospeech_generated_texttospeech_v1_TextToSpeech_ListVoices_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TextToSpeech" + }, + "shortName": "ListVoices" + } + }, + "file": "texttospeech_generated_texttospeech_v1_text_to_speech_list_voices_sync.py", + "regionTag": "texttospeech_generated_texttospeech_v1_TextToSpeech_ListVoices_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TextToSpeech" + }, + "shortName": "SynthesizeSpeech" + } + }, + "file": "texttospeech_generated_texttospeech_v1_text_to_speech_synthesize_speech_async.py", + "regionTag": "texttospeech_generated_texttospeech_v1_TextToSpeech_SynthesizeSpeech_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TextToSpeech" + }, + "shortName": "SynthesizeSpeech" + } + }, + "file": "texttospeech_generated_texttospeech_v1_text_to_speech_synthesize_speech_sync.py", + "regionTag": "texttospeech_generated_texttospeech_v1_TextToSpeech_SynthesizeSpeech_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ] + } + ] +} diff --git a/samples/generated_samples/snippet_metadata_texttospeech_v1beta1.json b/samples/generated_samples/snippet_metadata_texttospeech_v1beta1.json new file mode 100644 index 00000000..49e41e7a --- /dev/null +++ b/samples/generated_samples/snippet_metadata_texttospeech_v1beta1.json @@ -0,0 +1,182 @@ +{ + "snippets": [ + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TextToSpeech" + }, + "shortName": "ListVoices" + } + }, + "file": "texttospeech_generated_texttospeech_v1beta1_text_to_speech_list_voices_async.py", + "regionTag": "texttospeech_generated_texttospeech_v1beta1_TextToSpeech_ListVoices_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TextToSpeech" + }, + "shortName": "ListVoices" + } + }, + "file": "texttospeech_generated_texttospeech_v1beta1_text_to_speech_list_voices_sync.py", + "regionTag": "texttospeech_generated_texttospeech_v1beta1_TextToSpeech_ListVoices_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TextToSpeech" + }, + "shortName": "SynthesizeSpeech" + } + }, + "file": "texttospeech_generated_texttospeech_v1beta1_text_to_speech_synthesize_speech_async.py", + "regionTag": "texttospeech_generated_texttospeech_v1beta1_TextToSpeech_SynthesizeSpeech_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TextToSpeech" + }, + "shortName": "SynthesizeSpeech" + } + }, + "file": "texttospeech_generated_texttospeech_v1beta1_text_to_speech_synthesize_speech_sync.py", + "regionTag": "texttospeech_generated_texttospeech_v1beta1_TextToSpeech_SynthesizeSpeech_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ] + } + ] +} diff --git a/samples/generated_samples/texttospeech_generated_texttospeech_v1_text_to_speech_list_voices_async.py b/samples/generated_samples/texttospeech_generated_texttospeech_v1_text_to_speech_list_voices_async.py new file mode 100644 index 00000000..e3ba1782 --- /dev/null +++ b/samples/generated_samples/texttospeech_generated_texttospeech_v1_text_to_speech_list_voices_async.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListVoices +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-texttospeech + + +# [START texttospeech_generated_texttospeech_v1_TextToSpeech_ListVoices_async] +from google.cloud import texttospeech_v1 + + +async def sample_list_voices(): + # Create a client + client = texttospeech_v1.TextToSpeechAsyncClient() + + # Initialize request argument(s) + request = texttospeech_v1.ListVoicesRequest( + ) + + # Make the request + response = await client.list_voices(request=request) + + # Handle the response + print(response) + +# [END texttospeech_generated_texttospeech_v1_TextToSpeech_ListVoices_async] diff --git a/samples/generated_samples/texttospeech_generated_texttospeech_v1_text_to_speech_list_voices_sync.py b/samples/generated_samples/texttospeech_generated_texttospeech_v1_text_to_speech_list_voices_sync.py new file mode 100644 index 00000000..e222043f --- /dev/null +++ b/samples/generated_samples/texttospeech_generated_texttospeech_v1_text_to_speech_list_voices_sync.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListVoices +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-texttospeech + + +# [START texttospeech_generated_texttospeech_v1_TextToSpeech_ListVoices_sync] +from google.cloud import texttospeech_v1 + + +def sample_list_voices(): + # Create a client + client = texttospeech_v1.TextToSpeechClient() + + # Initialize request argument(s) + request = texttospeech_v1.ListVoicesRequest( + ) + + # Make the request + response = client.list_voices(request=request) + + # Handle the response + print(response) + +# [END texttospeech_generated_texttospeech_v1_TextToSpeech_ListVoices_sync] diff --git a/samples/generated_samples/texttospeech_generated_texttospeech_v1_text_to_speech_synthesize_speech_async.py b/samples/generated_samples/texttospeech_generated_texttospeech_v1_text_to_speech_synthesize_speech_async.py new file mode 100644 index 00000000..8133ef39 --- /dev/null +++ b/samples/generated_samples/texttospeech_generated_texttospeech_v1_text_to_speech_synthesize_speech_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SynthesizeSpeech +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-texttospeech + + +# [START texttospeech_generated_texttospeech_v1_TextToSpeech_SynthesizeSpeech_async] +from google.cloud import texttospeech_v1 + + +async def sample_synthesize_speech(): + # Create a client + client = texttospeech_v1.TextToSpeechAsyncClient() + + # Initialize request argument(s) + input = texttospeech_v1.SynthesisInput() + input.text = "text_value" + + voice = texttospeech_v1.VoiceSelectionParams() + voice.language_code = "language_code_value" + + audio_config = texttospeech_v1.AudioConfig() + audio_config.audio_encoding = "ALAW" + + request = texttospeech_v1.SynthesizeSpeechRequest( + input=input, + voice=voice, + audio_config=audio_config, + ) + + # Make the request + response = await client.synthesize_speech(request=request) + + # Handle the response + print(response) + +# [END texttospeech_generated_texttospeech_v1_TextToSpeech_SynthesizeSpeech_async] diff --git a/samples/generated_samples/texttospeech_generated_texttospeech_v1_text_to_speech_synthesize_speech_sync.py b/samples/generated_samples/texttospeech_generated_texttospeech_v1_text_to_speech_synthesize_speech_sync.py new file mode 100644 index 00000000..d3e06332 --- /dev/null +++ b/samples/generated_samples/texttospeech_generated_texttospeech_v1_text_to_speech_synthesize_speech_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SynthesizeSpeech +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-texttospeech + + +# [START texttospeech_generated_texttospeech_v1_TextToSpeech_SynthesizeSpeech_sync] +from google.cloud import texttospeech_v1 + + +def sample_synthesize_speech(): + # Create a client + client = texttospeech_v1.TextToSpeechClient() + + # Initialize request argument(s) + input = texttospeech_v1.SynthesisInput() + input.text = "text_value" + + voice = texttospeech_v1.VoiceSelectionParams() + voice.language_code = "language_code_value" + + audio_config = texttospeech_v1.AudioConfig() + audio_config.audio_encoding = "ALAW" + + request = texttospeech_v1.SynthesizeSpeechRequest( + input=input, + voice=voice, + audio_config=audio_config, + ) + + # Make the request + response = client.synthesize_speech(request=request) + + # Handle the response + print(response) + +# [END texttospeech_generated_texttospeech_v1_TextToSpeech_SynthesizeSpeech_sync] diff --git a/samples/generated_samples/texttospeech_generated_texttospeech_v1beta1_text_to_speech_list_voices_async.py b/samples/generated_samples/texttospeech_generated_texttospeech_v1beta1_text_to_speech_list_voices_async.py new file mode 100644 index 00000000..e5d462b1 --- /dev/null +++ b/samples/generated_samples/texttospeech_generated_texttospeech_v1beta1_text_to_speech_list_voices_async.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListVoices +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-texttospeech + + +# [START texttospeech_generated_texttospeech_v1beta1_TextToSpeech_ListVoices_async] +from google.cloud import texttospeech_v1beta1 + + +async def sample_list_voices(): + # Create a client + client = texttospeech_v1beta1.TextToSpeechAsyncClient() + + # Initialize request argument(s) + request = texttospeech_v1beta1.ListVoicesRequest( + ) + + # Make the request + response = await client.list_voices(request=request) + + # Handle the response + print(response) + +# [END texttospeech_generated_texttospeech_v1beta1_TextToSpeech_ListVoices_async] diff --git a/samples/generated_samples/texttospeech_generated_texttospeech_v1beta1_text_to_speech_list_voices_sync.py b/samples/generated_samples/texttospeech_generated_texttospeech_v1beta1_text_to_speech_list_voices_sync.py new file mode 100644 index 00000000..f07d5433 --- /dev/null +++ b/samples/generated_samples/texttospeech_generated_texttospeech_v1beta1_text_to_speech_list_voices_sync.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListVoices +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-texttospeech + + +# [START texttospeech_generated_texttospeech_v1beta1_TextToSpeech_ListVoices_sync] +from google.cloud import texttospeech_v1beta1 + + +def sample_list_voices(): + # Create a client + client = texttospeech_v1beta1.TextToSpeechClient() + + # Initialize request argument(s) + request = texttospeech_v1beta1.ListVoicesRequest( + ) + + # Make the request + response = client.list_voices(request=request) + + # Handle the response + print(response) + +# [END texttospeech_generated_texttospeech_v1beta1_TextToSpeech_ListVoices_sync] diff --git a/samples/generated_samples/texttospeech_generated_texttospeech_v1beta1_text_to_speech_synthesize_speech_async.py b/samples/generated_samples/texttospeech_generated_texttospeech_v1beta1_text_to_speech_synthesize_speech_async.py new file mode 100644 index 00000000..dd21162a --- /dev/null +++ b/samples/generated_samples/texttospeech_generated_texttospeech_v1beta1_text_to_speech_synthesize_speech_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SynthesizeSpeech +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-texttospeech + + +# [START texttospeech_generated_texttospeech_v1beta1_TextToSpeech_SynthesizeSpeech_async] +from google.cloud import texttospeech_v1beta1 + + +async def sample_synthesize_speech(): + # Create a client + client = texttospeech_v1beta1.TextToSpeechAsyncClient() + + # Initialize request argument(s) + input = texttospeech_v1beta1.SynthesisInput() + input.text = "text_value" + + voice = texttospeech_v1beta1.VoiceSelectionParams() + voice.language_code = "language_code_value" + + audio_config = texttospeech_v1beta1.AudioConfig() + audio_config.audio_encoding = "ALAW" + + request = texttospeech_v1beta1.SynthesizeSpeechRequest( + input=input, + voice=voice, + audio_config=audio_config, + ) + + # Make the request + response = await client.synthesize_speech(request=request) + + # Handle the response + print(response) + +# [END texttospeech_generated_texttospeech_v1beta1_TextToSpeech_SynthesizeSpeech_async] diff --git a/samples/generated_samples/texttospeech_generated_texttospeech_v1beta1_text_to_speech_synthesize_speech_sync.py b/samples/generated_samples/texttospeech_generated_texttospeech_v1beta1_text_to_speech_synthesize_speech_sync.py new file mode 100644 index 00000000..16173493 --- /dev/null +++ b/samples/generated_samples/texttospeech_generated_texttospeech_v1beta1_text_to_speech_synthesize_speech_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SynthesizeSpeech +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-texttospeech + + +# [START texttospeech_generated_texttospeech_v1beta1_TextToSpeech_SynthesizeSpeech_sync] +from google.cloud import texttospeech_v1beta1 + + +def sample_synthesize_speech(): + # Create a client + client = texttospeech_v1beta1.TextToSpeechClient() + + # Initialize request argument(s) + input = texttospeech_v1beta1.SynthesisInput() + input.text = "text_value" + + voice = texttospeech_v1beta1.VoiceSelectionParams() + voice.language_code = "language_code_value" + + audio_config = texttospeech_v1beta1.AudioConfig() + audio_config.audio_encoding = "ALAW" + + request = texttospeech_v1beta1.SynthesizeSpeechRequest( + input=input, + voice=voice, + audio_config=audio_config, + ) + + # Make the request + response = client.synthesize_speech(request=request) + + # Handle the response + print(response) + +# [END texttospeech_generated_texttospeech_v1beta1_TextToSpeech_SynthesizeSpeech_sync]