„Masz miesiąc, żeby się wyprowadzić!” — powiedziała teściowa. A mój mąż… tylko przytaknął.
Żyliśmy z Arturem razem od dwóch lat i wydawało się, iż wszystko układa się idealnie. Nie spieszyliśmy się z ślubem, mieszkaliśmy w mieszkaniu jego mamy, a ja naprawdę wierzyłam, iż miałam szczęście do teściowej. Była uprzejma, spokojna, powściągliwa. Nigdy nie wtrącała się w nasze sprawy# 3.0.0 Migration Guide
The 3.0 release of the `google-cloud-speech` client is a significant upgrade based on a [next-gen code generator](https://github.com/googleapis/gapic-generator-python), and includes substantial interface changes. Existing code written for earlier versions of this library will likely require updates to use this version. This document describes the changes that have been made, and what you need to do to update your usage.
If you experience issues or have questions, please file an [issue](https://github.com/googleapis/python-speech/issues).
## Supported Python Versions
> **WARNING**: Breaking change
The 2.0 release had supported Python 2.7 and 3.5+. 3.0 drops support for Python 2.7 and 3.5.
The lowest supported Python version is 3.6.
## Method Calls
> **WARNING**: Breaking change
Methods expect request objects. We provide a script that will convert most common use cases.
* Install the library and the `libcst` fixup tool.
“`py
python3 -m pip install google-cloud-speech libcst
“`
* The scripts `fixup_speech_v1_keywords.py` and `fixup_speech_v1p1beta1_keywords.py` are shipped with the library. It expects an input directory (with the code to convert) and an empty destination directory.
“`sh
$ fixup_speech_v1_keywords.py –input-directory .samples/ –output-directory samples/
“`
**Before:**
“`py
from google.cloud import speech
client = speech.SpeechClient()
response = client.recognize(config, audio)
“`
**After:**
“`py
from google.cloud import speech
client = speech.SpeechClient()
response = client.recognize(request={‘config’: config, ‘audio’: audio})
“`
### More Details
In `google-cloud-speech cloud_speech.RecognizeResponse:
“`
> **NOTE:** The `request` parameter and flattened keyword parameters for the API are mutually exclusive.
> Passing both will result in an error.
Both of these calls are valid:
“`py
response = client.recognize(
request={
“config”: config,
“audio”: audio,
}
)
response = client.recognize(
config=config,
audio=audio,
)
“`
This call is invalid because it mixes `request` with a keyword argument `audio`. Executing this code will result in an error.
“`py
response = client.recognize(
request={
“config”: config,
},
audio=audio,
)
“`
## Enums and Types
> **WARNING**: Breaking change
The submodules `enums` and `types` have been removed.
**Before:**
“`py
from google.cloud import speech
encoding = speech.enums.RecognitionConfig.AudioEncoding.LINEAR16
audio = speech.types.RecognitionAudio(content=content)
“`
**After:**
“`py
from google.cloud import speech
encoding = speech.RecognitionConfig.AudioEncoding.LINEAR16
audio = speech.RecognitionAudio(content=content)
“`
## Long Running Operations
Long running operations which used the `google.api_core.operation.Operation` class now use the `google.api_core.operation_async.AsyncOperation` class. The `AsyncOperation` object adds a `done()` coroutine, and removes the `metadata_type` and `response_type` properties.
The `AsyncOperation` object does not expose a constructor. To access a specific operation, clients should use the `get_operation` method on the specific client.
`AsyncOperation` has helper coroutines to wait for a response.
**Before:**
“`py
operation = client.long_running_recognize(config, audio)
operation.add_done_callback(callback)
result = operation.result()
“`
**After:**
“`py
operation = client.long_running_recognize(request={“config”: config, “audio”: audio})
operation.add_done_callback(callback)
result = await operation.result()
“`
Asynchronous examples can be found in the `samples/asyncio` directory.