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

Add comments for config options. #429

Merged
merged 2 commits into from
Jul 26, 2016
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
2 changes: 1 addition & 1 deletion appengine/standard/memcache/guestbook/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

# [START all]

import cgi
import cStringIO
import cgi
import logging
import urllib

Expand Down
10 changes: 8 additions & 2 deletions speech/api/speech_async_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@ def main(input_uri, encoding, sample_rate):
# https://github.com/googleapis/googleapis/blob/master/google/cloud/speech/v1beta1/cloud_speech.proto
response = service.AsyncRecognize(cloud_speech_pb2.AsyncRecognizeRequest(
config=cloud_speech_pb2.RecognitionConfig(
encoding=encoding,
sample_rate=sample_rate,
# There are a bunch of config options you can specify. See
# https://goo.gl/A6xv5G for the full list.
encoding=encoding, # one of LINEAR16, FLAC, MULAW, AMR, AMR_WB
sample_rate=sample_rate, # the rate in hertz
# See
# https://g.co/cloud/speech/docs/best-practices#language_support
# for a list of supported languages.
language_code='en-US', # a BCP-47 language tag
),
audio=cloud_speech_pb2.RecognitionAudio(
uri=input_uri,
Expand Down
8 changes: 6 additions & 2 deletions speech/api/speech_async_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ def main(speech_file):
service_request = service.speech().asyncrecognize(
body={
'config': {
'encoding': 'LINEAR16',
'sampleRate': 16000
# There are a bunch of config options you can specify. See
# https://goo.gl/EPjAup for the full list.
'encoding': 'LINEAR16', # raw 16-bit signed LE samples
'sampleRate': 16000, # 16 khz
# See https://goo.gl/DPeVFW for a list of supported languages.
'languageCode': 'en-US', # a BCP-47 language tag
},
'audio': {
'content': speech_content.decode('UTF-8')
Expand Down
10 changes: 8 additions & 2 deletions speech/api/speech_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ def main(input_uri, encoding, sample_rate):
# https://github.com/googleapis/googleapis/blob/master/google/cloud/speech/v1beta1/cloud_speech.proto
response = service.SyncRecognize(cloud_speech.SyncRecognizeRequest(
config=cloud_speech.RecognitionConfig(
encoding=encoding,
sample_rate=sample_rate,
# There are a bunch of config options you can specify. See
# https://goo.gl/A6xv5G for the full list.
encoding=encoding, # one of LINEAR16, FLAC, MULAW, AMR, AMR_WB
sample_rate=sample_rate, # the rate in hertz
# See
# https://g.co/cloud/speech/docs/best-practices#language_support
# for a list of supported languages.
language_code='en-US', # a BCP-47 language tag
),
audio=cloud_speech.RecognitionAudio(
uri=input_uri,
Expand Down
8 changes: 6 additions & 2 deletions speech/api/speech_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ def main(speech_file):
service_request = service.speech().syncrecognize(
body={
'config': {
'encoding': 'LINEAR16',
'sampleRate': 16000
# There are a bunch of config options you can specify. See
# https://goo.gl/EPjAup for the full list.
'encoding': 'LINEAR16', # raw 16-bit signed LE samples
'sampleRate': 16000, # 16 khz
# See https://goo.gl/DPeVFW for a list of supported languages.
'languageCode': 'en-US', # a BCP-47 language tag
},
'audio': {
'content': speech_content.decode('UTF-8')
Expand Down
12 changes: 10 additions & 2 deletions speech/api/speech_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,21 @@ def request_stream(stop_audio, channels=CHANNELS, rate=RATE, chunk=CHUNK):
Args:
stop_audio: A threading.Event object stops the recording when set.
channels: How many audio channels to record.
rate: The sampling rate.
rate: The sampling rate in hertz.
chunk: Buffer audio into chunks of this size before sending to the api.
"""
# The initial request must contain metadata about the stream, so the
# server knows how to interpret it.
recognition_config = cloud_speech.RecognitionConfig(
encoding='LINEAR16', sample_rate=rate)
# There are a bunch of config options you can specify. See
# https://goo.gl/A6xv5G for the full list.
encoding='LINEAR16', # raw 16-bit signed LE samples
sample_rate=rate, # the rate in hertz
# See
# https://g.co/cloud/speech/docs/best-practices#language_support
# for a list of supported languages.
language_code='en-US', # a BCP-47 language tag
)
streaming_config = cloud_speech.StreamingRecognitionConfig(
config=recognition_config,
# Note that setting interim_results to True means that you'll likely
Expand Down
4 changes: 2 additions & 2 deletions vision/api/face_detection/faces.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import argparse
import base64

from googleapiclient import discovery
from oauth2client.client import GoogleCredentials
from PIL import Image
from PIL import ImageDraw
from googleapiclient import discovery
from oauth2client.client import GoogleCredentials


# [START get_vision_service]
Expand Down
2 changes: 1 addition & 1 deletion vision/api/face_detection/faces_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

import os

from faces import main
from PIL import Image
from faces import main


def test_main(resource, tmpdir):
Expand Down