feat!: regenerate with microgenerator #30
Changes from 14 commits
db28a44
a40dbfe
b28186f
c931646
e7d1a19
bb549ce
c1bc992
aa9f5a2
6f971b7
36a17cc
813736a
4f034dd
589de3e
182452b
0a205e4
b5c8f53
1f41343
4906ae3
b265df8
3d69b6c
35ec4c0
9130109
036d284
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# 2.0.0 Migration Guide | ||
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this script included in this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes: 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"}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be good to emphasize that the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../UPGRADING.md |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Client for Google Cloud Texttospeech API | ||
======================================== | ||
|
||
.. automodule:: google.cloud.texttospeech_v1 | ||
:members: | ||
:inherited-members: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Types for Google Cloud Texttospeech API | ||
======================================= | ||
|
||
.. automodule:: google.cloud.texttospeech_v1.types | ||
:members: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Client for Google Cloud Texttospeech API | ||
======================================== | ||
|
||
.. automodule:: google.cloud.texttospeech_v1beta1 | ||
:members: | ||
:inherited-members: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Types for Google Cloud Texttospeech API | ||
======================================= | ||
|
||
.. automodule:: google.cloud.texttospeech_v1beta1.types | ||
:members: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Marker file for PEP 561. | ||
# The google-cloud-texttospeech package uses inline types. |
There was a problem hiding this comment.
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