From 8ff533cdff50fcd73c0998178595c72be2117356 Mon Sep 17 00:00:00 2001 From: Gus Class Date: Tue, 31 Jan 2017 16:26:43 -0800 Subject: [PATCH] Adds full usage examples --- speech/grpc/README.rst | 11 +++++++++++ speech/grpc/transcribe.py | 12 +++++++++--- speech/grpc/transcribe_async.py | 14 +++++++++++--- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/speech/grpc/README.rst b/speech/grpc/README.rst index 440bd209490..519963b72cd 100644 --- a/speech/grpc/README.rst +++ b/speech/grpc/README.rst @@ -121,6 +121,11 @@ To run this sample: [--sample_rate SAMPLE_RATE] input_uri + Transcribes a FLAC audio file stored in Google Cloud Storage using GRPC. + + Example usage: + python transcribe.py --encoding=FLAC --sample_rate=16000 gs://speech-demo/audio.flac + positional arguments: input_uri @@ -148,6 +153,12 @@ To run this sample: [--sample_rate SAMPLE_RATE] input_uri + Sample that transcribes a FLAC audio file stored in Google Cloud Storage, + using async GRPC. + + Example usage: + python transcribe_async.py --encoding=FLAC --sample_rate=16000 gs://speech-demo/audio.flac + positional arguments: input_uri diff --git a/speech/grpc/transcribe.py b/speech/grpc/transcribe.py index 5251630bfef..1e15fcf1104 100644 --- a/speech/grpc/transcribe.py +++ b/speech/grpc/transcribe.py @@ -12,8 +12,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Sample that transcribes a FLAC audio file stored in Google Cloud Storage, -using GRPC.""" +"""Transcribes a FLAC audio file stored in Google Cloud Storage using GRPC. + +Example usage: + python transcribe.py --encoding=FLAC --sample_rate=16000 \ + gs://speech-demo/audio.flac +""" import argparse @@ -80,7 +84,9 @@ def _gcs_uri(text): PROTO_URL = ('https://github.com/googleapis/googleapis/blob/master/' 'google/cloud/speech/v1beta1/cloud_speech.proto') if __name__ == '__main__': - parser = argparse.ArgumentParser() + parser = argparse.ArgumentParser( + description=__doc__, + formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('input_uri', type=_gcs_uri) parser.add_argument( '--encoding', default='LINEAR16', choices=[ diff --git a/speech/grpc/transcribe_async.py b/speech/grpc/transcribe_async.py index edecf6f7021..3bda3c4604e 100644 --- a/speech/grpc/transcribe_async.py +++ b/speech/grpc/transcribe_async.py @@ -13,8 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Sample that transcribes a FLAC audio file stored in Google Cloud Storage, -using async GRPC.""" +""" +Sample that transcribes a FLAC audio file stored in Google Cloud Storage, +using async GRPC. + +Example usage: + python transcribe_async.py --encoding=FLAC --sample_rate=16000 \ + gs://speech-demo/audio.flac +""" import argparse import time @@ -105,7 +111,9 @@ def _gcs_uri(text): if __name__ == '__main__': - parser = argparse.ArgumentParser() + parser = argparse.ArgumentParser( + description=__doc__, + formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('input_uri', type=_gcs_uri) parser.add_argument( '--encoding', default='LINEAR16', choices=[