Skip to content

Commit

Permalink
docs: add generated snippets (#321)
Browse files Browse the repository at this point in the history
* chore: use gapic-generator-python 0.63.2
docs: add generated snippets

PiperOrigin-RevId: 427792504

Source-Link: googleapis/googleapis@55b9e1e

Source-Link: googleapis/googleapis-gen@bf4e86b
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYmY0ZTg2Yjc1M2Y0MmNiMGVkYjFmZDUxZmJlODQwZDdkYTBhMWNkZSJ9

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Feb 11, 2022
1 parent 0198889 commit 70f0255
Show file tree
Hide file tree
Showing 6 changed files with 758 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,33 @@ async def recognize(
r"""Performs synchronous speech recognition: receive
results after all audio has been sent and processed.
.. code-block::
from google.cloud import speech_v1
def sample_recognize():
# Create a client
client = speech_v1.SpeechClient()
# Initialize request argument(s)
config = speech_v1.RecognitionConfig()
config.language_code = "language_code_value"
audio = speech_v1.RecognitionAudio()
audio.content = b'content_blob'
request = speech_v1.RecognizeRequest(
config=config,
audio=audio,
)
# Make the request
response = client.recognize(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.speech_v1.types.RecognizeRequest, dict]):
The request object. The top-level message sent by the
Expand Down Expand Up @@ -312,6 +339,37 @@ async def long_running_recognize(
on asynchronous speech recognition, see the
`how-to <https://cloud.google.com/speech-to-text/docs/async-recognize>`__.
.. code-block::
from google.cloud import speech_v1
def sample_long_running_recognize():
# Create a client
client = speech_v1.SpeechClient()
# Initialize request argument(s)
config = speech_v1.RecognitionConfig()
config.language_code = "language_code_value"
audio = speech_v1.RecognitionAudio()
audio.content = b'content_blob'
request = speech_v1.LongRunningRecognizeRequest(
config=config,
audio=audio,
)
# Make the request
operation = client.long_running_recognize(request=request)
print("Waiting for operation to complete...")
response = operation.result()
# Handle the response
print(response)
Args:
request (Union[google.cloud.speech_v1.types.LongRunningRecognizeRequest, dict]):
The request object. The top-level message sent by the
Expand Down Expand Up @@ -402,6 +460,40 @@ def streaming_recognize(
receive results while sending audio. This method is only
available via the gRPC API (not REST).
.. code-block::
from google.cloud import speech_v1
def sample_streaming_recognize():
# Create a client
client = speech_v1.SpeechClient()
# Initialize request argument(s)
streaming_config = speech_v1.StreamingRecognitionConfig()
streaming_config.config.language_code = "language_code_value"
request = speech_v1.StreamingRecognizeRequest(
streaming_config=streaming_config,
)
# This method expects an iterator which contains
# 'speech_v1.StreamingRecognizeRequest' objects
# Here we create a generator that yields a single `request` for
# demonstrative purposes.
requests = [request]
def request_generator():
for request in requests:
yield request
# Make the request
stream = client.streaming_recognize(requests=request_generator())
# Handle the response
for response in stream:
print(response)
Args:
requests (AsyncIterator[`google.cloud.speech_v1.types.StreamingRecognizeRequest`]):
The request object AsyncIterator. The top-level message sent by the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,34 @@ def recognize(
r"""Performs synchronous speech recognition: receive
results after all audio has been sent and processed.
.. code-block::
from google.cloud import speech_v1
def sample_recognize():
# Create a client
client = speech_v1.SpeechClient()
# Initialize request argument(s)
config = speech_v1.RecognitionConfig()
config.language_code = "language_code_value"
audio = speech_v1.RecognitionAudio()
audio.content = b'content_blob'
request = speech_v1.RecognizeRequest(
config=config,
audio=audio,
)
# Make the request
response = client.recognize(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.speech_v1.types.RecognizeRequest, dict]):
The request object. The top-level message sent by the
Expand Down Expand Up @@ -511,6 +539,38 @@ def long_running_recognize(
on asynchronous speech recognition, see the
`how-to <https://cloud.google.com/speech-to-text/docs/async-recognize>`__.
.. code-block::
from google.cloud import speech_v1
def sample_long_running_recognize():
# Create a client
client = speech_v1.SpeechClient()
# Initialize request argument(s)
config = speech_v1.RecognitionConfig()
config.language_code = "language_code_value"
audio = speech_v1.RecognitionAudio()
audio.content = b'content_blob'
request = speech_v1.LongRunningRecognizeRequest(
config=config,
audio=audio,
)
# Make the request
operation = client.long_running_recognize(request=request)
print("Waiting for operation to complete...")
response = operation.result()
# Handle the response
print(response)
Args:
request (Union[google.cloud.speech_v1.types.LongRunningRecognizeRequest, dict]):
The request object. The top-level message sent by the
Expand Down Expand Up @@ -601,6 +661,41 @@ def streaming_recognize(
receive results while sending audio. This method is only
available via the gRPC API (not REST).
.. code-block::
from google.cloud import speech_v1
def sample_streaming_recognize():
# Create a client
client = speech_v1.SpeechClient()
# Initialize request argument(s)
streaming_config = speech_v1.StreamingRecognitionConfig()
streaming_config.config.language_code = "language_code_value"
request = speech_v1.StreamingRecognizeRequest(
streaming_config=streaming_config,
)
# This method expects an iterator which contains
# 'speech_v1.StreamingRecognizeRequest' objects
# Here we create a generator that yields a single `request` for
# demonstrative purposes.
requests = [request]
def request_generator():
for request in requests:
yield request
# Make the request
stream = client.streaming_recognize(requests=request_generator())
# Handle the response
for response in stream:
print(response)
Args:
requests (Iterator[google.cloud.speech_v1.types.StreamingRecognizeRequest]):
The request object iterator. The top-level message sent by the
Expand Down
Loading

0 comments on commit 70f0255

Please sign in to comment.