Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

feat(v1p1beta1): support Model Adaptation #104

Merged
merged 2 commits into from Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 1 addition & 18 deletions .coveragerc
@@ -1,20 +1,3 @@
# -*- 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
#
# https://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 by synthtool. DO NOT EDIT!
[run]
branch = True

Expand All @@ -32,4 +15,4 @@ exclude_lines =
# This is added at the module level as a safeguard for if someone
# generates the code and tries to run it without pip installing. This
# makes it virtually impossible to test properly.
except pkg_resources.DistributionNotFound
except pkg_resources.DistributionNotFound
6 changes: 3 additions & 3 deletions docs/speech_v1/services.rst
@@ -1,6 +1,6 @@
Services for Google Cloud Speech v1 API
=======================================
.. toctree::
:maxdepth: 2

.. automodule:: google.cloud.speech_v1.services.speech
:members:
:inherited-members:
speech
6 changes: 6 additions & 0 deletions docs/speech_v1/speech.rst
@@ -0,0 +1,6 @@
Speech
------------------------

.. automodule:: google.cloud.speech_v1.services.speech
:members:
:inherited-members:
1 change: 1 addition & 0 deletions docs/speech_v1/types.rst
Expand Up @@ -3,4 +3,5 @@ Types for Google Cloud Speech v1 API

.. automodule:: google.cloud.speech_v1.types
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/speech_v1p1beta1/services.rst
@@ -1,6 +1,6 @@
Services for Google Cloud Speech v1p1beta1 API
==============================================
.. toctree::
:maxdepth: 2

.. automodule:: google.cloud.speech_v1p1beta1.services.speech
:members:
:inherited-members:
speech
6 changes: 6 additions & 0 deletions docs/speech_v1p1beta1/speech.rst
@@ -0,0 +1,6 @@
Speech
------------------------

.. automodule:: google.cloud.speech_v1p1beta1.services.speech
:members:
:inherited-members:
1 change: 1 addition & 0 deletions docs/speech_v1p1beta1/types.rst
Expand Up @@ -3,4 +3,5 @@ Types for Google Cloud Speech v1p1beta1 API

.. automodule:: google.cloud.speech_v1p1beta1.types
:members:
:undoc-members:
:show-inheritance:
165 changes: 84 additions & 81 deletions google/cloud/speech_v1/services/speech/async_client.py
Expand Up @@ -74,6 +74,7 @@ class SpeechAsyncClient:
common_location_path = staticmethod(SpeechClient.common_location_path)
parse_common_location_path = staticmethod(SpeechClient.parse_common_location_path)

from_service_account_info = SpeechClient.from_service_account_info
from_service_account_file = SpeechClient.from_service_account_file
from_service_account_json = from_service_account_file

