Skip to content

Commit b2e3ef3

Browse files
gguussdpebot
authored andcommitted
Adds full usage examples (GoogleCloudPlatform#772)
1 parent e5e89de commit b2e3ef3

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

speech/grpc/README.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ To run this sample:
121121
[--sample_rate SAMPLE_RATE]
122122
input_uri
123123
124+
Transcribes a FLAC audio file stored in Google Cloud Storage using GRPC.
125+
126+
Example usage:
127+
python transcribe.py --encoding=FLAC --sample_rate=16000 gs://speech-demo/audio.flac
128+
124129
positional arguments:
125130
input_uri
126131
@@ -148,6 +153,12 @@ To run this sample:
148153
[--sample_rate SAMPLE_RATE]
149154
input_uri
150155
156+
Sample that transcribes a FLAC audio file stored in Google Cloud Storage,
157+
using async GRPC.
158+
159+
Example usage:
160+
python transcribe_async.py --encoding=FLAC --sample_rate=16000 gs://speech-demo/audio.flac
161+
151162
positional arguments:
152163
input_uri
153164

speech/grpc/transcribe.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
"""Sample that transcribes a FLAC audio file stored in Google Cloud Storage,
16-
using GRPC."""
15+
"""Transcribes a FLAC audio file stored in Google Cloud Storage using GRPC.
16+
17+
Example usage:
18+
python transcribe.py --encoding=FLAC --sample_rate=16000 \
19+
gs://speech-demo/audio.flac
20+
"""
1721

1822
import argparse
1923

@@ -80,7 +84,9 @@ def _gcs_uri(text):
8084
PROTO_URL = ('https://github.com/googleapis/googleapis/blob/master/'
8185
'google/cloud/speech/v1beta1/cloud_speech.proto')
8286
if __name__ == '__main__':
83-
parser = argparse.ArgumentParser()
87+
parser = argparse.ArgumentParser(
88+
description=__doc__,
89+
formatter_class=argparse.RawDescriptionHelpFormatter)
8490
parser.add_argument('input_uri', type=_gcs_uri)
8591
parser.add_argument(
8692
'--encoding', default='LINEAR16', choices=[

speech/grpc/transcribe_async.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
"""Sample that transcribes a FLAC audio file stored in Google Cloud Storage,
17-
using async GRPC."""
16+
"""
17+
Sample that transcribes a FLAC audio file stored in Google Cloud Storage,
18+
using async GRPC.
19+
20+
Example usage:
21+
python transcribe_async.py --encoding=FLAC --sample_rate=16000 \
22+
gs://speech-demo/audio.flac
23+
"""
1824

1925
import argparse
2026
import time
@@ -105,7 +111,9 @@ def _gcs_uri(text):
105111

106112

107113
if __name__ == '__main__':
108-
parser = argparse.ArgumentParser()
114+
parser = argparse.ArgumentParser(
115+
description=__doc__,
116+
formatter_class=argparse.RawDescriptionHelpFormatter)
109117
parser.add_argument('input_uri', type=_gcs_uri)
110118
parser.add_argument(
111119
'--encoding', default='LINEAR16', choices=[

0 commit comments

Comments
 (0)