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
This repository was archived by the owner on Mar 17, 2020. It is now read-only.

Commit 34933c6

Browse filesBrowse files
authored
more info on alternatives (GoogleCloudPlatform#1791)
* more info on alternatives * add comment
1 parent bfd5d07 commit 34933c6
Copy full SHA for 34933c6

File tree

Expand file treeCollapse file tree

1 file changed

+21
-15
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+21
-15
lines changed

‎video/cloud-client/analyze/beta_snippets.py

Copy file name to clipboardExpand all lines: video/cloud-client/analyze/beta_snippets.py
+21-15Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,27 @@ def speech_transcription(input_uri):
5555
# There is only one annotation_result since only
5656
# one video is processed.
5757
annotation_results = result.annotation_results[0]
58-
speech_transcription = annotation_results.speech_transcriptions[0]
59-
alternative = speech_transcription.alternatives[0]
60-
61-
print('Transcript: {}'.format(alternative.transcript))
62-
print('Confidence: {}\n'.format(alternative.confidence))
63-
64-
print('Word level information:')
65-
for word_info in alternative.words:
66-
word = word_info.word
67-
start_time = word_info.start_time
68-
end_time = word_info.end_time
69-
print('\t{}s - {}s: {}'.format(
70-
start_time.seconds + start_time.nanos * 1e-9,
71-
end_time.seconds + end_time.nanos * 1e-9,
72-
word))
58+
for speech_transcription in annotation_results.speech_transcriptions:
59+
60+
# The number of alternatives for each transcription is limited by
61+
# SpeechTranscriptionConfig.max_alternatives.
62+
# Each alternative is a different possible transcription
63+
# and has its own confidence score.
64+
for alternative in speech_transcription.alternatives:
65+
print('Alternative level information:')
66+
67+
print('Transcript: {}'.format(alternative.transcript))
68+
print('Confidence: {}\n'.format(alternative.confidence))
69+
70+
print('Word level information:')
71+
for word_info in alternative.words:
72+
word = word_info.word
73+
start_time = word_info.start_time
74+
end_time = word_info.end_time
75+
print('\t{}s - {}s: {}'.format(
76+
start_time.seconds + start_time.nanos * 1e-9,
77+
end_time.seconds + end_time.nanos * 1e-9,
78+
word))
7379
# [END video_speech_transcription_gcs_beta]
7480

7581

0 commit comments

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