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

feat!: regenerate with microgenerator #30

Merged
merged 23 commits into from Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Expand Up @@ -16,7 +16,7 @@

# Generated by synthtool. DO NOT EDIT!
[flake8]
ignore = E203, E266, E501, W503
ignore = E203, E266, E501, W503, F401, F841
exclude =
# Exclude generated code.
**/proto/**
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -10,6 +10,7 @@
dist
build
eggs
.eggs
parts
bin
var
Expand Down Expand Up @@ -49,6 +50,7 @@ bigquery/docs/generated
# Virtual environment
env/
coverage.xml
sponge_log.xml

# System test environment variables.
system_tests/local_test_setup
Expand Down
2 changes: 0 additions & 2 deletions .kokoro/publish-docs.sh
Expand Up @@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#!/bin/bash

set -eo pipefail

# Disable buffering, so that the logs stream through.
Expand Down
2 changes: 0 additions & 2 deletions .kokoro/release.sh
Expand Up @@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#!/bin/bash

set -eo pipefail

# Start the releasetool reporter
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Expand Up @@ -20,3 +20,6 @@ recursive-include google *.json *.proto
recursive-include tests *
global-exclude *.py[co]
global-exclude __pycache__

# Extras for samples
prune scripts/readme-gen
2 changes: 2 additions & 0 deletions README.rst
Expand Up @@ -56,6 +56,8 @@ Deprecated Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^
Python == 2.7. Python 2.7 support will be removed on January 1, 2020.

The last version of this library compatible with Python 2.7 is google-cloud-texttospeech==1.0.1.


Mac/Linux
^^^^^^^^^
Expand Down
134 changes: 134 additions & 0 deletions UPGRADING.md
@@ -0,0 +1,134 @@
# 2.0.0 Migration Guide
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@software-dov @telpirion Please review


The 2.0.0 release of `google-cloud-texttospeech` is based on a [new code generator](https://github.com/googleapis/gapic-generator-python) and has significant differences from the previous major release. This guide explains how to modify your code to be compatible with the latest major version of the library.

If you experience issues or have questions, please file an [issue](https://github.com/googleapis/python-texttospeech/issues).

## Supported Python Versions

> **WARNING**: Breaking change

The 2.0.0 release requires Python 3.6+.


## Method Calls

> **WARNING**: Breaking change

Methods expect request objects. We provide a script that will convert most common use cases.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this script included in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes: scripts/fixup_keywords.py is published with the library.

If you install the library it will be available on the command line. https://python-packaging.readthedocs.io/en/latest/command-line-scripts.html#the-scripts-keyword-argument


* Install the library

```py
python3 -m pip install google-cloud-text-to-speech
```

* The script `fixup_keywords.py` is shipped with the library. It expects
an input directory (with the code to convert) and an empty destination directory.

```sh
$ fixup_keywords.py --input-directory .samples/ --output-directory samples/
```

**Before:**
```py
from google.cloud import texttospeech

client = texttospeech.TextToSpeechClient()

voices = client.list_voices(language_code="no")
```


**After:**
```py
from google.cloud import texttospeech

client = texttospeech.TextToSpeechClient()

voices = client.list_voices(request={"language_code": "no"})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a significant change in behavior. You might want to updated the docs too, at least a release note.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Will follow up with the TW.

```

### More Details

In `google-cloud-texttospeech<2.0.0`, arguments required by the API were positional arguments and optional arguments were keyword arguments.

**Before:**
```py
def synthesize_speech(
self,
input_,
voice,
audio_config,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
```

In the 2.0.0 release, all methods have a single positional argument `request`.

Some methods have additional keyword only arguments. The available parameters depend on the [`google.api.method_signature` annotation](https://github.com/googleapis/googleapis/blob/master/google/cloud/texttospeech/v1/cloud_tts.proto#L53) specified by the API producer.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to emphasize that the request param and any kword only flattenings are mutually exclusive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added




**After:**
```py
def synthesize_speech(
self,
request: cloud_tts.SynthesizeSpeechRequest = None,
*,
input: cloud_tts.SynthesisInput = None,
voice: cloud_tts.VoiceSelectionParams = None,
audio_config: cloud_tts.AudioConfig = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_tts.SynthesizeSpeechResponse:
```

For this method, both of these calls are valid:

```py
response = client.synthesize_speech(
request={
"input": input_text,
"voice": voice,
"audio_config": audio_config
}
)
```

```py
response = client.synthesize_speech(
input=input_text,
voice=voice,
audio_config=audio_config
)
```


## Enums and Types


> **WARNING**: Breaking change

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above: consider updating the documentation on cloud.google.com for all breaking changes.


The submodules `enums` and `types` have been removed.

**Before:**
```py

from google.cloud import texttospeech

encoding = texttospeech.enums.AudioEncoding.MP3
voice = texttospeech.types.VoiceSelectionParams(language_code="en-US")
```


**After:**
```py
from google.cloud import texttospeech

encoding = texttospeech.AudioEncoding.MP3
voice = texttospeech.VoiceSelectionParams(language_code="en-US")
```
1 change: 1 addition & 0 deletions docs/UPGRADING.md
30 changes: 0 additions & 30 deletions docs/api.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/gapic/v1/api.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/gapic/v1/types.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/gapic/v1beta1/api.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/gapic/v1beta1/types.rst

This file was deleted.

42 changes: 35 additions & 7 deletions docs/index.rst
@@ -1,15 +1,43 @@
.. include:: README.rst

Api Reference
-------------
.. include:: multiprocessing.rst

This package includes clients for multiple versions of the Text-to-Speech
API. By default, you will get ``v1``, the latest GA version.

v1 API Reference
----------------
.. toctree::
:maxdepth: 2

Client (v1) <texttospeech_v1/services>
Types (v1) <texttospeech_v1/types>


If you are interested in beta features ahead of the latest GA, you may
opt-in to the v1.1 beta, which is spelled ``v1beta1``. In order to do this,
you will want to import from ``google.cloud.texttospeech_v1beta1`` in lieu of
``google.cloud.texttospeech``.

v1beta1 API Reference
---------------------
.. toctree::
:maxdepth: 2

Client (v1beta1) <texttospeech_v1beta1/services>
Types (v1beta1) <texttospeech_v1beta1/types>


Migration Guide
---------------

See the guide below for instructions on migrating to the 2.x release of this library.

.. toctree::
:maxdepth: 2

UPGRADING

Text-to-Speech Client API Reference <api>
Client for Cloud Text-to-Speech API (v1) <gapic/v1/api>
Types for Cloud Text-to-Speech API Client (v1) <gapic/v1/types>
Client for Cloud Text-to-Speech API (v1beta1) <gapic/v1beta1/api>
Types for Cloud Text-to-Speech API Client (v1beta1) <gapic/v1beta1/types>

Changelog
---------
Expand Down
7 changes: 7 additions & 0 deletions docs/multiprocessing.rst
@@ -0,0 +1,7 @@
.. note::

Because this client uses :mod:`grpcio` library, it is safe to
share instances across threads. In multiprocessing scenarios, the best
practice is to create client instances *after* the invocation of
:func:`os.fork` by :class:`multiprocessing.Pool` or
:class:`multiprocessing.Process`.
6 changes: 6 additions & 0 deletions docs/texttospeech_v1/services.rst
@@ -0,0 +1,6 @@
Client for Google Cloud Texttospeech API
========================================

.. automodule:: google.cloud.texttospeech_v1
:members:
:inherited-members:
5 changes: 5 additions & 0 deletions docs/texttospeech_v1/types.rst
@@ -0,0 +1,5 @@
Types for Google Cloud Texttospeech API
=======================================

.. automodule:: google.cloud.texttospeech_v1.types
:members:
6 changes: 6 additions & 0 deletions docs/texttospeech_v1beta1/services.rst
@@ -0,0 +1,6 @@
Client for Google Cloud Texttospeech API
========================================

.. automodule:: google.cloud.texttospeech_v1beta1
:members:
:inherited-members:
5 changes: 5 additions & 0 deletions docs/texttospeech_v1beta1/types.rst
@@ -0,0 +1,5 @@
Types for Google Cloud Texttospeech API
=======================================

.. automodule:: google.cloud.texttospeech_v1beta1.types
:members:
45 changes: 45 additions & 0 deletions google/cloud/texttospeech/__init__.py
@@ -0,0 +1,45 @@
# -*- 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.
#


from google.cloud.texttospeech_v1.services.text_to_speech.client import (
TextToSpeechClient,
)
from google.cloud.texttospeech_v1.types.cloud_tts import AudioConfig
from google.cloud.texttospeech_v1.types.cloud_tts import AudioEncoding
from google.cloud.texttospeech_v1.types.cloud_tts import ListVoicesRequest
from google.cloud.texttospeech_v1.types.cloud_tts import ListVoicesResponse
from google.cloud.texttospeech_v1.types.cloud_tts import SsmlVoiceGender
from google.cloud.texttospeech_v1.types.cloud_tts import SynthesisInput
from google.cloud.texttospeech_v1.types.cloud_tts import SynthesizeSpeechRequest
from google.cloud.texttospeech_v1.types.cloud_tts import SynthesizeSpeechResponse
from google.cloud.texttospeech_v1.types.cloud_tts import Voice
from google.cloud.texttospeech_v1.types.cloud_tts import VoiceSelectionParams

__all__ = (
"AudioConfig",
"AudioEncoding",
"ListVoicesRequest",
"ListVoicesResponse",
"SsmlVoiceGender",
"SynthesisInput",
"SynthesizeSpeechRequest",
"SynthesizeSpeechResponse",
"TextToSpeechClient",
"Voice",
"VoiceSelectionParams",
)
2 changes: 2 additions & 0 deletions google/cloud/texttospeech/py.typed
@@ -0,0 +1,2 @@
# Marker file for PEP 561.
# The google-cloud-texttospeech package uses inline types.