Skip to content

Commit ce5e6f1

Browse files
feat: adds model adaptation sample (#121)
* I updated the comment on the transcribe_async file to reflect time limitations on local files for the long_running_recognize * docs: I updated the comment on the transcribe_async file to reflect time limitations on local files for the long_running_recognize * chore: I updated the comments on the transcribe_async file to reflect time limitations on local files for the long_running_recognize * fix: resolved conflicts pick f510e8f chore: I updated the comments on the transcribe_async file to reflect time limitations on local files for the long_running_recognize * chore: added a profanity filter sample * feat: adds new multi-region sample * fix: migrated to speech 2.0.0 * fix: fixed lint issues * fix: deleted a duplicate line that calls the recognizer * docs: repaired region tag mismatch * chore: formatting * chore: added ] * docs: udated documentation to point to python-speech instead of python-docs-samples * docs: udated documentation to point to python-speech instead of python-docs-samples * docs: udated documentation to point to python-speech instead of python-docs-samples * fix: applied suggested changes * fix: applied suggested changes * feat: adds model adaptation sample * feat: fix issues * feat: fix region tag * feat: fixed region tag * chore: applied suggested changes * chore: applied suggested changes * chore: applied suggested changes * chore: applied suggested changes * chore: applied suggested changes * chore: applied suggested changes * chore: applied suggested changes
1 parent 32619e9 commit ce5e6f1

8 files changed

+205
-77
lines changed

speech/microphone/README.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ This directory contains samples for Google Cloud Speech API. The `Google Cloud S
1818

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

21+
22+
23+
24+
2125
Setup
2226
-------------------------------------------------------------------------------
2327

@@ -39,7 +43,7 @@ Install Dependencies
3943

4044
.. code-block:: bash
4145
42-
$ git clone https://github.com/googleapis/python-speech.git
46+
$ git clone https://github.com/googleapis/python-speech.git
4347
4448
#. 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.
4549

speech/microphone/noxfile.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,25 @@
3838

3939
TEST_CONFIG = {
4040
# You can opt out from the test for specific Python versions.
41-
'ignored_versions': ["2.7"],
42-
41+
"ignored_versions": ["2.7"],
4342
# Old samples are opted out of enforcing Python type hints
4443
# All new samples should feature them
45-
'enforce_type_hints': False,
46-
44+
"enforce_type_hints": False,
4745
# An envvar key for determining the project id to use. Change it
4846
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
4947
# build specific Cloud project. You can also use your own string
5048
# to use your own Cloud project.
51-
'gcloud_project_env': 'GOOGLE_CLOUD_PROJECT',
49+
"gcloud_project_env": "GOOGLE_CLOUD_PROJECT",
5250
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
53-
5451
# A dictionary you want to inject into your test. Don't put any
5552
# secrets here. These values will override predefined values.
56-
'envs': {},
53+
"envs": {},
5754
}
5855

5956

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

7673
# Override the GCLOUD_PROJECT and the alias.
77-
env_key = TEST_CONFIG['gcloud_project_env']
74+
env_key = TEST_CONFIG["gcloud_project_env"]
7875
# This should error out if not set.
79-
ret['GOOGLE_CLOUD_PROJECT'] = os.environ[env_key]
76+
ret["GOOGLE_CLOUD_PROJECT"] = os.environ[env_key]
8077

8178
# Apply user supplied envs.
82-
ret.update(TEST_CONFIG['envs'])
79+
ret.update(TEST_CONFIG["envs"])
8380
return ret
8481

8582

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

9087
# Any default versions that should be ignored.
91-
IGNORED_VERSIONS = TEST_CONFIG['ignored_versions']
88+
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]
9289

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

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

138135
@nox.session
139136
def lint(session: nox.sessions.Session) -> None:
140-
if not TEST_CONFIG['enforce_type_hints']:
137+
if not TEST_CONFIG["enforce_type_hints"]:
141138
session.install("flake8", "flake8-import-order")
142139
else:
143140
session.install("flake8", "flake8-import-order", "flake8-annotations")
@@ -146,9 +143,11 @@ def lint(session: nox.sessions.Session) -> None:
146143
args = FLAKE8_COMMON_ARGS + [
147144
"--application-import-names",
148145
",".join(local_names),
149-
"."
146+
".",
150147
]
151148
session.run("flake8", *args)
149+
150+
152151
#
153152
# Black
154153
#
@@ -161,6 +160,7 @@ def blacken(session: nox.sessions.Session) -> None:
161160

162161
session.run("black", *python_files)
163162

163+
164164
#
165165
# Sample Tests
166166
#
@@ -169,7 +169,9 @@ def blacken(session: nox.sessions.Session) -> None:
169169
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]
170170

171171

172-
def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
172+
def _session_tests(
173+
session: nox.sessions.Session, post_install: Callable = None
174+
) -> None:
173175
"""Runs py.test for a particular project."""
174176
if os.path.exists("requirements.txt"):
175177
session.install("-r", "requirements.txt")
@@ -200,9 +202,9 @@ def py(session: nox.sessions.Session) -> None:
200202
if session.python in TESTED_VERSIONS:
201203
_session_tests(session)
202204
else:
203-
session.skip("SKIPPED: {} tests are disabled for this sample.".format(
204-
session.python
205-
))
205+
session.skip(
206+
"SKIPPED: {} tests are disabled for this sample.".format(session.python)
207+
)
206208

207209

208210
#

speech/snippets/README.rst

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ This directory contains samples for Google Cloud Speech API. The `Google Cloud S
1818

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

21+
22+
23+
24+
2125
Setup
2226
-------------------------------------------------------------------------------
2327

