Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

feat: adds model adaptation sample #121

Merged
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
217ff44
I updated the comment on the transcribe_async file to reflect time li…
b-loved-dreamer Sep 22, 2020
5dc2211
docs: I updated the comment on the transcribe_async file to reflect t…
b-loved-dreamer Sep 22, 2020
2716e6b
chore: I updated the comments on the transcribe_async file to reflect…
b-loved-dreamer Sep 23, 2020
634bfb9
fix: resolved conflicts
b-loved-dreamer Oct 3, 2020
9dc148e
chore: added a profanity filter sample
b-loved-dreamer Dec 5, 2020
0756e61
feat: adds new multi-region sample
b-loved-dreamer Dec 15, 2020
92dccf2
fix: migrated to speech 2.0.0
b-loved-dreamer Oct 2, 2020
8435999
fix: fixed lint issues
b-loved-dreamer Oct 5, 2020
818c7aa
fix: deleted a duplicate line that calls the recognizer
b-loved-dreamer Oct 28, 2020
81e6b63
docs: repaired region tag mismatch
b-loved-dreamer Oct 28, 2020
7234efe
chore: formatting
b-loved-dreamer Oct 28, 2020
ba6f58f
chore: added ]
b-loved-dreamer Oct 29, 2020
e6ad89f
docs: udated documentation to point to python-speech instead of pytho…
b-loved-dreamer Nov 19, 2020
5c99971
docs: udated documentation to point to python-speech instead of pytho…
b-loved-dreamer Nov 20, 2020
5dd2b2c
docs: udated documentation to point to python-speech instead of pytho…
b-loved-dreamer Nov 20, 2020
356f53a
fix: applied suggested changes
b-loved-dreamer Dec 15, 2020
160940a
fix: applied suggested changes
b-loved-dreamer Dec 15, 2020
342113d
feat: adds model adaptation sample
b-loved-dreamer Mar 12, 2021
8cdd91f
feat: fix issues
b-loved-dreamer Mar 12, 2021
5f58764
feat: fix region tag
b-loved-dreamer Mar 12, 2021
45578ab
feat: fixed region tag
b-loved-dreamer Mar 12, 2021
dbdf6b8
chore: applied suggested changes
b-loved-dreamer Mar 12, 2021
ce7c312
chore: applied suggested changes
b-loved-dreamer Mar 12, 2021
b486aee
chore: applied suggested changes
b-loved-dreamer Mar 12, 2021
9b4602d
chore: applied suggested changes
b-loved-dreamer Mar 12, 2021
53e08b8
chore: applied suggested changes
b-loved-dreamer Mar 13, 2021
c8b2082
chore: applied suggested changes
b-loved-dreamer Mar 13, 2021
c4dcee4
chore: applied suggested changes
b-loved-dreamer Mar 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion samples/microphone/README.rst
Expand Up @@ -18,6 +18,10 @@ This directory contains samples for Google Cloud Speech API. The `Google Cloud S

.. _Google Cloud Speech API: https://cloud.google.com/speech/docs/





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

Expand All @@ -39,7 +43,7 @@ Install Dependencies

.. code-block:: bash

$ git clone https://github.com/googleapis/python-speech.git
$ git clone https://github.com/googleapis/python-speech.git

#. 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.

Expand Down
38 changes: 20 additions & 18 deletions samples/microphone/noxfile.py
Expand Up @@ -38,28 +38,25 @@

TEST_CONFIG = {
# You can opt out from the test for specific Python versions.
'ignored_versions': ["2.7"],

"ignored_versions": ["2.7"],
# Old samples are opted out of enforcing Python type hints
# All new samples should feature them
'enforce_type_hints': False,

"enforce_type_hints": False,
# An envvar key for determining the project id to use. Change it
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
# build specific Cloud project. You can also use your own string
# to use your own Cloud project.
'gcloud_project_env': 'GOOGLE_CLOUD_PROJECT',
"gcloud_project_env": "GOOGLE_CLOUD_PROJECT",
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',

# A dictionary you want to inject into your test. Don't put any
# secrets here. These values will override predefined values.
'envs': {},
"envs": {},
}


try:
# Ensure we can import noxfile_config in the project's directory.
sys.path.append('.')
sys.path.append(".")
from noxfile_config import TEST_CONFIG_OVERRIDE
except ImportError as e:
print("No user noxfile_config found: detail: {}".format(e))
Expand All @@ -74,12 +71,12 @@ def get_pytest_env_vars() -> Dict[str, str]:
ret = {}

# Override the GCLOUD_PROJECT and the alias.
env_key = TEST_CONFIG['gcloud_project_env']
env_key = TEST_CONFIG["gcloud_project_env"]
# This should error out if not set.
ret['GOOGLE_CLOUD_PROJECT'] = os.environ[env_key]
ret["GOOGLE_CLOUD_PROJECT"] = os.environ[env_key]

# Apply user supplied envs.
ret.update(TEST_CONFIG['envs'])
ret.update(TEST_CONFIG["envs"])
return ret


Expand All @@ -88,7 +85,7 @@ def get_pytest_env_vars() -> Dict[str, str]:
ALL_VERSIONS = ["2.7", "3.6", "3.7", "3.8", "3.9"]

# Any default versions that should be ignored.
IGNORED_VERSIONS = TEST_CONFIG['ignored_versions']
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]

TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS])

Expand Down Expand Up @@ -137,7 +134,7 @@ def _determine_local_import_names(start_dir: str) -> List[str]:

@nox.session
def lint(session: nox.sessions.Session) -> None:
if not TEST_CONFIG['enforce_type_hints']:
if not TEST_CONFIG["enforce_type_hints"]:
session.install("flake8", "flake8-import-order")
else:
session.install("flake8", "flake8-import-order", "flake8-annotations")
Expand All @@ -146,9 +143,11 @@ def lint(session: nox.sessions.Session) -> None:
args = FLAKE8_COMMON_ARGS + [
"--application-import-names",
",".join(local_names),
"."
".",
]
session.run("flake8", *args)


#
# Black
#
Expand All @@ -161,6 +160,7 @@ def blacken(session: nox.sessions.Session) -> None:

session.run("black", *python_files)


#
# Sample Tests
#
Expand All @@ -169,7 +169,9 @@ def blacken(session: nox.sessions.Session) -> None:
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]


def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
def _session_tests(
session: nox.sessions.Session, post_install: Callable = None
) -> None:
"""Runs py.test for a particular project."""
if os.path.exists("requirements.txt"):
session.install("-r", "requirements.txt")
Expand Down Expand Up @@ -200,9 +202,9 @@ def py(session: nox.sessions.Session) -> None:
if session.python in TESTED_VERSIONS:
_session_tests(session)
else:
session.skip("SKIPPED: {} tests are disabled for this sample.".format(
session.python
))
session.skip(
"SKIPPED: {} tests are disabled for this sample.".format(session.python)
)


#
Expand Down
45 changes: 6 additions & 39 deletions samples/snippets/README.rst
Expand Up @@ -18,6 +18,10 @@ This directory contains samples for Google Cloud Speech API. The `Google Cloud S

