This repository has been archived by the owner on Sep 5, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
55a75a9
commit 17cc6bb
Showing
5 changed files
with
288 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...d_mediatranslation_v1beta1_speech_translation_service_streaming_translate_speech_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# -*- 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. | ||
# | ||
# Generated code. DO NOT EDIT! | ||
# | ||
# Snippet for StreamingTranslateSpeech | ||
# NOTE: This snippet has been automatically generated for illustrative purposes only. | ||
# It may require modifications to work in your environment. | ||
|
||
# To install the latest published package dependency, execute the following: | ||
# python3 -m pip install google-cloud-media-translation | ||
|
||
|
||
# [START mediatranslation_generated_mediatranslation_v1beta1_SpeechTranslationService_StreamingTranslateSpeech_async] | ||
from google.cloud import mediatranslation_v1beta1 | ||
|
||
|
||
async def sample_streaming_translate_speech(): | ||
# Create a client | ||
client = mediatranslation_v1beta1.SpeechTranslationServiceAsyncClient() | ||
|
||
# Initialize request argument(s) | ||
streaming_config = mediatranslation_v1beta1.StreamingTranslateSpeechConfig() | ||
streaming_config.audio_config.audio_encoding = "audio_encoding_value" | ||
streaming_config.audio_config.source_language_code = "source_language_code_value" | ||
streaming_config.audio_config.target_language_code = "target_language_code_value" | ||
|
||
request = mediatranslation_v1beta1.StreamingTranslateSpeechRequest( | ||
streaming_config=streaming_config, | ||
) | ||
|
||
# This method expects an iterator which contains | ||
# 'mediatranslation_v1beta1.StreamingTranslateSpeechRequest' 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 = await client.streaming_translate_speech(requests=request_generator()) | ||
|
||
# Handle the response | ||
async for response in stream: | ||
print(response) | ||
|
||
# [END mediatranslation_generated_mediatranslation_v1beta1_SpeechTranslationService_StreamingTranslateSpeech_async] |
61 changes: 61 additions & 0 deletions
61
...ed_mediatranslation_v1beta1_speech_translation_service_streaming_translate_speech_sync.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# -*- 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. | ||
# | ||
# Generated code. DO NOT EDIT! | ||
# | ||
# Snippet for StreamingTranslateSpeech | ||
# NOTE: This snippet has been automatically generated for illustrative purposes only. | ||
# It may require modifications to work in your environment. | ||
|
||
# To install the latest published package dependency, execute the following: | ||
# python3 -m pip install google-cloud-media-translation | ||
|
||
|
||
# [START mediatranslation_generated_mediatranslation_v1beta1_SpeechTranslationService_StreamingTranslateSpeech_sync] | ||
from google.cloud import mediatranslation_v1beta1 | ||
|
||
|
||
def sample_streaming_translate_speech(): | ||
# Create a client | ||
client = mediatranslation_v1beta1.SpeechTranslationServiceClient() | ||
|
||
# Initialize request argument(s) | ||
streaming_config = mediatranslation_v1beta1.StreamingTranslateSpeechConfig() | ||
streaming_config.audio_config.audio_encoding = "audio_encoding_value" | ||
streaming_config.audio_config.source_language_code = "source_language_code_value" | ||
streaming_config.audio_config.target_language_code = "target_language_code_value" | ||
|
||
request = mediatranslation_v1beta1.StreamingTranslateSpeechRequest( | ||
streaming_config=streaming_config, | ||
) | ||
|
||
# This method expects an iterator which contains | ||
# 'mediatranslation_v1beta1.StreamingTranslateSpeechRequest' 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_translate_speech(requests=request_generator()) | ||
|
||
# Handle the response | ||
for response in stream: | ||
print(response) | ||
|
||
# [END mediatranslation_generated_mediatranslation_v1beta1_SpeechTranslationService_StreamingTranslateSpeech_sync] |
93 changes: 93 additions & 0 deletions
93
samples/generated_samples/snippet_metadata_mediatranslation_v1beta1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
{ | ||
"snippets": [ | ||
{ | ||
"clientMethod": { | ||
"async": true, | ||
"method": { | ||
"service": { | ||
"shortName": "SpeechTranslationService" | ||
}, | ||
"shortName": "StreamingTranslateSpeech" | ||
} | ||
}, | ||
"file": "mediatranslation_generated_mediatranslation_v1beta1_speech_translation_service_streaming_translate_speech_async.py", | ||
"regionTag": "mediatranslation_generated_mediatranslation_v1beta1_SpeechTranslationService_StreamingTranslateSpeech_async", | ||
"segments": [ | ||
{ | ||
"end": 60, | ||
"start": 27, | ||
"type": "FULL" | ||
}, | ||
{ | ||
"end": 60, | ||
"start": 27, | ||
"type": "SHORT" | ||
}, | ||
{ | ||
"end": 33, | ||
"start": 31, | ||
"type": "CLIENT_INITIALIZATION" | ||
}, | ||
{ | ||
"end": 53, | ||
"start": 34, | ||
"type": "REQUEST_INITIALIZATION" | ||
}, | ||
{ | ||
"end": 56, | ||
"start": 54, | ||
"type": "REQUEST_EXECUTION" | ||
}, | ||
{ | ||
"end": 61, | ||
"start": 57, | ||
"type": "RESPONSE_HANDLING" | ||
} | ||
] | ||
}, | ||
{ | ||
"clientMethod": { | ||
"method": { | ||
"service": { | ||
"shortName": "SpeechTranslationService" | ||
}, | ||
"shortName": "StreamingTranslateSpeech" | ||
} | ||
}, | ||
"file": "mediatranslation_generated_mediatranslation_v1beta1_speech_translation_service_streaming_translate_speech_sync.py", | ||
"regionTag": "mediatranslation_generated_mediatranslation_v1beta1_SpeechTranslationService_StreamingTranslateSpeech_sync", | ||
"segments": [ | ||
{ | ||
"end": 60, | ||
"start": 27, | ||
"type": "FULL" | ||
}, | ||
{ | ||
"end": 60, | ||
"start": 27, | ||
"type": "SHORT" | ||
}, | ||
{ | ||
"end": 33, | ||
"start": 31, | ||
"type": "CLIENT_INITIALIZATION" | ||
}, | ||
{ | ||
"end": 53, | ||
"start": 34, | ||
"type": "REQUEST_INITIALIZATION" | ||
}, | ||
{ | ||
"end": 56, | ||
"start": 54, | ||
"type": "REQUEST_EXECUTION" | ||
}, | ||
{ | ||
"end": 61, | ||
"start": 57, | ||
"type": "RESPONSE_HANDLING" | ||
} | ||
] | ||
} | ||
] | ||
} |