Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e3992a7

Browse filesBrowse files
jerjouJon Wayne Parrott
authored andcommitted
Speech: clarify comments. (GoogleCloudPlatform#1278)
1 parent 12619d0 commit e3992a7
Copy full SHA for e3992a7

File tree

Expand file treeCollapse file tree

3 files changed

+16
-4
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+16
-4
lines changed

‎speech/cloud-client/transcribe.py

Copy file name to clipboardExpand all lines: speech/cloud-client/transcribe.py
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ def transcribe_file(speech_file):
5151
# [START migration_sync_response]
5252
response = client.recognize(config, audio)
5353
# [END migration_sync_request]
54-
# Print the first alternative of all the consecutive results.
54+
# Each result is for a consecutive portion of the audio. Iterate through
55+
# them to get the transcripts for the entire audio file.
5556
for result in response.results:
57+
# The first alternative is the most likely one for this portion.
5658
print('Transcript: {}'.format(result.alternatives[0].transcript))
5759
# [END migration_sync_response]
5860
# [END def_transcribe_file]
@@ -75,8 +77,10 @@ def transcribe_gcs(gcs_uri):
7577
# [END migration_audio_config_gcs]
7678

7779
response = client.recognize(config, audio)
78-
# Print the first alternative of all the consecutive results.
80+
# Each result is for a consecutive portion of the audio. Iterate through
81+
# them to get the transcripts for the entire audio file.
7982
for result in response.results:
83+
# The first alternative is the most likely one for this portion.
8084
print('Transcript: {}'.format(result.alternatives[0].transcript))
8185
# [END def_transcribe_gcs]
8286

‎speech/cloud-client/transcribe_async.py

Copy file name to clipboardExpand all lines: speech/cloud-client/transcribe_async.py
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ def transcribe_file(speech_file):
5151
print('Waiting for operation to complete...')
5252
response = operation.result(timeout=90)
5353

54-
# Print the first alternative of all the consecutive results.
54+
# Each result is for a consecutive portion of the audio. Iterate through
55+
# them to get the transcripts for the entire audio file.
5556
for result in response.results:
57+
# The first alternative is the most likely one for this portion.
5658
print('Transcript: {}'.format(result.alternatives[0].transcript))
5759
print('Confidence: {}'.format(result.alternatives[0].confidence))
5860
# [END migration_async_response]
@@ -78,8 +80,10 @@ def transcribe_gcs(gcs_uri):
7880
print('Waiting for operation to complete...')
7981
response = operation.result(timeout=90)
8082

81-
# Print the first alternative of all the consecutive results.
83+
# Each result is for a consecutive portion of the audio. Iterate through
84+
# them to get the transcripts for the entire audio file.
8285
for result in response.results:
86+
# The first alternative is the most likely one for this portion.
8387
print('Transcript: {}'.format(result.alternatives[0].transcript))
8488
print('Confidence: {}'.format(result.alternatives[0].confidence))
8589
# [END def_transcribe_gcs]

‎speech/cloud-client/transcribe_streaming.py

Copy file name to clipboardExpand all lines: speech/cloud-client/transcribe_streaming.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ def transcribe_streaming(stream_file):
5555
# [END migration_streaming_request]
5656

5757
for response in responses:
58+
# Once the transcription has settled, the first result will contain the
59+
# is_final result. The other results will be for subsequent portions of
60+
# the audio.
5861
for result in response.results:
5962
print('Finished: {}'.format(result.is_final))
6063
print('Stability: {}'.format(result.stability))
6164
alternatives = result.alternatives
65+
# The alternatives are ordered from most likely to least.
6266
for alternative in alternatives:
6367
print('Confidence: {}'.format(alternative.confidence))
6468
print('Transcript: {}'.format(alternative.transcript))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.