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

feat(speech): Add Speech-to-Text On-Prem sample #4223

Merged
merged 6 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Move to onprem folder, add resource and README
  • Loading branch information
vinnysenthil committed Jul 22, 2020
commit 3aec031d099127db648e6462dbc2bff8d1133e96
Binary file not shown.
111 changes: 111 additions & 0 deletions speech/cloud-client/transcribe_onprem/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
.. This file is automatically generated. Do not edit this file directly.

Google Cloud Speech-to-Text On-Prem Python Samples
===============================================================================


.. warning:: This product is only available to customers that have been granted access. Please `contact us`_ to request access to the Speech-to-Text On-Prem feature.

This directory contains samples for `Google Cloud Speech-to-Text On-Prem`_. Speech-to-Text On-Prem enables easy integration of Google speech recognition technologies into your on-prem solution.


.. _Google Cloud Speech-to-Text On-Prem: https://cloud.google.com/speech-to-text/on-prem/priv/docs

.. _contact us: https://cloud.google.com/contact

.. _Google Cloud Speech-to-Text On-Prem: https://cloud.google.com/speech-to-text/on-prem/priv/docs

Setup
-------------------------------------------------------------------------------


Prepare and Deploy API
+++++++++++++++++++++++

This sample requires you to have a Kubernetes cluster with the Speech-to-Text On-Prem service deployed. Follow the quickstart steps listed below:

#. `Setup IAM, Kubernetes, Billing`_

#. `Deploy the API using the UI or command line`_

#. `Query the API to ensure it's working`_


.. _Query the API to ensure it's working:
https://cloud.google.com/speech-to-text/on-prem/priv/docs/query

.. _Deploy the API using the UI or command line:
https://cloud.google.com/speech-to-text/on-prem/priv/docs/deploy

.. _Setup IAM, Kubernetes, Billing:
https://cloud.google.com/speech-to-text/on-prem/priv/docs/before-you-begin

Install Dependencies
++++++++++++++++++++

#. Clone python-docs-samples and change directory to the sample directory you want to use.

.. code-block:: bash

$ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
$ cd python-doc-samples/speech/cloud-client

#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions.

.. _Python Development Environment Setup Guide:
https://cloud.google.com/python/setup

#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.

.. code-block:: bash

$ virtualenv env
$ source env/bin/activate

#. Install the dependencies needed to run the samples.

.. code-block:: bash

$ pip install -r requirements.txt

.. _pip: https://pip.pypa.io/
.. _virtualenv: https://virtualenv.pypa.io/

Samples
-------------------------------------------------------------------------------

transcribe_onprem
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


You can run this sample one of two ways, using a **public IP**:

.. code-block:: bash

# Using a Public IP
$ python transcribe_onprem.py --file_path="../resources/two_channel_16k.wav" --api_endpoint=${PUBLIC_IP}:443

or by using a **cluster level IP**:

.. code-block:: bash

# Using a cluster level IP
$ kubectl port-forward -n $NAMESPACE $POD 10000:443
$ python transcribe_onprem.py --file_path="../resources/two_channel_16k.wav" --api_endpoint="0.0.0.0:10000"

The client library
-------------------------------------------------------------------------------

This sample uses the `Google Cloud Client Library for Python`_.
You can read the documentation for more details on API usage and use GitHub
to `browse the source`_ and `report issues`_.

.. _Google Cloud Client Library for Python:
https://googlecloudplatform.github.io/google-cloud-python/
.. _browse the source:
https://github.com/GoogleCloudPlatform/google-cloud-python
.. _report issues:
https://github.com/GoogleCloudPlatform/google-cloud-python/issues


.. _Google Cloud SDK: https://cloud.google.com/sdk/
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def transcribe_onprem(local_file_path, api_endpoint):
import io

# api_endpoint = '0.0.0.0:10000'
# local_file_path = 'resources/brooklyn_bridge.raw'
# local_file_path = '../resources/two_channel_16k.raw'

# Create a gRPC channel to your server
channel = grpc.insecure_channel(target=api_endpoint)
Expand All @@ -42,7 +42,7 @@ def transcribe_onprem(local_file_path, api_endpoint):
language_code = "en-US"

# Sample rate in Hertz of the audio data sent
sample_rate_hertz = 8000
sample_rate_hertz = 16000

# Encoding of audio data sent. This sample sets this explicitly.
# This field is optional for FLAC and WAV audio formats.
Expand Down