Skip to content

Commit 1be81b3

Browse files
fix: update speech imports (GoogleCloudPlatform#11278)
* created a new branch for import issue * 🦉 Updates from OwlBot post-processor 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>
1 parent 217d590 commit 1be81b3

5 files changed

Lines changed: 17 additions & 17 deletions

speech/snippets/beta_snippets_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_transcribe_multichannel_file(capsys: pytest.CaptureFixture) -> None:
7474
result = transcribe_file_with_multichannel()
7575
out, err = capsys.readouterr()
7676

77-
assert "OK Google stream stranger things from Netflix to my TV" in out
77+
assert "Okay Google stream stranger things from Netflix to my TV" in out
7878
assert result is not None
7979

8080

@@ -93,7 +93,7 @@ def test_transcribe_word_level_confidence(capsys: pytest.CaptureFixture) -> None
9393
result = transcribe_file_with_word_level_confidence()
9494
out, err = capsys.readouterr()
9595

96-
assert "OK Google stream stranger things from Netflix to my TV" in out
96+
assert "Okay Google stream stranger things from Netflix to my TV" in out
9797
assert result is not None
9898

9999

speech/snippets/transcribe_batch_multiple_files_v2.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ def transcribe_batch_multiple_files_v2(
4848
model="long",
4949
)
5050

51-
files = [
52-
cloud_speech.BatchRecognizeFileMetadata(uri=uri)
53-
for uri in gcs_uris
54-
]
51+
files = [cloud_speech.BatchRecognizeFileMetadata(uri=uri) for uri in gcs_uris]
5552

5653
request = cloud_speech.BatchRecognizeRequest(
5754
recognizer=f"projects/{project_id}/locations/global/recognizers/_",

speech/snippets/transcribe_chirp_auto_detect_language.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def transcribe_chirp_auto_detect_language(
6464

6565
return response
6666

67+
6768
# [END speech_transcribe_chirp_auto_detect_language]
6869

6970

speech/snippets/transcribe_chirp_auto_detect_language_test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
def test_transcribe_chirp() -> None:
2727
project_id = os.getenv("GOOGLE_CLOUD_PROJECT")
2828

29-
response = transcribe_chirp_auto_detect_language.transcribe_chirp_auto_detect_language(
30-
project_id, os.path.join(_RESOURCES, "audio.wav")
29+
response = (
30+
transcribe_chirp_auto_detect_language.transcribe_chirp_auto_detect_language(
31+
project_id, os.path.join(_RESOURCES, "audio.wav")
32+
)
3133
)
3234

3335
assert re.search(
@@ -36,4 +38,4 @@ def test_transcribe_chirp() -> None:
3638
re.DOTALL | re.I,
3739
)
3840

39-
assert response.results[0].language_code == 'en'
41+
assert response.results[0].language_code == "en"

speech/snippets/transcribe_streaming_v2.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717

1818
# [START speech_transcribe_streaming_v2]
1919
from google.cloud.speech_v2 import SpeechClient
20-
from google.cloud.speech_v2.types import cloud_speech
20+
from google.cloud.speech_v2.types import cloud_speech as cloud_speech_types
2121

2222

2323
def transcribe_streaming_v2(
2424
project_id: str,
2525
audio_file: str,
26-
) -> cloud_speech.StreamingRecognizeResponse:
26+
) -> cloud_speech_types.StreamingRecognizeResponse:
2727
"""Transcribes audio from audio file stream.
2828
2929
Args:
@@ -47,23 +47,23 @@ def transcribe_streaming_v2(
4747
for start in range(0, len(content), chunk_length)
4848
]
4949
audio_requests = (
50-
cloud_speech.StreamingRecognizeRequest(audio=audio) for audio in stream
50+
cloud_speech_types.StreamingRecognizeRequest(audio=audio) for audio in stream
5151
)
5252

53-
recognition_config = cloud_speech.RecognitionConfig(
54-
auto_decoding_config=cloud_speech.AutoDetectDecodingConfig(),
53+
recognition_config = cloud_speech_types.RecognitionConfig(
54+
auto_decoding_config=cloud_speech_types.AutoDetectDecodingConfig(),
5555
language_codes=["en-US"],
5656
model="long",
5757
)
58-
streaming_config = cloud_speech.StreamingRecognitionConfig(
58+
streaming_config = cloud_speech_types.StreamingRecognitionConfig(
5959
config=recognition_config
6060
)
61-
config_request = cloud_speech.StreamingRecognizeRequest(
61+
config_request = cloud_speech_types.StreamingRecognizeRequest(
6262
recognizer=f"projects/{project_id}/locations/global/recognizers/_",
6363
streaming_config=streaming_config,
6464
)
6565

66-
def requests(config: cloud_speech.RecognitionConfig, audio: list) -> list:
66+
def requests(config: cloud_speech_types.RecognitionConfig, audio: list) -> list:
6767
yield config
6868
yield from audio
6969

0 commit comments

Comments
 (0)