File tree 3 files changed +10
-0
lines changed 3 files changed +10
-0
lines changed Original file line number Diff line number Diff line change 28
28
# [END import_libraries]
29
29
30
30
31
+ # [START def_transcribe_file]
31
32
def transcribe_file (speech_file ):
32
33
"""Transcribe the given audio file."""
33
34
from google .cloud import speech
@@ -55,8 +56,10 @@ def transcribe_file(speech_file):
55
56
for alternative in alternatives :
56
57
print ('Transcript: {}' .format (alternative .transcript ))
57
58
# [END migration_sync_response]
59
+ # [END def_transcribe_file]
58
60
59
61
62
+ # [START def_transcribe_gcs]
60
63
def transcribe_gcs (gcs_uri ):
61
64
"""Transcribes the audio file specified by the gcs_uri."""
62
65
from google .cloud import speech
@@ -77,6 +80,7 @@ def transcribe_gcs(gcs_uri):
77
80
78
81
for alternative in alternatives :
79
82
print ('Transcript: {}' .format (alternative .transcript ))
83
+ # [END def_transcribe_gcs]
80
84
81
85
82
86
if __name__ == '__main__' :
Original file line number Diff line number Diff line change 27
27
import time
28
28
29
29
30
+ # [START def_transcribe_file]
30
31
def transcribe_file (speech_file ):
31
32
"""Transcribe the given audio file asynchronously."""
32
33
from google .cloud import speech
@@ -63,8 +64,10 @@ def transcribe_file(speech_file):
63
64
print ('Transcript: {}' .format (alternative .transcript ))
64
65
print ('Confidence: {}' .format (alternative .confidence ))
65
66
# [END migration_async_response]
67
+ # [END def_transcribe_file]
66
68
67
69
70
+ # [START def_transcribe_gcs]
68
71
def transcribe_gcs (gcs_uri ):
69
72
"""Asynchronously transcribes the audio file specified by the gcs_uri."""
70
73
from google .cloud import speech
@@ -93,6 +96,7 @@ def transcribe_gcs(gcs_uri):
93
96
for alternative in alternatives :
94
97
print ('Transcript: {}' .format (alternative .transcript ))
95
98
print ('Confidence: {}' .format (alternative .confidence ))
99
+ # [END def_transcribe_gcs]
96
100
97
101
98
102
if __name__ == '__main__' :
Original file line number Diff line number Diff line change 26
26
# [END import_libraries]
27
27
28
28
29
+ # [START def_transcribe_streaming]
29
30
def transcribe_streaming (stream_file ):
30
31
"""Streams transcription of the given audio file."""
31
32
from google .cloud import speech
@@ -62,6 +63,7 @@ def transcribe_streaming(stream_file):
62
63
print ('Confidence: {}' .format (alternative .confidence ))
63
64
print ('Transcript: {}' .format (alternative .transcript ))
64
65
# [END migration_streaming_response]
66
+ # [END def_transcribe_streaming]
65
67
66
68
67
69
if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments