Skip to content

Commit b2daafe

Browse files
authored
Write synthesis script, regenerate library (googleapis#5577)
1 parent 696b307 commit b2daafe

26 files changed

Lines changed: 1155 additions & 554 deletions

speech/README.rst

Lines changed: 78 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,97 @@
1-
Python Client for Google Cloud Speech
2-
=====================================
1+
Python Client for Google Cloud Speech API (`Beta`_)
2+
====================================================
33

4-
Python idiomatic client for `Google Cloud Speech`_
4+
`Google Cloud Speech API`_: Google Cloud Speech API.
55

6-
.. _Google Cloud Speech: https://cloud.google.com/speech/
6+
- `Client Library Documentation`_
7+
- `Product Documentation`_
78

8-
|pypi| |versions|
9-
10-
- `Documentation`_
11-
12-
.. _Documentation: https://googlecloudplatform.github.io/google-cloud-python/latest/speech/
9+
.. _Alpha: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst
10+
.. _Google Cloud Speech API: https://cloud.google.com/speech
11+
.. _Client Library Documentation: https://googlecloudplatform.github.io/google-cloud-python/stable/speech/usage.html
12+
.. _Product Documentation: https://cloud.google.com/speech
1313

1414
Quick Start
1515
-----------
1616

17+
In order to use this library, you first need to go through the following steps:
18+
19+
1. `Select or create a Cloud Platform project.`_
20+
2. `Enable billing for your project.`_
21+
3. `Enable the Google Cloud Speech API.`_
22+
4. `Setup Authentication.`_
23+
24+
.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
25+
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
26+
.. _Enable the Google Cloud Speech API.: https://cloud.google.com/speech
27+
.. _Setup Authentication.: https://googlecloudplatform.github.io/google-cloud-python/stable/core/auth.html
28+
29+
Installation
30+
~~~~~~~~~~~~
31+
32+
Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
33+
create isolated Python environments. The basic problem it addresses is one of
34+
dependencies and versions, and indirectly permissions.
35+
36+
With `virtualenv`_, it's possible to install this library without needing system
37+
install permissions, and without clashing with the installed system
38+
dependencies.
39+
40+
.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
41+
42+
43+
Mac/Linux
44+
^^^^^^^^^
45+
46+
.. code-block:: console
47+
48+
pip install virtualenv
49+
virtualenv <your-env>
50+
source <your-env>/bin/activate
51+
<your-env>/bin/pip install google-cloud-speech
52+
53+
54+
Windows
55+
^^^^^^^
56+
1757
.. code-block:: console
1858
19-
$ pip install --upgrade google-cloud-speech
59+
pip install virtualenv
60+
virtualenv <your-env>
61+
<your-env>\Scripts\activate
62+
<your-env>\Scripts\pip.exe install google-cloud-speech
2063
21-
For more information on setting up your Python development environment,
22-
such as installing ``pip`` and ``virtualenv`` on your system, please refer
23-
to `Python Development Environment Setup Guide`_ for Google Cloud Platform.
64+
Preview
65+
~~~~~~~
2466

25-
.. _Python Development Environment Setup Guide: https://cloud.google.com/python/setup
67+
SpeechClient
68+
^^^^^^^^^^^^
2669

27-
Authentication
28-
--------------
70+
.. code:: py
2971
30-
With ``google-cloud-python`` we try to make authentication as painless as
31-
possible. Check out the `Authentication section`_ in our documentation to
32-
learn more. You may also find the `authentication document`_ shared by all
33-
the ``google-cloud-*`` libraries to be helpful.
72+
from google.cloud import speech_v1
73+
from google.cloud.speech_v1 import enums
3474
35-
.. _Authentication section: https://google-cloud-python.readthedocs.io/en/latest/core/auth.html
36-
.. _authentication document: https://github.com/GoogleCloudPlatform/google-cloud-common/tree/master/authentication
75+
client = speech_v1.SpeechClient()
3776
38-
Using the API
39-
-------------
77+
encoding = enums.RecognitionConfig.AudioEncoding.FLAC
78+
sample_rate_hertz = 44100
79+
language_code = 'en-US'
80+
config = {'encoding': encoding, 'sample_rate_hertz': sample_rate_hertz, 'language_code': language_code}
81+
uri = 'gs://bucket_name/file_name.flac'
82+
audio = {'uri': uri}
4083
41-
`Cloud Speech API`_ enables easy integration of Google speech
42-
recognition technologies into developer applications. Send audio
43-
and receive a text transcription from the Cloud Speech API service.
84+
response = client.recognize(config, audio)
4485
45-
.. _Cloud Speech API: https://cloud.google.com/speech/
86+
Next Steps
87+
~~~~~~~~~~
4688

47-
See the ``google-cloud-python`` API `speech documentation`_ to learn how to
48-
connect to the Google Cloud Speech API using this Client Library.
89+
- Read the `Client Library Documentation`_ for Google Cloud Speech API
90+
API to see other available methods on the client.
91+
- Read the `Google Cloud Speech API Product documentation`_ to learn
92+
more about the product and see How-to Guides.
93+
- View this `repository’s main README`_ to see the full list of Cloud
94+
APIs that we cover.
4995

50-
.. _speech documentation: https://googlecloudplatform.github.io/google-cloud-python/latest/speech/
51-
.. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-speech.svg
52-
:target: https://pypi.org/project/google-cloud-speech/
53-
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-speech.svg
54-
:target: https://pypi.org/project/google-cloud-speech/
96+
.. _Google Cloud Speech API Product documentation: https://cloud.google.com/speech
97+
.. _repository’s main README: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst

speech/docs/gapic/v1/api.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Client for Google Cloud Speech API
2+
==================================
3+
4+
.. automodule:: google.cloud.speech_v1
5+
:members:
6+
:inherited-members:

speech/docs/gapic/v1/types.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Types for Google Cloud Speech API Client
2+
========================================
3+
4+
.. automodule:: google.cloud.speech_v1.types
5+
:members:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Client for Cloud Speech API
2+
===========================
3+
4+
.. automodule:: google.cloud.speech_v1p1beta1
5+
:members:
6+
:inherited-members:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Types for Cloud Speech API Client
2+
=================================
3+
4+
.. automodule:: google.cloud.speech_v1p1beta1.types
5+
:members:

speech/docs/index.rst

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
Python Client for Google Cloud Speech API (`Beta`_)
2+
====================================================
3+
4+
`Google Cloud Speech API`_: Google Cloud Speech API.
5+
6+
- `Client Library Documentation`_
7+
- `Product Documentation`_
8+
9+
.. _Alpha: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst
10+
.. _Google Cloud Speech API: https://cloud.google.com/speech
11+
.. _Client Library Documentation: https://googlecloudplatform.github.io/google-cloud-python/stable/speech/usage.html
12+
.. _Product Documentation: https://cloud.google.com/speech
13+
14+
Quick Start
15+
-----------
16+
17+
In order to use this library, you first need to go through the following steps:
18+
19+
1. `Select or create a Cloud Platform project.`_
20+
2. `Enable billing for your project.`_
21+
3. `Enable the Google Cloud Speech API.`_
22+
4. `Setup Authentication.`_
23+
24+
.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
25+
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
26+
.. _Enable the Google Cloud Speech API.: https://cloud.google.com/speech
27+
.. _Setup Authentication.: https://googlecloudplatform.github.io/google-cloud-python/stable/core/auth.html
28+
29+
Installation
30+
~~~~~~~~~~~~
31+
32+
Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
33+
create isolated Python environments. The basic problem it addresses is one of
34+
dependencies and versions, and indirectly permissions.
35+
36+
With `virtualenv`_, it's possible to install this library without needing system
37+
install permissions, and without clashing with the installed system
38+
dependencies.
39+
40+
.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
41+
42+
43+
Mac/Linux
44+
^^^^^^^^^
45+
46+
.. code-block:: console
47+
48+
pip install virtualenv
49+
virtualenv <your-env>
50+
source <your-env>/bin/activate
51+
<your-env>/bin/pip install google-cloud-speech
52+
53+
54+
Windows
55+
^^^^^^^
56+
57+
.. code-block:: console
58+
59+
pip install virtualenv
60+
virtualenv <your-env>
61+
<your-env>\Scripts\activate
62+
<your-env>\Scripts\pip.exe install google-cloud-speech
63+
64+
Preview
65+
~~~~~~~
66+
67+
SpeechClient
68+
^^^^^^^^^^^^
69+
70+
.. code:: py
71+
72+
from google.cloud import speech_v1
73+
from google.cloud.speech_v1 import enums
74+
75+
client = speech_v1.SpeechClient()
76+
77+
encoding = enums.RecognitionConfig.AudioEncoding.FLAC
78+
sample_rate_hertz = 44100
79+
language_code = 'en-US'
80+
config = {'encoding': encoding, 'sample_rate_hertz': sample_rate_hertz, 'language_code': language_code}
81+
uri = 'gs://bucket_name/file_name.flac'
82+
audio = {'uri': uri}
83+
84+
response = client.recognize(config, audio)
85+
86+
Next Steps
87+
~~~~~~~~~~
88+
89+
- Read the `Client Library Documentation`_ for Google Cloud Speech API
90+
API to see other available methods on the client.
91+
- Read the `Google Cloud Speech API Product documentation`_ to learn
92+
more about the product and see How-to Guides.
93+
- View this `repository’s main README`_ to see the full list of Cloud
94+
APIs that we cover.
95+
96+
.. _Google Cloud Speech API Product documentation: https://cloud.google.com/speech
97+
.. _repository’s main README: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst
98+
99+
Api Reference
100+
-------------
101+
.. toctree::
102+
:maxdepth: 2
103+
104+
gapic/v1/api
105+
gapic/v1/types
106+
gapic/v1p1beta1/api
107+
gapic/v1p1beta1/types
108+
changelog

speech/google/cloud/speech_v1/gapic/enums.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
# limitations under the License.
1414
"""Wrappers for protocol buffer enum types."""
1515

16+
import enum
17+
1618

1719
class RecognitionConfig(object):
18-
class AudioEncoding(object):
20+
class AudioEncoding(enum.IntEnum):
1921
"""
2022
Audio encoding of the data sent in the audio message. All encodings support
2123
only 1 channel (mono) audio. Only ``FLAC`` and ``WAV`` include a header that
@@ -68,7 +70,7 @@ class AudioEncoding(object):
6870

6971

7072
class StreamingRecognizeResponse(object):
71-
class SpeechEventType(object):
73+
class SpeechEventType(enum.IntEnum):
7274
"""
7375
Indicates the type of speech event.
7476

0 commit comments

Comments
 (0)