Expand Down Expand Up @@ -152,19 +153,21 @@ async def recognize(
results after all audio has been sent and processed.

Args:
request (:class:`~.cloud_speech.RecognizeRequest`):
request (:class:`google.cloud.speech_v1.types.RecognizeRequest`):
The request object. The top-level message sent by the
client for the `Recognize` method.
config (:class:`~.cloud_speech.RecognitionConfig`):
config (:class:`google.cloud.speech_v1.types.RecognitionConfig`):
Required. Provides information to the
recognizer that specifies how to process
the request.

This corresponds to the ``config`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
audio (:class:`~.cloud_speech.RecognitionAudio`):
audio (:class:`google.cloud.speech_v1.types.RecognitionAudio`):
Required. The audio data to be
recognized.

This corresponds to the ``audio`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
Expand All @@ -176,10 +179,10 @@ async def recognize(
sent along with the request as metadata.

Returns:
~.cloud_speech.RecognizeResponse:
The only message returned to the client by the
``Recognize`` method. It contains the result as zero or
more sequential ``SpeechRecognitionResult`` messages.
google.cloud.speech_v1.types.RecognizeResponse:
The only message returned to the client by the Recognize method. It
contains the result as zero or more sequential
SpeechRecognitionResult messages.

"""
# Create or coerce a protobuf request object.
Expand Down Expand Up @@ -242,19 +245,21 @@ async def long_running_recognize(
`how-to <https://cloud.google.com/speech-to-text/docs/async-recognize>`__.

Args:
request (:class:`~.cloud_speech.LongRunningRecognizeRequest`):
request (:class:`google.cloud.speech_v1.types.LongRunningRecognizeRequest`):
The request object. The top-level message sent by the
client for the `LongRunningRecognize` method.
config (:class:`~.cloud_speech.RecognitionConfig`):
config (:class:`google.cloud.speech_v1.types.RecognitionConfig`):
Required. Provides information to the
recognizer that specifies how to process
the request.

This corresponds to the ``config`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
audio (:class:`~.cloud_speech.RecognitionAudio`):
audio (:class:`google.cloud.speech_v1.types.RecognitionAudio`):
Required. The audio data to be
recognized.

This corresponds to the ``audio`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
Expand All @@ -266,18 +271,15 @@ async def long_running_recognize(
sent along with the request as metadata.

Returns:
~.operation_async.AsyncOperation:
google.api_core.operation_async.AsyncOperation:
An object representing a long-running operation.

The result type for the operation will be
:class:``~.cloud_speech.LongRunningRecognizeResponse``:
The only message returned to the client by the
``LongRunningRecognize`` method. It contains the result
as zero or more sequential ``SpeechRecognitionResult``
messages. It is included in the ``result.response``
field of the ``Operation`` returned by the
``GetOperation`` call of the
``google::longrunning::Operations`` service.
The result type for the operation will be :class:`google.cloud.speech_v1.types.LongRunningRecognizeResponse` The only message returned to the client by the LongRunningRecognize method.
It contains the result as zero or more sequential
SpeechRecognitionResult messages. It is included in
the result.response field of the Operation returned
by the GetOperation call of the
google::longrunning::Operations service.

"""
# Create or coerce a protobuf request object.
Expand Down Expand Up @@ -335,7 +337,7 @@ def streaming_recognize(
available via the gRPC API (not REST).

Args:
requests (AsyncIterator[`~.cloud_speech.StreamingRecognizeRequest`]):
requests (AsyncIterator[`google.cloud.speech_v1.types.StreamingRecognizeRequest`]):
The request object AsyncIterator. The top-level message sent by the
client for the `StreamingRecognize` method. Multiple
`StreamingRecognizeRequest` messages are sent. The first
Expand All @@ -350,66 +352,67 @@ def streaming_recognize(
sent along with the request as metadata.

Returns:
AsyncIterable[~.cloud_speech.StreamingRecognizeResponse]:
``StreamingRecognizeResponse`` is the only message
returned to the client by ``StreamingRecognize``. A
series of zero or more ``StreamingRecognizeResponse``
messages are streamed back to the client. If there is no
recognizable audio, and ``single_utterance`` is set to
false, then no messages are streamed back to the client.

Here's an example of a series of ten
``StreamingRecognizeResponse``\ s that might be returned
while processing audio:

1. results { alternatives { transcript: "tube" }
stability: 0.01 }

2. results { alternatives { transcript: "to be a" }
stability: 0.01 }

3. results { alternatives { transcript: "to be" }
stability: 0.9 } results { alternatives { transcript:
" or not to be" } stability: 0.01 }

4. results { alternatives { transcript: "to be or not to
be" confidence: 0.92 } alternatives { transcript: "to
bee or not to bee" } is_final: true }

5. results { alternatives { transcript: " that's" }
stability: 0.01 }

6. results { alternatives { transcript: " that is" }
stability: 0.9 } results { alternatives { transcript:
" the question" } stability: 0.01 }

7. results { alternatives { transcript: " that is the
question" confidence: 0.98 } alternatives {
transcript: " that was the question" } is_final: true
}

Notes:

- Only two of the above responses #4 and #7 contain
final results; they are indicated by
``is_final: true``. Concatenating these together
generates the full transcript: "to be or not to be
that is the question".

- The others contain interim ``results``. #3 and #6
contain two interim ``results``: the first portion
has a high stability and is less likely to change;
the second portion has a low stability and is very
likely to change. A UI designer might choose to show
only high stability ``results``.

- The specific ``stability`` and ``confidence`` values
shown above are only for illustrative purposes.
Actual values may vary.

- In each response, only one of these fields will be
set: ``error``, ``speech_event_type``, or one or more
(repeated) ``results``.
AsyncIterable[google.cloud.speech_v1.types.StreamingRecognizeResponse]:
StreamingRecognizeResponse is the only message returned to the client by
StreamingRecognize. A series of zero or more
StreamingRecognizeResponse messages are streamed back
to the client. If there is no recognizable audio, and
single_utterance is set to false, then no messages
are streamed back to the client.

Here's an example of a series of ten
StreamingRecognizeResponses that might be returned
while processing audio:

1. results { alternatives { transcript: "tube" }
stability: 0.01 }
2. results { alternatives { transcript: "to be a" }
stability: 0.01 }
3. results { alternatives { transcript: "to be" }
stability: 0.9 } results { alternatives {
transcript: " or not to be" } stability: 0.01 }
4.

results { alternatives { transcript: "to be or not to be"
confidence: 0.92 }

alternatives { transcript: "to bee or not to bee" }
is_final: true }

5. results { alternatives { transcript: " that's" }
stability: 0.01 }
6. results { alternatives { transcript: " that is" }
stability: 0.9 } results { alternatives {
transcript: " the question" } stability: 0.01 }
7.

results { alternatives { transcript: " that is the question"
confidence: 0.98 }

alternatives { transcript: " that was the question" }
is_final: true }

Notes:

- Only two of the above responses #4 and #7 contain
final results; they are indicated by
is_final: true. Concatenating these together
generates the full transcript: "to be or not to be
that is the question".
- The others contain interim results. #3 and #6
contain two interim \`results`: the first portion
has a high stability and is less likely to change;
the second portion has a low stability and is very
likely to change. A UI designer might choose to
show only high stability results.
- The specific stability and confidence values shown
above are only for illustrative purposes. Actual
values may vary.
-

In each response, only one of these fields will be set:
error, speech_event_type, or one or more
(repeated) results.

"""

Expand Down