|
1 | | -Python Client for Google Cloud Speech |
2 | | -===================================== |
| 1 | +Python Client for Google Cloud Speech API (`Beta`_) |
| 2 | +==================================================== |
3 | 3 |
|
4 | | - Python idiomatic client for `Google Cloud Speech`_ |
| 4 | +`Google Cloud Speech API`_: Google Cloud Speech API. |
5 | 5 |
|
6 | | -.. _Google Cloud Speech: https://cloud.google.com/speech/ |
| 6 | +- `Client Library Documentation`_ |
| 7 | +- `Product Documentation`_ |
7 | 8 |
|
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 |
13 | 13 |
|
14 | 14 | Quick Start |
15 | 15 | ----------- |
16 | 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 | + |
17 | 57 | .. code-block:: console |
18 | 58 |
|
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 |
20 | 63 |
|
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 | +~~~~~~~ |
24 | 66 |
|
25 | | -.. _Python Development Environment Setup Guide: https://cloud.google.com/python/setup |
| 67 | +SpeechClient |
| 68 | +^^^^^^^^^^^^ |
26 | 69 |
|
27 | | -Authentication |
28 | | --------------- |
| 70 | +.. code:: py |
29 | 71 |
|
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 |
34 | 74 |
|
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() |
37 | 76 |
|
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} |
40 | 83 |
|
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) |
44 | 85 |
|
45 | | -.. _Cloud Speech API: https://cloud.google.com/speech/ |
| 86 | +Next Steps |
| 87 | +~~~~~~~~~~ |
46 | 88 |
|
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. |
49 | 95 |
|
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 |
0 commit comments