.. _Google Cloud Speech API: https://cloud.google.com/speech/docs/





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

Expand All @@ -39,7 +43,7 @@ Install Dependencies

.. code-block:: bash

$ git clone https://github.com/googleapis/python-speech.git
$ git clone https://github.com/googleapis/python-speech.git

#. 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.

Expand Down Expand Up @@ -132,7 +136,6 @@ To run this sample:

Google Cloud Speech API sample application using the REST API for async
batch processing.

Example usage:
python transcribe_async.py resources/audio.raw
python transcribe_async.py gs://cloud-samples-tests/speech/vr.flac
Expand Down Expand Up @@ -268,42 +271,6 @@ To run this sample:



Transcribe with Model Selection
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=speech/cloud-client/transcribe_auto_punctuation.py,speech/cloud-client/README.rst




To run this sample:

.. code-block:: bash

$ python transcribe_model_selection.py

usage: transcribe_model_selection.py [-h]
[--model {command_and_search,phone_call,video,default}]
path

Google Cloud Speech API sample that demonstrates how to select the model
used for speech recognition.

Example usage:
python transcribe_model_selection.py resources/Google_Gnome.wav --model video
python transcribe_model_selection.py gs://cloud-samples-tests/speech/Google_Gnome.wav --model video

positional arguments:
path File or GCS path for audio file to be recognized

optional arguments:
-h, --help show this help message and exit
--model {command_and_search,phone_call,video,default}
The speech recognition model to use



