Skip to content

Commit

Permalink
Merge branch 'master' of github.com:GoogleCloudPlatform/python-docs-s…
Browse files Browse the repository at this point in the history
…amples
  • Loading branch information
Jon Wayne Parrott committed Apr 12, 2017
2 parents 9c3c073 + 166e787 commit e48b8b0
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 22 deletions.
1 change: 0 additions & 1 deletion appengine/flexible/django_cloudsql/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ beta_settings:
runtime_config:
python_version: 3
# [END runtime]

4 changes: 3 additions & 1 deletion appengine/flexible/django_cloudsql/mysite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@
# [START dbconfig]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
# If you are using Cloud SQL for MySQL rather than PostgreSQL, set
# 'ENGINE': 'django.db.backends.mysql' instead of the following.
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'polls',
'USER': '<your-database-user>',
'PASSWORD': '<your-database-password>',
Expand Down
1 change: 1 addition & 0 deletions appengine/flexible/django_cloudsql/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ Django==1.11
mysqlclient==1.3.10
wheel==0.29.0
gunicorn==19.7.1
psycopg2==2.7.1
2 changes: 1 addition & 1 deletion language/cloud-client/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
google-cloud-language==0.24.0
google-cloud-language==0.24.1
2 changes: 1 addition & 1 deletion language/sentiment/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
google-cloud-language==0.24.0
google-cloud-language==0.24.1
27 changes: 26 additions & 1 deletion speech/cloud-client/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ To run this sample:
Example usage:
python transcribe_async.py resources/audio.raw
python transcribe_async.py gs://cloud-samples-tests/speech/brooklyn.flac
python transcribe_async.py gs://cloud-samples-tests/speech/brooklyn.raw
positional arguments:
path File or GCS path for audio file to be recognized
Expand All @@ -136,6 +136,31 @@ To run this sample:
-h, --help show this help message and exit
Transcribe Streaming
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



To run this sample:

.. code-block:: bash
$ python transcribe_streaming.py
usage: transcribe_streaming.py [-h] stream
Google Cloud Speech API sample application using the streaming API.
Example usage:
python transcribe_streaming.py resources/audio.raw
positional arguments:
stream File to stream to the API
optional arguments:
-h, --help show this help message and exit
The client library
Expand Down
3 changes: 3 additions & 0 deletions speech/cloud-client/README.rst.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ samples:
- name: Transcribe async
file: transcribe_async.py
show_help: true
- name: Transcribe Streaming
file: transcribe_streaming.py
show_help: true

cloud_client_library: true
6 changes: 3 additions & 3 deletions speech/cloud-client/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ def run_quickstart():
# Loads the audio into memory
with io.open(file_name, 'rb') as audio_file:
content = audio_file.read()
audio_sample = speech_client.sample(
sample = speech_client.sample(
content,
source_uri=None,
encoding='LINEAR16',
sample_rate=16000)
sample_rate_hertz=16000)

# Detects speech in the audio file
alternatives = speech_client.speech_api.sync_recognize(audio_sample)
alternatives = sample.recognize('en-US')

for alternative in alternatives:
print('Transcript: {}'.format(alternative.transcript))
Expand Down
2 changes: 1 addition & 1 deletion speech/cloud-client/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
google-cloud-speech==0.23.0
google-cloud-speech==0.25.0
8 changes: 4 additions & 4 deletions speech/cloud-client/transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def transcribe_file(speech_file):
content=content,
source_uri=None,
encoding='LINEAR16',
sample_rate=16000)
sample_rate_hertz=16000)

alternatives = speech_client.speech_api.sync_recognize(audio_sample)
alternatives = audio_sample.recognize('en-US')
for alternative in alternatives:
print('Transcript: {}'.format(alternative.transcript))

Expand All @@ -55,9 +55,9 @@ def transcribe_gcs(gcs_uri):
content=None,
source_uri=gcs_uri,
encoding='FLAC',
sample_rate=16000)
sample_rate_hertz=16000)

alternatives = speech_client.speech_api.sync_recognize(audio_sample)
alternatives = audio_sample.recognize('en-US')
for alternative in alternatives:
print('Transcript: {}'.format(alternative.transcript))

Expand Down
12 changes: 6 additions & 6 deletions speech/cloud-client/transcribe_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Example usage:
python transcribe_async.py resources/audio.raw
python transcribe_async.py gs://cloud-samples-tests/speech/brooklyn.flac
python transcribe_async.py gs://cloud-samples-tests/speech/brooklyn.raw
"""

import argparse
Expand All @@ -38,9 +38,9 @@ def transcribe_file(speech_file):
content,
source_uri=None,
encoding='LINEAR16',
sample_rate=16000)
sample_rate_hertz=16000)

operation = speech_client.speech_api.async_recognize(audio_sample)
operation = audio_sample.long_running_recognize('en-US')

retry_count = 100
while retry_count > 0 and not operation.complete:
Expand All @@ -67,10 +67,10 @@ def transcribe_gcs(gcs_uri):
audio_sample = speech_client.sample(
content=None,
source_uri=gcs_uri,
encoding='FLAC',
sample_rate=16000)
encoding='LINEAR16',
sample_rate_hertz=16000)

operation = speech_client.speech_api.async_recognize(audio_sample)
operation = audio_sample.long_running_recognize('en-US')

retry_count = 100
while retry_count > 0 and not operation.complete:
Expand Down
2 changes: 1 addition & 1 deletion speech/cloud-client/transcribe_async_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_transcribe(capsys):

def test_transcribe_gcs(capsys):
transcribe_async.transcribe_gcs(
'gs://python-docs-samples-tests/speech/audio.flac')
'gs://python-docs-samples-tests/speech/audio.raw')
out, err = capsys.readouterr()

assert re.search(r'how old is the Brooklyn Bridge', out, re.DOTALL | re.I)
4 changes: 2 additions & 2 deletions speech/cloud-client/transcribe_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def transcribe_streaming(stream_file):
audio_sample = speech_client.sample(
stream=audio_file,
encoding=speech.encoding.Encoding.LINEAR16,
sample_rate=16000)
alternatives = audio_sample.streaming_recognize()
sample_rate_hertz=16000)
alternatives = audio_sample.streaming_recognize('en-US')

for alternative in alternatives:
print('Finished: {}'.format(alternative.is_final))
Expand Down

0 comments on commit e48b8b0

Please sign in to comment.