Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
Merge branch 'main' into delete-owlbot-py
Browse files Browse the repository at this point in the history
  • Loading branch information
nicain authored Nov 6, 2021
2 parents 57e7dfe + 18c42ab commit aec8418
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 259 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@

[1]: https://pypi.org/project/google-cloud-texttospeech/#history

### [2.7.1](https://www.github.com/googleapis/python-texttospeech/compare/v2.7.0...v2.7.1) (2021-11-01)


### Bug Fixes

* **deps:** drop packaging dependency ([99ac70b](https://www.github.com/googleapis/python-texttospeech/commit/99ac70ba45d7c500d0f19a30dead060c0db4453c))
* **deps:** require google-api-core >= 1.28.0 ([99ac70b](https://www.github.com/googleapis/python-texttospeech/commit/99ac70ba45d7c500d0f19a30dead060c0db4453c))


### Documentation

* list oneofs in docstring ([99ac70b](https://www.github.com/googleapis/python-texttospeech/commit/99ac70ba45d7c500d0f19a30dead060c0db4453c))

## [2.7.0](https://www.github.com/googleapis/python-texttospeech/compare/v2.6.0...v2.7.0) (2021-10-18)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
from typing import Dict, Sequence, Tuple, Type, Union
import pkg_resources

import google.api_core.client_options as ClientOptions # type: ignore
from google.api_core.client_options import ClientOptions # type: ignore
from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.cloud.texttospeech_v1.types import cloud_tts
from .transports.base import TextToSpeechTransport, DEFAULT_CLIENT_INFO
from .transports.grpc_asyncio import TextToSpeechGrpcAsyncIOTransport
Expand Down Expand Up @@ -156,17 +158,17 @@ def __init__(

async def list_voices(
self,
request: cloud_tts.ListVoicesRequest = None,
request: Union[cloud_tts.ListVoicesRequest, dict] = None,
*,
language_code: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_tts.ListVoicesResponse:
r"""Returns a list of Voice supported for synthesis.
Args:
request (:class:`google.cloud.texttospeech_v1.types.ListVoicesRequest`):
request (Union[google.cloud.texttospeech_v1.types.ListVoicesRequest, dict]):
The request object. The top-level message sent by the
client for the `ListVoices` method.
language_code (:class:`str`):
Expand Down Expand Up @@ -239,20 +241,20 @@ async def list_voices(

async def synthesize_speech(
self,
request: cloud_tts.SynthesizeSpeechRequest = None,
request: Union[cloud_tts.SynthesizeSpeechRequest, dict] = None,
*,
input: cloud_tts.SynthesisInput = None,
voice: cloud_tts.VoiceSelectionParams = None,
audio_config: cloud_tts.AudioConfig = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_tts.SynthesizeSpeechResponse:
r"""Synthesizes speech synchronously: receive results
after all text input has been processed.
Args:
request (:class:`google.cloud.texttospeech_v1.types.SynthesizeSpeechRequest`):
request (Union[google.cloud.texttospeech_v1.types.SynthesizeSpeechRequest, dict]):
The request object. The top-level message sent by the
client for the `SynthesizeSpeech` method.
input (:class:`google.cloud.texttospeech_v1.types.SynthesisInput`):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.cloud.texttospeech_v1.types import cloud_tts
from .transports.base import TextToSpeechTransport, DEFAULT_CLIENT_INFO
from .transports.grpc import TextToSpeechGrpcTransport
Expand Down Expand Up @@ -333,7 +335,7 @@ def list_voices(
request: Union[cloud_tts.ListVoicesRequest, dict] = None,
*,
language_code: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_tts.ListVoicesResponse:
Expand Down Expand Up @@ -408,7 +410,7 @@ def synthesize_speech(
input: cloud_tts.SynthesisInput = None,
voice: cloud_tts.VoiceSelectionParams = None,
audio_config: cloud_tts.AudioConfig = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_tts.SynthesizeSpeechResponse:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#
import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
import packaging.version
import pkg_resources

import google.auth # type: ignore
Expand All @@ -37,15 +36,6 @@
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()

try:
# google.auth.__version__ was added in 1.26.0
_GOOGLE_AUTH_VERSION = google.auth.__version__
except AttributeError:
try: # try pkg_resources if it is available
_GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None


class TextToSpeechTransport(abc.ABC):
"""Abstract transport class for TextToSpeech."""
Expand Down Expand Up @@ -95,7 +85,7 @@ def __init__(
host += ":443"
self._host = host

scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}

# Save the scopes.
self._scopes = scopes
Expand Down Expand Up @@ -128,29 +118,6 @@ def __init__(
# Save the credentials.
self._credentials = credentials

# TODO(busunkim): This method is in the base transport
# to avoid duplicating code across the transport classes. These functions
# should be deleted once the minimum required versions of google-auth is increased.

# TODO: Remove this function once google-auth >= 1.25.0 is required
@classmethod
def _get_scopes_kwargs(
cls, host: str, scopes: Optional[Sequence[str]]
) -> Dict[str, Optional[Sequence[str]]]:
"""Returns scopes kwargs to pass to google-auth methods depending on the google-auth version"""

scopes_kwargs = {}

if _GOOGLE_AUTH_VERSION and (
packaging.version.parse(_GOOGLE_AUTH_VERSION)
>= packaging.version.parse("1.25.0")
):
scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES}
else:
scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES}

return scopes_kwargs

def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from google.api_core import grpc_helpers_async # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
import packaging.version

import grpc # type: ignore
from grpc.experimental import aio # type: ignore
Expand Down
9 changes: 9 additions & 0 deletions google/cloud/texttospeech_v1/types/cloud_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,24 @@ class SynthesisInput(proto.Message):
[google.rpc.Code.INVALID_ARGUMENT][]. The input size is limited to
5000 characters.
This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
text (str):
The raw text to be synthesized.
This field is a member of `oneof`_ ``input_source``.
ssml (str):
The SSML document to be synthesized. The SSML document must
be valid and well-formed. Otherwise the RPC will fail and
return [google.rpc.Code.INVALID_ARGUMENT][]. For more
information, see
`SSML <https://cloud.google.com/text-to-speech/docs/ssml>`__.
This field is a member of `oneof`_ ``input_source``.
"""

text = proto.Field(proto.STRING, number=1, oneof="input_source",)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
from typing import Dict, Sequence, Tuple, Type, Union
import pkg_resources

import google.api_core.client_options as ClientOptions # type: ignore
from google.api_core.client_options import ClientOptions # type: ignore
from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.cloud.texttospeech_v1beta1.types import cloud_tts
from .transports.base import TextToSpeechTransport, DEFAULT_CLIENT_INFO
from .transports.grpc_asyncio import TextToSpeechGrpcAsyncIOTransport
Expand Down Expand Up @@ -156,17 +158,17 @@ def __init__(

async def list_voices(
self,
request: cloud_tts.ListVoicesRequest = None,
request: Union[cloud_tts.ListVoicesRequest, dict] = None,
*,
language_code: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_tts.ListVoicesResponse:
r"""Returns a list of Voice supported for synthesis.
Args:
request (:class:`google.cloud.texttospeech_v1beta1.types.ListVoicesRequest`):
request (Union[google.cloud.texttospeech_v1beta1.types.ListVoicesRequest, dict]):
The request object. The top-level message sent by the
client for the `ListVoices` method.
language_code (:class:`str`):
Expand Down Expand Up @@ -230,20 +232,20 @@ async def list_voices(

async def synthesize_speech(
self,
request: cloud_tts.SynthesizeSpeechRequest = None,
request: Union[cloud_tts.SynthesizeSpeechRequest, dict] = None,
*,
input: cloud_tts.SynthesisInput = None,
voice: cloud_tts.VoiceSelectionParams = None,
audio_config: cloud_tts.AudioConfig = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_tts.SynthesizeSpeechResponse:
r"""Synthesizes speech synchronously: receive results
after all text input has been processed.
Args:
request (:class:`google.cloud.texttospeech_v1beta1.types.SynthesizeSpeechRequest`):
request (Union[google.cloud.texttospeech_v1beta1.types.SynthesizeSpeechRequest, dict]):
The request object. The top-level message sent by the
client for the `SynthesizeSpeech` method.
input (:class:`google.cloud.texttospeech_v1beta1.types.SynthesisInput`):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.cloud.texttospeech_v1beta1.types import cloud_tts
from .transports.base import TextToSpeechTransport, DEFAULT_CLIENT_INFO
from .transports.grpc import TextToSpeechGrpcTransport
Expand Down Expand Up @@ -333,7 +335,7 @@ def list_voices(
request: Union[cloud_tts.ListVoicesRequest, dict] = None,
*,
language_code: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_tts.ListVoicesResponse:
Expand Down Expand Up @@ -409,7 +411,7 @@ def synthesize_speech(
input: cloud_tts.SynthesisInput = None,
voice: cloud_tts.VoiceSelectionParams = None,
audio_config: cloud_tts.AudioConfig = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_tts.SynthesizeSpeechResponse:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#
import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
import packaging.version
import pkg_resources

import google.auth # type: ignore
Expand All @@ -37,15 +36,6 @@
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()

try:
# google.auth.__version__ was added in 1.26.0
_GOOGLE_AUTH_VERSION = google.auth.__version__
except AttributeError:
try: # try pkg_resources if it is available
_GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None


class TextToSpeechTransport(abc.ABC):
"""Abstract transport class for TextToSpeech."""
Expand Down Expand Up @@ -95,7 +85,7 @@ def __init__(
host += ":443"
self._host = host

scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}

# Save the scopes.
self._scopes = scopes
Expand Down Expand Up @@ -128,29 +118,6 @@ def __init__(
# Save the credentials.
self._credentials = credentials

# TODO(busunkim): This method is in the base transport
# to avoid duplicating code across the transport classes. These functions
# should be deleted once the minimum required versions of google-auth is increased.

# TODO: Remove this function once google-auth >= 1.25.0 is required
@classmethod
def _get_scopes_kwargs(
cls, host: str, scopes: Optional[Sequence[str]]
) -> Dict[str, Optional[Sequence[str]]]:
"""Returns scopes kwargs to pass to google-auth methods depending on the google-auth version"""

scopes_kwargs = {}

if _GOOGLE_AUTH_VERSION and (
packaging.version.parse(_GOOGLE_AUTH_VERSION)
>= packaging.version.parse("1.25.0")
):
scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES}
else:
scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES}

return scopes_kwargs

def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from google.api_core import grpc_helpers_async # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
import packaging.version

import grpc # type: ignore
from grpc.experimental import aio # type: ignore
Expand Down
9 changes: 9 additions & 0 deletions google/cloud/texttospeech_v1beta1/types/cloud_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,24 @@ class SynthesisInput(proto.Message):
[google.rpc.Code.INVALID_ARGUMENT][]. The input size is limited to
5000 characters.
This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
text (str):
The raw text to be synthesized.
This field is a member of `oneof`_ ``input_source``.
ssml (str):
The SSML document to be synthesized. The SSML document must
be valid and well-formed. Otherwise the RPC will fail and
return [google.rpc.Code.INVALID_ARGUMENT][]. For more
information, see
`SSML <https://cloud.google.com/text-to-speech/docs/ssml>`__.
This field is a member of `oneof`_ ``input_source``.
"""

text = proto.Field(proto.STRING, number=1, oneof="input_source",)
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
future==0.18.2
google-cloud-texttospeech==2.7.0
google-cloud-texttospeech==2.7.1
Loading

0 comments on commit aec8418

Please sign in to comment.