@@ -39,7 +43,7 @@ Install Dependencies
3943

4044
.. code-block:: bash
4145
42-
$ git clone https://github.com/googleapis/python-speech.git
46+
$ git clone https://github.com/googleapis/python-speech.git
4347
4448
#. 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.
4549

@@ -132,7 +136,6 @@ To run this sample:
132136
133137
Google Cloud Speech API sample application using the REST API for async
134138
batch processing.
135-
136139
Example usage:
137140
python transcribe_async.py resources/audio.raw
138141
python transcribe_async.py gs://cloud-samples-tests/speech/vr.flac
@@ -268,42 +271,6 @@ To run this sample:
268271
269272
270273
271-
Transcribe with Model Selection
272-
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
273-
274-
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
275-
: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
276-
277-
278-
279-
280-
To run this sample:
281-
282-
.. code-block:: bash
283-
284-
$ python transcribe_model_selection.py
285-
286-
usage: transcribe_model_selection.py [-h]
287-
[--model {command_and_search,phone_call,video,default}]
288-
path
289-
290-
Google Cloud Speech API sample that demonstrates how to select the model
291-
used for speech recognition.
292-
293-
Example usage:
294-
python transcribe_model_selection.py resources/Google_Gnome.wav --model video
295-
python transcribe_model_selection.py gs://cloud-samples-tests/speech/Google_Gnome.wav --model video
296-
297-
positional arguments:
298-
path File or GCS path for audio file to be recognized
299-
300-
optional arguments:
301-
-h, --help show this help message and exit
302-
--model {command_and_search,phone_call,video,default}
303-
The speech recognition model to use
304-
305-
306-
307274
Beta Samples
308275
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
309276

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

360327

361-
.. _Google Cloud SDK: https://cloud.google.com/sdk/
328+
.. _Google Cloud SDK: https://cloud.google.com/sdk/

speech/snippets/multi_region.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717

1818
def sync_recognize_with_multi_region_gcs():
19+
1920
# [START speech_multi_region]
2021

2122
# Imports the Google Cloud client library

speech/snippets/noxfile.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,25 @@
3838

3939
TEST_CONFIG = {
4040
# You can opt out from the test for specific Python versions.
41-
'ignored_versions': ["2.7"],
42-
41+
"ignored_versions": ["2.7"],
4342
# Old samples are opted out of enforcing Python type hints
4443
# All new samples should feature them
45-
'enforce_type_hints': False,
46-
44+
"enforce_type_hints": False,
4745
# An envvar key for determining the project id to use. Change it
4846
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
4947
# build specific Cloud project. You can also use your own string
5048
# to use your own Cloud project.
51-
'gcloud_project_env': 'GOOGLE_CLOUD_PROJECT',
49+
"gcloud_project_env": "GOOGLE_CLOUD_PROJECT",
5250
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
53-
5451
# A dictionary you want to inject into your test. Don't put any
5552
# secrets here. These values will override predefined values.
56-
'envs': {},
53+
"envs": {},
5754
}
5855

5956

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

7673
# Override the GCLOUD_PROJECT and the alias.
77-
env_key = TEST_CONFIG['gcloud_project_env']
74+
env_key = TEST_CONFIG["gcloud_project_env"]
7875
# This should error out if not set.
79-
ret['GOOGLE_CLOUD_PROJECT'] = os.environ[env_key]
76+
ret["GOOGLE_CLOUD_PROJECT"] = os.environ[env_key]
8077

8178
# Apply user supplied envs.
82-
ret.update(TEST_CONFIG['envs'])
79+
ret.update(TEST_CONFIG["envs"])
8380
return ret
8481

8582

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

9087
# Any default versions that should be ignored.
91-
IGNORED_VERSIONS = TEST_CONFIG['ignored_versions']
88+
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]
9289

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

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

138135
@nox.session
139136
def lint(session: nox.sessions.Session) -> None:
140-
if not TEST_CONFIG['enforce_type_hints']:
137+
if not TEST_CONFIG["enforce_type_hints"]:
141138
session.install("flake8", "flake8-import-order")
142139
else:
143140
session.install("flake8", "flake8-import-order", "flake8-annotations")
@@ -146,9 +143,11 @@ def lint(session: nox.sessions.Session) -> None:
146143
args = FLAKE8_COMMON_ARGS + [
147144
"--application-import-names",
148145
",".join(local_names),
149-
"."
146+
".",
150147
]
151148
session.run("flake8", *args)
149+
150+
152151
#
153152
# Black
154153
#
@@ -161,6 +160,7 @@ def blacken(session: nox.sessions.Session) -> None:
161160

162161
session.run("black", *python_files)
163162

163+
164164
#
165165
# Sample Tests
166166
#
@@ -169,7 +169,9 @@ def blacken(session: nox.sessions.Session) -> None:
169169
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]
170170

171171

172-
def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
172+
def _session_tests(
173+
session: nox.sessions.Session, post_install: Callable = None
174+
) -> None:
173175
"""Runs py.test for a particular project."""
174176
if os.path.exists("requirements.txt"):
175177
session.install("-r", "requirements.txt")
@@ -200,9 +202,9 @@ def py(session: nox.sessions.Session) -> None:
200202
if session.python in TESTED_VERSIONS:
201203
_session_tests(session)
202204
else:
203-
session.skip("SKIPPED: {} tests are disabled for this sample.".format(
204-
session.python
205-
))
205+
session.skip(
206+
"SKIPPED: {} tests are disabled for this sample.".format(session.python)
207+
)
206208

207209

208210
#

0 commit comments

Comments
 (0)