File tree Expand file tree Collapse file tree 3 files changed +10
-0
lines changed
google-cloud-speech/samples/snippets Expand file tree Collapse file tree 3 files changed +10
-0
lines changed Original file line number Diff line number Diff line change 2828# [END import_libraries]
2929
3030
31+ # [START def_transcribe_file]
3132def transcribe_file (speech_file ):
3233 """Transcribe the given audio file."""
3334 from google .cloud import speech
@@ -55,8 +56,10 @@ def transcribe_file(speech_file):
5556 for alternative in alternatives :
5657 print ('Transcript: {}' .format (alternative .transcript ))
5758 # [END migration_sync_response]
59+ # [END def_transcribe_file]
5860
5961
62+ # [START def_transcribe_gcs]
6063def transcribe_gcs (gcs_uri ):
6164 """Transcribes the audio file specified by the gcs_uri."""
6265 from google .cloud import speech
@@ -77,6 +80,7 @@ def transcribe_gcs(gcs_uri):
7780
7881 for alternative in alternatives :
7982 print ('Transcript: {}' .format (alternative .transcript ))
83+ # [END def_transcribe_gcs]
8084
8185
8286if __name__ == '__main__' :
Original file line number Diff line number Diff line change 2727import time
2828
2929
30+ # [START def_transcribe_file]
3031def transcribe_file (speech_file ):
3132 """Transcribe the given audio file asynchronously."""
3233 from google .cloud import speech
@@ -63,8 +64,10 @@ def transcribe_file(speech_file):
6364 print ('Transcript: {}' .format (alternative .transcript ))
6465 print ('Confidence: {}' .format (alternative .confidence ))
6566 # [END migration_async_response]
67+ # [END def_transcribe_file]
6668
6769
70+ # [START def_transcribe_gcs]
6871def transcribe_gcs (gcs_uri ):
6972 """Asynchronously transcribes the audio file specified by the gcs_uri."""
7073 from google .cloud import speech
@@ -93,6 +96,7 @@ def transcribe_gcs(gcs_uri):
9396 for alternative in alternatives :
9497 print ('Transcript: {}' .format (alternative .transcript ))
9598 print ('Confidence: {}' .format (alternative .confidence ))
99+ # [END def_transcribe_gcs]
96100
97101
98102if __name__ == '__main__' :
Original file line number Diff line number Diff line change 2626# [END import_libraries]
2727
2828
29+ # [START def_transcribe_streaming]
2930def transcribe_streaming (stream_file ):
3031 """Streams transcription of the given audio file."""
3132 from google .cloud import speech
@@ -62,6 +63,7 @@ def transcribe_streaming(stream_file):
6263 print ('Confidence: {}' .format (alternative .confidence ))
6364 print ('Transcript: {}' .format (alternative .transcript ))
6465 # [END migration_streaming_response]
66+ # [END def_transcribe_streaming]
6567
6668
6769if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments