Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use region tags for Speech API samples #1022

Merged
merged 1 commit into from
Jul 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions speech/cloud-client/transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# [END import_libraries]


# [START def_transcribe_file]
def transcribe_file(speech_file):
"""Transcribe the given audio file."""
from google.cloud import speech
Expand Down Expand Up @@ -55,8 +56,10 @@ def transcribe_file(speech_file):
for alternative in alternatives:
print('Transcript: {}'.format(alternative.transcript))
# [END migration_sync_response]
# [END def_transcribe_file]


# [START def_transcribe_gcs]
def transcribe_gcs(gcs_uri):
"""Transcribes the audio file specified by the gcs_uri."""
from google.cloud import speech
Expand All @@ -77,6 +80,7 @@ def transcribe_gcs(gcs_uri):

for alternative in alternatives:
print('Transcript: {}'.format(alternative.transcript))
# [END def_transcribe_gcs]


if __name__ == '__main__':
Expand Down
4 changes: 4 additions & 0 deletions speech/cloud-client/transcribe_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import time


# [START def_transcribe_file]
def transcribe_file(speech_file):
"""Transcribe the given audio file asynchronously."""
from google.cloud import speech
Expand Down Expand Up @@ -63,8 +64,10 @@ def transcribe_file(speech_file):
print('Transcript: {}'.format(alternative.transcript))
print('Confidence: {}'.format(alternative.confidence))
# [END migration_async_response]
# [END def_transcribe_file]


# [START def_transcribe_gcs]
def transcribe_gcs(gcs_uri):
"""Asynchronously transcribes the audio file specified by the gcs_uri."""
from google.cloud import speech
Expand Down Expand Up @@ -93,6 +96,7 @@ def transcribe_gcs(gcs_uri):
for alternative in alternatives:
print('Transcript: {}'.format(alternative.transcript))
print('Confidence: {}'.format(alternative.confidence))
# [END def_transcribe_gcs]


if __name__ == '__main__':
Expand Down
2 changes: 2 additions & 0 deletions speech/cloud-client/transcribe_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# [END import_libraries]


# [START def_transcribe_streaming]
def transcribe_streaming(stream_file):
"""Streams transcription of the given audio file."""
from google.cloud import speech
Expand Down Expand Up @@ -62,6 +63,7 @@ def transcribe_streaming(stream_file):
print('Confidence: {}'.format(alternative.confidence))
print('Transcript: {}'.format(alternative.transcript))
# [END migration_streaming_response]
# [END def_transcribe_streaming]


if __name__ == '__main__':
Expand Down