Beta Samples
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Expand Down Expand Up @@ -358,4 +325,4 @@ to `browse the source`_ and `report issues`_.
https://github.com/GoogleCloudPlatform/google-cloud-python/issues


.. _Google Cloud SDK: https://cloud.google.com/sdk/
.. _Google Cloud SDK: https://cloud.google.com/sdk/
1 change: 1 addition & 0 deletions samples/snippets/multi_region.py
Expand Up @@ -16,6 +16,7 @@


def sync_recognize_with_multi_region_gcs():

# [START speech_multi_region]

# Imports the Google Cloud client library
Expand Down
38 changes: 20 additions & 18 deletions samples/snippets/noxfile.py
Expand Up @@ -38,28 +38,25 @@

TEST_CONFIG = {
# You can opt out from the test for specific Python versions.
'ignored_versions': ["2.7"],

"ignored_versions": ["2.7"],
# Old samples are opted out of enforcing Python type hints
# All new samples should feature them
'enforce_type_hints': False,

"enforce_type_hints": False,
# An envvar key for determining the project id to use. Change it
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
# build specific Cloud project. You can also use your own string
# to use your own Cloud project.
'gcloud_project_env': 'GOOGLE_CLOUD_PROJECT',
"gcloud_project_env": "GOOGLE_CLOUD_PROJECT",
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',

# A dictionary you want to inject into your test. Don't put any
# secrets here. These values will override predefined values.
'envs': {},
"envs": {},
}


try:
# Ensure we can import noxfile_config in the project's directory.
sys.path.append('.')
sys.path.append(".")
from noxfile_config import TEST_CONFIG_OVERRIDE
except ImportError as e:
print("No user noxfile_config found: detail: {}".format(e))
Expand All @@ -74,12 +71,12 @@ def get_pytest_env_vars() -> Dict[str, str]:
ret = {}

# Override the GCLOUD_PROJECT and the alias.
env_key = TEST_CONFIG['gcloud_project_env']
env_key = TEST_CONFIG["gcloud_project_env"]
# This should error out if not set.
ret['GOOGLE_CLOUD_PROJECT'] = os.environ[env_key]
ret["GOOGLE_CLOUD_PROJECT"] = os.environ[env_key]

# Apply user supplied envs.
ret.update(TEST_CONFIG['envs'])
ret.update(TEST_CONFIG["envs"])
return ret


Expand All @@ -88,7 +85,7 @@ def get_pytest_env_vars() -> Dict[str, str]:
ALL_VERSIONS = ["2.7", "3.6", "3.7", "3.8", "3.9"]

# Any default versions that should be ignored.
IGNORED_VERSIONS = TEST_CONFIG['ignored_versions']
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]

TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS])

Expand Down Expand Up @@ -137,7 +134,7 @@ def _determine_local_import_names(start_dir: str) -> List[str]:

@nox.session
def lint(session: nox.sessions.Session) -> None:
if not TEST_CONFIG['enforce_type_hints']:
if not TEST_CONFIG["enforce_type_hints"]:
session.install("flake8", "flake8-import-order")
else:
session.install("flake8", "flake8-import-order", "flake8-annotations")
Expand All @@ -146,9 +143,11 @@ def lint(session: nox.sessions.Session) -> None:
args = FLAKE8_COMMON_ARGS + [
"--application-import-names",
",".join(local_names),
"."
".",
]
session.run("flake8", *args)


#
# Black
#
Expand All @@ -161,6 +160,7 @@ def blacken(session: nox.sessions.Session) -> None:

session.run("black", *python_files)


#
# Sample Tests
#
Expand All @@ -169,7 +169,9 @@ def blacken(session: nox.sessions.Session) -> None:
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]


def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
def _session_tests(
session: nox.sessions.Session, post_install: Callable = None
) -> None:
"""Runs py.test for a particular project."""
if os.path.exists("requirements.txt"):
session.install("-r", "requirements.txt")
Expand Down Expand Up @@ -200,9 +202,9 @@ def py(session: nox.sessions.Session) -> None:
if session.python in TESTED_VERSIONS:
_session_tests(session)
else:
session.skip("SKIPPED: {} tests are disabled for this sample.".format(
session.python
))
session.skip(
"SKIPPED: {} tests are disabled for this sample.".format(session.python)
)


#
Expand Down