Giter Site home page Giter Site logo

python-speech's Introduction

NOTE:This github repository is archived. The repository contents and history have moved to google-cloud-python.

Python Client for Cloud Speech API

stable pypi versions

Cloud Speech API: enables easy integration of Google speech recognition technologies into developer applications. Send audio and receive a text transcription from the Speech-to-Text API service.

Quick Start

In order to use this library, you first need to go through the following steps:

  1. Select or create a Cloud Platform project.
  2. Enable billing for your project.
  3. Enable the Cloud Speech API.
  4. Setup Authentication.

Installation

Install this library in a virtual environment using venv. venv is a tool that creates isolated Python environments. These isolated environments can have separate versions of Python packages, which allows you to isolate one project's dependencies from the dependencies of other projects.

With venv, it's possible to install this library without needing system install permissions, and without clashing with the installed system dependencies.

Code samples and snippets

Code samples and snippets live in the samples/ folder.

Supported Python Versions

Our client libraries are compatible with all current active and maintenance versions of Python.

Python >= 3.7

Unsupported Python Versions

Python <= 3.6

If you are using an end-of-life version of Python, we recommend that you update as soon as possible to an actively supported version.

Mac/Linux
python3 -m venv <your-env>
source <your-env>/bin/activate
pip install google-cloud-speech
Windows
py -m venv <your-env>
.\<your-env>\Scripts\activate
pip install google-cloud-speech

Next Steps

python-speech's People

Contributors

anguillanneuf avatar b-loved-dreamer avatar busunkim96 avatar chemelnucfin avatar crwilcox avatar czahedi avatar dandhlee avatar daspecster avatar dhermes avatar dizcology avatar dpebot avatar gcf-owl-bot[bot] avatar gguuss avatar happyhuman avatar jameszhao00 avatar jerjou avatar lukesneeringer avatar munkhuushmgl avatar nicain avatar nitsanshai avatar nnegrey avatar parthea avatar release-please[bot] avatar renovate-bot avatar theacodes avatar tseaver avatar tswast avatar vinnysenthil avatar wangbill-google avatar yoshi-automation avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-speech's Issues

Avoiding high billing with infinite stream

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Dear community,

I am seeing on my Console the billing tendency that Speech-To-Text API has a lot of usage when using infinite stream recognition. Is there a way to mitigate high costs for real-time transcription? The stream is open several hours a day but it's rarely used for the whole time. Will be VAD a practical solution?

Cheers,
Paulo

speech_contexts results in type error: expected v1.SpeechContext, got SpeechContext

Please run down the following list and make sure you've tried the usual "quick fixes":

Environment details

  • OS type and version: MacOS Catalina
  • Python version: 3.8
  • pip version: 20.2.3
  • google-cloud-speech version: 2.0.0

Steps to reproduce

  1. Fill in the values needed and run code below

Code example

from google.cloud import speech
client = speech.SpeechClient.from_service_account_json("keyfile_here")
config = {
        "language_code": "en-US",
        "encoding": speech.RecognitionConfig.AudioEncoding.LINEAR16,
        "speech_contexts": [speech.SpeechContext(phrases=["test", "two"])],
}
client.long_running_recognize(request={
       "config": config,
       "audio": speech.RecognitionAudio(uri="<URI_HERE>"),
}

Without the speech_contexts key, this is successful and doesn't encounter errors. But with speech_contexts, I get the error below.

Stack trace

  File "my_project/gcloud_stt.py", line 118, in transcribe_storage_uri
    response = _get_client().long_running_recognize(
  File ".../site-packages/google/cloud/speech_v1/services/speech/client.py", line 410, in long_running_recognize
    request = cloud_speech.LongRunningRecognizeRequest(request)
  File ".../site-packages/proto/message.py", line 416, in __init__
    pb_value = marshal.to_proto(pb_type, value)
  File ".../site-packages/proto/marshal/marshal.py", line 205, in to_proto
    pb_value = rule.to_proto(value)
  File ".../site-packages/proto/marshal/rules/message.py", line 32, in to_proto
    return self._descriptor(**value)
TypeError: Parameter to MergeFrom() must be instance of same class: expected google.cloud.speech.v1.SpeechContext got SpeechContext.

400 Inline audio exceeds duration limit

I am running speech to text with python and I have audio files larger than 60 seconds, I get the following error:
google.api_core.exceptions.InvalidArgument: 400 Inline audio exceeds duration limit. Please use a GCS URI.

I understand that it exceeds the 60 seconds duration quota for the files to be read directly from the file system.

I need to know how to upload the file to GSC and get back it's URI using Python.

Cant run Demo software

First time user. I cant get the quickstart python code to run. I keep getting the following error from line 14

"AttributeError: 'Module' object has no attribute "RecognitionAudio'

what might be causing this?

-Joe Virden

Await rpc result in 'SpeechAsyncClient.streaming_recognize'

Is your feature request related to a problem? Please describe.
It is extremely confusing that method streaming_recognize in SpeechAsyncClient class doesn't await on response and returns coroutine object instead of async iterator. Besides that returning a coroutine is AFAIK a quite unusual practice, it also contradicts to what documentation says.

The other two methods in SpeechAsyncClient class (recognize and long_running_recognize) await for the rpc to complete and return the result, which is natural and expected behaviour. Method streaming_recognize in SpeechClient class returns iterator. I see no reason why its asynchronous counterpart should behave differently.

Describe the solution you'd like
Declare streaming_recognize method as a coroutine. Then, await on rpc(...) to obtain the response in the form of async iterator. Finally, return response.

Synthesis failed for python-speech

Hello! Autosynth couldn't regenerate python-speech. ๐Ÿ’”

Here's the output from running synth.py:

_python/requirements.txt (line 4))
  Using cached https://files.pythonhosted.org/packages/30/9e/f663a2aa66a09d838042ae1a2c5659828bb9b41ea3a6efa20a20fd92b121/Jinja2-2.11.2-py2.py3-none-any.whl
  Saved ./Jinja2-2.11.2-py2.py3-none-any.whl
Collecting MarkupSafe==1.1.1 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 5))
  Using cached https://files.pythonhosted.org/packages/b2/5f/23e0023be6bb885d00ffbefad2942bc51a620328ee910f64abe5a8d18dd1/MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
  Saved ./MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
Collecting protobuf==3.13.0 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 6))
  Using cached https://files.pythonhosted.org/packages/30/79/510974552cebff2ba04038544799450defe75e96ea5f1675dbf72cc8744f/protobuf-3.13.0-cp36-cp36m-manylinux1_x86_64.whl
  Saved ./protobuf-3.13.0-cp36-cp36m-manylinux1_x86_64.whl
Collecting pypandoc==1.5 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 7))
  Using cached https://files.pythonhosted.org/packages/d6/b7/5050dc1769c8a93d3ec7c4bd55be161991c94b8b235f88bf7c764449e708/pypandoc-1.5.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmpfs/tmp/tmp28zrdfc3/setuptools-tmp/setuptools/__init__.py", line 6, in <module>
        import distutils.core
      File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/_distutils_hack/__init__.py", line 82, in create_module
        return importlib.import_module('._distutils', 'setuptools')
      File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    ModuleNotFoundError: No module named 'setuptools._distutils'
    
    ----------------------------------------
 (Command "python setup.py egg_info" failed with error code 1 in /tmpfs/tmp/pip-build-8tscdxgz/pypandoc/
)
ERROR: no such package '@gapic_generator_python_pip_deps//': pip_import failed: Collecting click==7.1.2 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 1))
  Using cached https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl
  Saved ./click-7.1.2-py2.py3-none-any.whl
Collecting google-api-core==1.22.1 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 2))
  Using cached https://files.pythonhosted.org/packages/e0/2d/7c6c75013105e1d2b6eaa1bf18a56995be1dbc673c38885aea31136e9918/google_api_core-1.22.1-py2.py3-none-any.whl
  Saved ./google_api_core-1.22.1-py2.py3-none-any.whl
Collecting googleapis-common-protos==1.52.0 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/03/74/3956721ea1eb4bcf7502a311fdaa60b85bd751de4e57d1943afe9b334141/googleapis_common_protos-1.52.0-py2.py3-none-any.whl
  Saved ./googleapis_common_protos-1.52.0-py2.py3-none-any.whl
Collecting jinja2==2.11.2 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 4))
  Using cached https://files.pythonhosted.org/packages/30/9e/f663a2aa66a09d838042ae1a2c5659828bb9b41ea3a6efa20a20fd92b121/Jinja2-2.11.2-py2.py3-none-any.whl
  Saved ./Jinja2-2.11.2-py2.py3-none-any.whl
Collecting MarkupSafe==1.1.1 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 5))
  Using cached https://files.pythonhosted.org/packages/b2/5f/23e0023be6bb885d00ffbefad2942bc51a620328ee910f64abe5a8d18dd1/MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
  Saved ./MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
Collecting protobuf==3.13.0 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 6))
  Using cached https://files.pythonhosted.org/packages/30/79/510974552cebff2ba04038544799450defe75e96ea5f1675dbf72cc8744f/protobuf-3.13.0-cp36-cp36m-manylinux1_x86_64.whl
  Saved ./protobuf-3.13.0-cp36-cp36m-manylinux1_x86_64.whl
Collecting pypandoc==1.5 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 7))
  Using cached https://files.pythonhosted.org/packages/d6/b7/5050dc1769c8a93d3ec7c4bd55be161991c94b8b235f88bf7c764449e708/pypandoc-1.5.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmpfs/tmp/tmp28zrdfc3/setuptools-tmp/setuptools/__init__.py", line 6, in <module>
        import distutils.core
      File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/_distutils_hack/__init__.py", line 82, in create_module
        return importlib.import_module('._distutils', 'setuptools')
      File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    ModuleNotFoundError: No module named 'setuptools._distutils'
    
    ----------------------------------------
 (Command "python setup.py egg_info" failed with error code 1 in /tmpfs/tmp/pip-build-8tscdxgz/pypandoc/
)
INFO: Elapsed time: 2.168s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)

Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 102, in <module>
    main()
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 94, in main
    spec.loader.exec_module(synth_module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/kbuilder/.cache/synthtool/python-speech/synth.py", line 33, in <module>
    include_protos=True,
  File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 46, in py_library
    return self._generate_code(service, version, "python", **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 183, in _generate_code
    shell.run(bazel_run_args)
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 39, in run
    raise exc
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 33, in run
    encoding="utf-8",
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['bazel', '--max_idle_secs=240', 'build', '//google/cloud/speech/v1p1beta1:speech-v1p1beta1-py']' returned non-zero exit status 1.
2020-08-31 05:24:54,869 autosynth [ERROR] > Synthesis failed
2020-08-31 05:24:54,869 autosynth [DEBUG] > Running: git reset --hard HEAD
HEAD is now at 4214630 docs: remove example usage from READMe (#46)
2020-08-31 05:24:54,874 autosynth [DEBUG] > Running: git checkout autosynth
Switched to branch 'autosynth'
2020-08-31 05:24:54,879 autosynth [DEBUG] > Running: git clean -fdx
Removing __pycache__/
Removing google/__pycache__/
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 690, in <module>
    main()
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 539, in main
    return _inner_main(temp_dir)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 670, in _inner_main
    commit_count = synthesize_loop(x, multiple_prs, change_pusher, synthesizer)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 375, in synthesize_loop
    has_changes = toolbox.synthesize_version_in_new_branch(synthesizer, youngest)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 273, in synthesize_version_in_new_branch
    synthesizer.synthesize(synth_log_path, self.environ)
  File "/tmpfs/src/github/synthtool/autosynth/synthesizer.py", line 120, in synthesize
    synth_proc.check_returncode()  # Raise an exception.
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 389, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.

Google internal developers can see the full log here.

Question: long_running_recognize vs splitting the audio file

Would long_running_recognize output better results while using the speaker diarization feature vs splitting the audio file in chunks of 15 seconds for example and sending them one by one to the recognizer?

When is long_running_recognize preferred to be used?

Synthesis failed for python-speech

Hello! Autosynth couldn't regenerate python-speech. ๐Ÿ’”

Here's the output from running synth.py:

tp.bzl:296:16):
 - <builtin>
 - /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:108:1
Loading: 0 packages loaded
Loading: 0 packages loaded
INFO: SHA256 (https://github.com/googleapis/gapic-generator/archive/b7033a61dbfc7f1ad856b17299cf8aeb688a94f4.zip) = 5318c9464c4b7f337992123eeeae2282f22ed83d0c1d13018bd18b13a3009b34
Loading: 0 packages loaded
DEBUG: Rule 'com_google_api_codegen' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "5318c9464c4b7f337992123eeeae2282f22ed83d0c1d13018bd18b13a3009b34"
DEBUG: Call stack for the definition of repository 'com_google_api_codegen' which is a http_archive (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):
 - <builtin>
 - /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:62:1
INFO: SHA256 (https://github.com/googleapis/protoc-java-resource-names-plugin/archive/2b04af0971699d6f042e8b5a6683487a40919a92.zip) = e06b4805df2b123fb494466b2995eb18b5801e6a553bc83669cf02bc8740fba9
DEBUG: Rule 'com_google_protoc_java_resource_names_plugin' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "e06b4805df2b123fb494466b2995eb18b5801e6a553bc83669cf02bc8740fba9"
DEBUG: Call stack for the definition of repository 'com_google_protoc_java_resource_names_plugin' which is a http_archive (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):
 - <builtin>
 - /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:136:1
INFO: SHA256 (https://github.com/googleapis/protoc-docs-plugin/archive/fa40c6ad56d6e98d3bd99fcb2b8c59d097430a7e.zip) = 3345377ac2a051d3a78c4caad4656d3db5c05be8149404ab00232d6811bc3d28
DEBUG: Rule 'protoc_docs_plugin' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "3345377ac2a051d3a78c4caad4656d3db5c05be8149404ab00232d6811bc3d28"
DEBUG: Call stack for the definition of repository 'protoc_docs_plugin' which is a http_archive (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):
 - <builtin>
 - /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:160:1
Loading: 0 packages loaded
INFO: SHA256 (https://github.com/bazelbuild/bazel-gazelle/archive/0.17.0.zip) = 55d4c42482dc5d81e89cb96998fc9f05a108ee17ae493a4175a7b99a05be5380
DEBUG: Rule 'bazel_gazelle' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "55d4c42482dc5d81e89cb96998fc9f05a108ee17ae493a4175a7b99a05be5380"
DEBUG: Call stack for the definition of repository 'bazel_gazelle' which is a http_archive (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):
 - <builtin>
 - /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:194:1
Loading: 0 packages loaded
    currently loading: google/cloud/speech/v1p1beta1
INFO: SHA256 (https://github.com/grpc/grpc-java/archive/v1.25.0.zip) = e44ebf25c8885233b15d522e3349c9b495945adea5f3e1d5a287a9ec437ecec5
DEBUG: Rule 'io_grpc_grpc_java' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "e44ebf25c8885233b15d522e3349c9b495945adea5f3e1d5a287a9ec437ecec5"
DEBUG: Call stack for the definition of repository 'io_grpc_grpc_java' which is a http_archive (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):
 - <builtin>
 - /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/com_google_api_gax_java/repositories.bzl:114:5
 - /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/com_google_api_gax_java/repositories.bzl:60:5
 - /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:123:1
Analyzing: target //google/cloud/speech/v1p1beta1:speech-v1p1beta1-py (1 packages loaded, 0 targets configured)
INFO: Call stack for the definition of repository 'go_sdk' which is a _go_download_sdk (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/io_bazel_rules_go/go/private/sdk.bzl:53:20):
 - <builtin>
 - /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/io_bazel_rules_go/go/private/sdk.bzl:65:5
 - /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/io_bazel_rules_go/go/toolchain/toolchains.bzl:379:13
 - /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:191:1
ERROR: While resolving toolchains for target @pypi_black//:black: invalid registered toolchain '@gapic_generator_python//:pyenv3_toolchain': no such package '@gapic_generator_python//': The repository '@gapic_generator_python' could not be resolved
ERROR: Analysis of target '//google/cloud/speech/v1p1beta1:speech-v1p1beta1-py' failed; build aborted: invalid registered toolchain '@gapic_generator_python//:pyenv3_toolchain': no such package '@gapic_generator_python//': The repository '@gapic_generator_python' could not be resolved
INFO: Elapsed time: 8.333s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (31 packages loaded, 171 targets configured)
FAILED: Build did NOT complete successfully (31 packages loaded, 171 targets configured)

2020-06-20 08:40:17,591 synthtool [DEBUG] > Wrote metadata to synth.metadata.
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 102, in <module>
    main()
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 94, in main
    spec.loader.exec_module(synth_module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/kbuilder/.cache/synthtool/python-speech/synth.py", line 33, in <module>
    include_protos=True,
  File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 46, in py_library
    return self._generate_code(service, version, "python", **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 180, in _generate_code
    shell.run(bazel_run_args)
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 39, in run
    raise exc
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 33, in run
    encoding="utf-8",
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['bazel', '--max_idle_secs=60', 'build', '//google/cloud/speech/v1p1beta1:speech-v1p1beta1-py']' returned non-zero exit status 1.
2020-06-20 08:40:17,670 autosynth [ERROR] > Synthesis failed
2020-06-20 08:40:17,670 autosynth [DEBUG] > Running: git reset --hard HEAD
HEAD is now at 0d4d2c2 chore: Migrate python-speech synth.py from artman to bazel (#21)
2020-06-20 08:40:17,677 autosynth [DEBUG] > Running: git checkout autosynth-self
Switched to branch 'autosynth-self'
2020-06-20 08:40:17,682 autosynth [ERROR] > Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.
2020-06-20 08:40:17,885 autosynth [INFO] > PR already exists: https://github.com/googleapis/python-speech/pull/33
2020-06-20 08:40:17,885 autosynth [DEBUG] > Running: git clean -fdx
Removing __pycache__/
Removing google/__pycache__/
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 649, in <module>
    main()
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 506, in main
    return _inner_main(temp_dir)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 629, in _inner_main
    commit_count = synthesize_loop(x, multiple_prs, change_pusher, synthesizer)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 367, in synthesize_loop
    synthesize_inner_loop(fork, synthesizer)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 411, in synthesize_inner_loop
    synthesizer, len(toolbox.versions) - 1
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 266, in synthesize_version_in_new_branch
    synthesizer.synthesize(synth_log_path, self.environ)
  File "/tmpfs/src/github/synthtool/autosynth/synthesizer.py", line 120, in synthesize
    synth_proc.check_returncode()  # Raise an exception.
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 389, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.

Google internal developers can see the full log here.

GRPC Ver 1.22.0 DNS resolution failed

When I created the channel for Google Speech Client through the proxy(also PAC), I got the DNS resolution failed.This porblem only occur in my customer side but do not occur in my company proxy. Can you advice for this issue and also what information need for to do this from my customer side?

My environment informations are following.

C# / net462 gRPC 1.22.0 , Google.cloud.speech.v1 Windows 10

My codes are following.

var cred = GoogleAuthentication.GetServiceAccountCredential(GoogleSpeech.SpeechClient.DefaultScopes);
ChannelCredentials channelCredentials = cred.ToChannelCredentials();
Channel channel = new Channel(GoogleSpeech.SpeechClient.DefaultEndpoint.Host,GoogleSpeech.SpeechClient.DefaultEndpoint.Port, channelCredentials);
GoogleSpeechClient = GoogleSpeech.SpeechClient.Create(channel);

Here is my grpc debug log.

I0205 11:22:45.653978 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\transport\chttp2\client\secure\secure_channel_create.cc:198: grpc_secure_channel_create(creds=00000204FCF267F0, target=speech.googleapis.com:443, args=00000204A2666570, reserved=0000000000000000) I0205 11:22:45.653978 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc:1184: chand=00000204FDDCC020: creating client_channel for channel stack 00000204FDDCBFA0 I0205 11:22:45.653978 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc:1087: chand=00000204FDDCC020: update: state=IDLE picker=00000204A2666770 I0205 11:22:45.653978 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc:1259: chand=00000204FDDCC020: created resolving_lb_policy=000002049E1046E0 I0205 11:22:45.655974 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\metadata_array.cc:29: grpc_metadata_array_init(array=00000204A2666690) I0205 11:22:45.655974 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\call.cc:1922: grpc_call_start_batch(call=000002049E2DB960, ops=00000009C19FD620, nops=2, tag=00000204A2557130, reserved=0000000000000000) I0205 11:22:45.655974 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\call.cc:1526: ops[0]: SEND_INITIAL_METADATA key=x-goog-api-client value=67 6c 2d 64 6f 74 6e 65 74 2f 34 2e 36 2e 32 20 67 63 63 6c 2f 31 2e 32 2e 30 20 67 61 70 69 63 2f 31 2e 32 2e 30 20 67 61 78 2f 32 2e 39 2e 30 20 67 72 70 63 2f 31 2e 32 32 2e 30 'gl-dotnet/4.6.2 gccl/1.2.0 gapic/1.2.0 gax/2.9.0 grpc/1.22.0' I0205 11:22:45.655974 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\call.cc:1526: ops[1]: RECV_STATUS_ON_CLIENT metadata=00000204A2557190 status=00000204A25571A8 details=00000204A25571B0 I0205 11:22:45.655974 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc:3499: chand=00000204FDDCC020 calld=000002049E2DC310: LB pick returned QUEUE (connected_subchannel=0000000000000000, error="No Error") I0205 11:22:45.655974 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc:3373: chand=00000204FDDCC020 calld=000002049E2DC310: adding to queued picks list I0205 11:22:45.655974 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolving_lb_policy.cc:283: resolving_lb=000002049E1046E0: starting name resolution I0205 11:22:45.655974 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc:1087: chand=00000204FDDCC020: update: state=CONNECTING picker=00000204A2666AF0 D0205 11:22:45.655974 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:242: Start resolving. I0205 11:22:45.655974 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc:3499: chand=00000204FDDCC020 calld=000002049E2DC310: LB pick returned QUEUE (connected_subchannel=0000000000000000, error="No Error") I0205 11:22:45.655974 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\call.cc:1922: grpc_call_start_batch(call=000002049E2DB960, ops=00000009C19FD680, nops=1, tag=00000204A2557200, reserved=0000000000000000) I0205 11:22:45.655974 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\call.cc:1526: ops[0]: RECV_INITIAL_METADATA ptr=00000204A2557238 I0205 11:22:45.657332 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\call.cc:1922: grpc_call_start_batch(call=000002049E2DB960, ops=00000009C19FDD20, nops=1, tag=00000204A2556EC0, reserved=0000000000000000) I0205 11:22:45.657332 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\call.cc:1526: ops[0]: SEND_MESSAGE ptr=00000204FDDE43D0 I0205 11:22:45.677333 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native*dns_resolver.cc:185: dns resolution failed (will retry): {"created":"@1580869365.677000000","description":"OS Error","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\iomgr\resolve_address_windows.cc","file_line":96,"os_error":"No such host is known.\r\n","syscall":"getaddrinfo","wsa_error":11001}* I0205 11:22:45.677333 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolving_lb_policy.cc:299: resolving_lb=000002049E1046E0: resolver transient failure: {"created":"@1580869365.677000000","description":"DNS resolution failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc","file_line":190,"grpc_status":14,"referenced_errors":[{"created":"@1580869365.677000000","description":"OS Error","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\iomgr\resolve_address_windows.cc","file_line":96,"os_error":"No such host is known.\r\n","syscall":"getaddrinfo","wsa_error":11001}]} I0205 11:22:45.677333 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc:1087: chand=00000204FDDCC020: update: state=TRANSIENT_FAILURE picker=00000204FAC0CC20 D0205 11:22:45.677333 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:202: retrying in 1000 milliseconds I0205 11:22:45.677333 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc:3499: chand=00000204FDDCC020 calld=000002049E2DC310: LB pick returned TRANSIENT_FAILURE (connected_subchannel=0000000000000000, error={"created":"@1580869365.677000000","description":"Resolver transient failure","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolving_lb_policy.cc","file_line":307,"referenced_errors":[{"created":"@1580869365.677000000","description":"DNS resolution failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc","file_line":190,"grpc_status":14,"referenced_errors":[{"created":"@1580869365.677000000","description":"OS Error","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\iomgr\resolve_address_windows.cc","file_line":96,"os_error":"No such host is known.\r\n","syscall":"getaddrinfo","wsa_error":11001}]}]}) I0205 11:22:45.677333 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc:3361: chand=00000204FDDCC020 calld=000002049E2DC310: removing from queued picks list I0205 11:22:45.677333 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc:3308: chand=00000204FDDCC020 calld=000002049E2DC310: failed to pick subchannel: error={"created":"@1580869365.677000000","description":"Failed to pick subchannel","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc","file_line":3528,"referenced_errors":[{"created":"@1580869365.677000000","description":"Resolver transient failure","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolving_lb_policy.cc","file_line":307,"referenced_errors":[{"created":"@1580869365.677000000","description":"DNS resolution failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc","file_line":190,"grpc_status":14,"referenced_errors":[{"created":"@1580869365.677000000","description":"OS Error","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\iomgr\resolve_address_windows.cc","file_line":96,"os_error":"No such host is known.\r\n","syscall":"getaddrinfo","wsa_error":11001}]}]}]} I0205 11:22:45.677333 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\completion_queue.cc:688: cq_end_op_for_next(cq=000002049E247C30, tag=00000204A2557130, error="No Error", done=00007FFDD8C1E1A0, done_arg=000002049E2DC7F0, storage=000002049E2DC840) I0205 11:22:45.677333 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\completion_queue.cc:688: cq_end_op_for_next(cq=000002049E247C30, tag=00000204A2556EC0, error={"created":"@1580869365.677000000","description":"Failed to pick subchannel","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc","file_line":3528,"referenced_errors":[{"created":"@1580869365.677000000","description":"Resolver transient failure","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolving_lb_policy.cc","file_line":307,"referenced_errors":[{"created":"@1580869365.677000000","description":"DNS resolution failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc","file_line":190,"grpc_status":14,"referenced_errors":[{"created":"@1580869365.677000000","description":"OS Error","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\iomgr\resolve_address_windows.cc","file_line":96,"os_error":"No such host is known.\r\n","syscall":"getaddrinfo","wsa_error":11001}]}]}]}, done=00007FFDD8C1E1A0, done_arg=000002049E2DC9B0, storage=000002049E2DCA00) I0205 11:22:45.677333 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\completion_queue.cc:688: cq_end_op_for_next(cq=000002049E247C30, tag=00000204A2557200, error={"created":"@1580869365.677000000","description":"Failed to pick subchannel","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc","file_line":3528,"referenced_errors":[{"created":"@1580869365.677000000","description":"Resolver transient failure","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolving_lb_policy.cc","file_line":307,"referenced_errors":[{"created":"@1580869365.677000000","description":"DNS resolution failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc","file_line":190,"grpc_status":14,"referenced_errors":[{"created":"@1580869365.677000000","description":"OS Error","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\iomgr\resolve_address_windows.cc","file_line":96,"os_error":"No such host is known.\r\n","syscall":"getaddrinfo","wsa_error":11001}]}]}]}, done=00007FFDD8C1E1A0, done_arg=000002049E2DC8D0, storage=000002049E2DC920) I0205 11:22:45.677333 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc:3337: chand=00000204FDDCC020 calld=000002049E2DC310: cancelling queued pick: error={"created":"@1580869365.677000000","description":"Failed to pick subchannel","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc","file_line":3528,"referenced_errors":[{"created":"@1580869365.677000000","description":"Resolver transient failure","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolving_lb_policy.cc","file_line":307,"referenced_errors":[{"created":"@1580869365.677000000","description":"DNS resolution failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc","file_line":190,"grpc_status":14,"referenced_errors":[{"created":"@1580869365.677000000","description":"OS Error","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\iomgr\resolve_address_windows.cc","file_line":96,"os_error":"No such host is known.\r\n","syscall":"getaddrinfo","wsa_error":11001}]}]}]} self=00000204FDD77F90 calld->pick_canceller=0000000000000000 I0205 11:22:45.677333 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\completion_queue.cc:1063: RETURN_EVENT[000002049E247C30]: OP_COMPLETE: tag:00000204A2557130 OK I0205 11:22:45.677333 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\completion_queue.cc:963: grpc_completion_queue_next(cq=000002049E247C30, deadline=gpr_timespec { tv_sec: 9223372036854775807, tv_nsec: 0, clock_type: 1 }, reserved=0000000000000000) I0205 11:22:45.677333 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\completion_queue.cc:1063: RETURN_EVENT[000002049E247C30]: OP_COMPLETE: tag:00000204A2556EC0 ERROR I0205 11:22:45.677333 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\completion_queue.cc:963: grpc_completion_queue_next(cq=000002049E247C30, deadline=gpr_timespec { tv_sec: 9223372036854775807, tv_nsec: 0, clock_type: 1 }, reserved=0000000000000000) I0205 11:22:45.677333 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\completion_queue.cc:1063: RETURN_EVENT[000002049E247C30]: OP_COMPLETE: tag:00000204A2557200 ERROR I0205 11:22:45.678195 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\completion_queue.cc:963: grpc_completion_queue_next(cq=000002049E247C30, deadline=gpr_timespec { tv_sec: 9223372036854775807, tv_nsec: 0, clock_type: 1 }, reserved=0000000000000000) D0205 11:22:45.698018 2218855401520 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:242: Start resolving. I0205 11:22:45.698018 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:185: dns resolution failed (will retry): {"created":"@1580869365.698000000","description":"OS Error","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\iomgr\resolve_address_windows.cc","file_line":96,"os_error":"No such host is known.\r\n","syscall":"getaddrinfo","wsa_error":11001} I0205 11:22:45.698018 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolving_lb_policy.cc:299: resolving_lb=00000204A258E6E0: resolver transient failure: {"created":"@1580869365.698000000","description":"DNS resolution failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc","file_line":190,"grpc_status":14,"referenced_errors":[{"created":"@1580869365.698000000","description":"OS Error","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\iomgr\resolve_address_windows.cc","file_line":96,"os_error":"No such host is known.\r\n","syscall":"getaddrinfo","wsa_error":11001}]} I0205 11:22:45.698987 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc:1087: chand=00000204FDDCDBE0: update: state=TRANSIENT_FAILURE picker=000002049E1EE100 D0205 11:22:45.698987 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:202: retrying in 142172 milliseconds I0205 11:22:45.782621 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\call.cc:1922: grpc_call_start_batch(call=000002049E2DB960, ops=00000009C05FE160, nops=1, tag=00000204A2557130, reserved=0000000000000000) I0205 11:22:45.782621 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\call.cc:1526: ops[0]: RECV_MESSAGE ptr=00000204A2557180 I0205 11:22:45.782621 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\completion_queue.cc:688: cq_end_op_for_next(cq=000002049E247C30, tag=00000204A2557130, error={"created":"@1580869365.677000000","description":"Failed to pick subchannel","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc","file_line":3528,"referenced_errors":[{"created":"@1580869365.677000000","description":"Resolver transient failure","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolving_lb_policy.cc","file_line":307,"referenced_errors":[{"created":"@1580869365.677000000","description":"DNS resolution failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc","file_line":190,"grpc_status":14,"referenced_errors":[{"created":"@1580869365.677000000","description":"OS Error","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\iomgr\resolve_address_windows.cc","file_line":96,"os_error":"No such host is known.\r\n","syscall":"getaddrinfo","wsa_error":11001}]}]}]}, done=00007FFDD8C1E1A0, done_arg=000002049E2DCA90, storage=000002049E2DCAE0) I0205 11:22:45.782621 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\completion_queue.cc:1063: RETURN_EVENT[000002049E247C30]: OP_COMPLETE: tag:00000204A2557130 ERROR I0205 11:22:45.782621 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\completion_queue.cc:963: grpc_completion_queue_next(cq=000002049E247C30, deadline=gpr_timespec { tv_sec: 9223372036854775807, tv_nsec: 0, clock_type: 1 }, reserved=0000000000000000) I0205 11:22:45.783619 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\call.cc:573: grpc_call_unref(c=000002049E2DB960) I0205 11:22:46.370273 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\security\credentials\credentials.cc:43: grpc_channel_credentials_release(creds=00000204FCF267F0) I0205 11:22:46.370273 0 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\security\credentials\credentials.cc:43: grpc_channel_credentials_release(creds=000002049E368640) D0205 11:22:46.676327 2218857935696 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:242: Start resolving. I0205 11:22:46.677361 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:185: dns resolution failed (will retry): {"created":"@1580869366.677000000","description":"OS Error","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\iomgr\resolve_address_windows.cc","file_line":96,"os_error":"No such host is known.\r\n","syscall":"getaddrinfo","wsa_error":11001} I0205 11:22:46.677361 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolving_lb_policy.cc:299: resolving_lb=000002049E1046E0: resolver transient failure: {"created":"@1580869366.677000000","description":"DNS resolution failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc","file_line":190,"grpc_status":14,"referenced_errors":[{"created":"@1580869366.677000000","description":"OS Error","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\iomgr\resolve_address_windows.cc","file_line":96,"os_error":"No such host is known.\r\n","syscall":"getaddrinfo","wsa_error":11001}]} I0205 11:22:46.677361 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc:1087: chand=00000204FDDCC020: update: state=TRANSIENT_FAILURE picker=000002049E0947E0 D0205 11:22:46.677361 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:202: retrying in 1616 milliseconds D0205 11:22:48.293939 2218855401520 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:242: Start resolving. I0205 11:22:48.294441 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:185: dns resolution failed (will retry): {"created":"@1580869368.294000000","description":"OS Error","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\iomgr\resolve_address_windows.cc","file_line":96,"os_error":"No such host is known.\r\n","syscall":"getaddrinfo","wsa_error":11001} I0205 11:22:48.294441 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolving_lb_policy.cc:299: resolving_lb=000002049E1046E0: resolver transient failure: {"created":"@1580869368.294000000","description":"DNS resolution failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc","file_line":190,"grpc_status":14,"referenced_errors":[{"created":"@1580869368.294000000","description":"OS Error","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\iomgr\resolve_address_windows.cc","file_line":96,"os_error":"No such host is known.\r\n","syscall":"getaddrinfo","wsa_error":11001}]} I0205 11:22:48.294441 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc:1087: chand=00000204FDDCC020: update: state=TRANSIENT_FAILURE picker=000002049E094E60 D0205 11:22:48.294441 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:202: retrying in 2336 milliseconds D0205 11:22:50.629492 2218857935696 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:242: Start resolving. I0205 11:22:50.653821 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc:185: dns resolution failed (will retry): {"created":"@1580869370.653000000","description":"OS Error","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\iomgr\resolve_address_windows.cc","file_line":96,"os_error":"No such host is known.\r\n","syscall":"getaddrinfo","wsa_error":11001} I0205 11:22:50.653821 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolving_lb_policy.cc:299: resolving_lb=000002049E1046E0: resolver transient failure: {"created":"@1580869370.654000000","description":"DNS resolution failed","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\resolver\dns\native\dns_resolver.cc","file_line":190,"grpc_status":14,"referenced_errors":[{"created":"@1580869370.653000000","description":"OS Error","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\iomgr\resolve_address_windows.cc","file_line":96,"os_error":"No such host is known.\r\n","syscall":"getaddrinfo","wsa_error":11001}]} I0205 11:22:50.653821 2218856014768 T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\ext\filters\client_channel\client_channel.cc:1087: chand=00000204FDDCC020: update: state=TRANSIENT_FAILURE picker=000002049E0948C0 D0205 11:22:50.653821 221885601

Punctuation with transcribe_streaming_mic

Is it possible to enable punctuation with the transcribe_streaming_mic code? I tried setting enable_automatic_punctuation=True in the RecognitionConfig, but it had no effect.

Badly documented speech_v1.streaming_recognize()

Hello there.

It is clearly stated in the docs that streaming_recognize raises google.gax.errors.GaxError.

However, from what I have seen so far, gax errors (google.gax.grpc) are not used anymore in google speech-to-text, or at least specifically in streaming recognition. From using the library, it seems that gax errors are never raised; instead I only see api_core exceptions, e.g google.api_core.exceptions.OutOfRange.

I believe the docs should be corrected in case gax errors are not used anymore. Furthermore, there should be a list of all possible exceptions raised by a call to streaming_recognize()

Sample test failing with File "/tmFatal Python error: pfSegmentation faults

============================= test session starts ==============================
platform linux -- Python 3.7.7, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
rootdir: /tmpfs/src/github/python-speech
collected 24 items

beta_snippets_test.py [mutex.cc : 422] RAW: Lock blocking 0x5563026fa6c0   @
[mutex.cc : 422] RAW: Lock returning 0x5563026fa6c0   @
double free or corruption (fasttop)
Fatal Python error: Aborted

Thread 0x00007f35979ae600 (most recent call first):
  File "/tmFatal Python error: pfSegmentation faults

/src/github/pynox > Command pytest --junitxml=sponge_log.xml failed with exit code -11
nox > Session py-3.7 failed.

Speech samples test fails occasionally with this error. It does not seem tied to a particular Python version.

#60

Speech to Text API is slow

Hi,

I'm using the guide on "Transcribing long audio files using a Google Cloud Storage file" here.

But the speed is slow when using the "enhanced video" model with "enable_automatic_punctuation". It takes around 2.5 minutes per 10 minutes of audio duration.

Here is my config:

config = speech.RecognitionConfig(
  encoding=speech.RecognitionConfig.AudioEncoding.FLAC,
  audio_channel_count=2,
  language_code="en-US",
  use_enhanced=True,  # Use enhanced model.
  model='video',  # Enhanced model for videos
  enable_word_time_offsets=True,  # Add the word video times (seconds)
  enable_automatic_punctuation=True  # Add punctuation to the transcript.
)
operation = client.long_running_recognize(config=config, audio=audio)

Is there any way we can get a response that is faster. Does it really take this long for the speech recognition model + the NLP punctuation model ~2 minutes for a 10 minute duration audio file?

Thank you so much for your help.

Not possible to set a timeout + long time loop if internet connection disappears(waiting until grpc connection is closed)

Environment details

OS: Ubuntu 18.04.2 LTS Linux 4.15.0-50-generic
Python 3.7.2
google-cloud-speech Version: 1.0.0

Steps to reproduce

  1. Start streaming recognize request with different connection in different thread
  2. Turn off internet connection
  3. Join thread with streaming recognize

Code example

from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types
from google.oauth2 import service_account
from threading import Thread
import pyaudio
import time
import queue


class GoogleSpeechInteraction:

	def __init__(self, google_speech_generator, rate):
		credentials_path = "<path to your credentials>"
		credentials = service_account.Credentials.from_service_account_file(credentials_path)
		self._client = speech.SpeechClient(credentials=credentials)

		recognition_config = types.RecognitionConfig(
					encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
					sample_rate_hertz=rate,
					language_code='en-US')
		self._streaming_config = types.StreamingRecognitionConfig(config=recognition_config)
		self._generator = google_speech_generator

		self._is_converting_data_to_text = False

		self._closed = False
		self._converting_data_to_text_thread = Thread(target=self._convert_data_to_text_function)
		self._converting_data_to_text_thread.daemon = True
		self._converting_data_to_text_thread.start()

	def _convert_data_to_text_function(self):
		while self._is_converting_data_to_text:
			try:
				audio_requests = (types.StreamingRecognizeRequest(audio_content=content)
							for content in self._generator())
				responses = self._client.streaming_recognize(self._streaming_config, audio_requests) # no possibility to set timeout
				for response in responses:
					if not response.results:
						continue

					result = response.results[0]
					if not result.alternatives:
						continue

					if result.is_final:
						transcription = result.alternatives[0].transcript
						print('transcription = {transcription}'.format(transcription=transcription))
			except BaseException as exc:
				print('Handling google speech exception - {exception}'.format(exception=exc))
			time.sleep(1)

	def start(self):
		print("Starting GoogleSpeechInteraction")
		if not self._is_converting_data_to_text:
			self._is_converting_data_to_text = True
			self._converting_data_to_text_thread = Thread(target=self._convert_data_to_text_function)
			self._converting_data_to_text_thread.daemon = True
			self._converting_data_to_text_thread.start()

	def stop(self):
		print("Stopping GoogleSpeechInteraction")
		if self._is_converting_data_to_text:
			self._is_converting_data_to_text = False
			self._converting_data_to_text_thread.join()


class RecordAndTransformAudio:
	def __init__(self):
		self._rate = 16000  # put here your rate
		self._chunk = 1024
		self._channels = 1
		self._format = pyaudio.paInt16

		self._google_speech_audio_buffer = queue.Queue()
		self._is_using_google_speech = False

		self._google_speech_interaction = GoogleSpeechInteraction(self._google_speech_generator, self._rate)

		self._audio_interface = pyaudio.PyAudio()
		self._in_audio_stream = self._audio_interface.open(format=self._format,
													channels=self._channels,
													rate=self._rate,
													input=True,
													start=False,
															frames_per_buffer=self._chunk,
															stream_callback=self._fill_audio_buffer)

	def _fill_audio_buffer(self, in_data, frame_count, time_info, status_flags):
		"""Filling audio buffers continuously"""
		if self._is_using_google_speech:
			self._google_speech_audio_buffer.put(in_data)
		return None, pyaudio.paContinue

	def _google_speech_generator(self):
		while self._is_using_google_speech:
			# Use a blocking get() to ensure there's at least one chunk of
			# data, and stop iteration if the chunk is None, indicating the
			# end of the audio stream.
			chunk = self._google_speech_audio_buffer.get()
			if chunk is None:
				return
			data = [chunk]

			# Now consume whatever other data's still buffered.
			while True:
				try:
					chunk = self._google_speech_audio_buffer.get(block=False)
					if chunk is None:
						return
					data.append(chunk)
				except queue.Empty:
					break
			yield b''.join(data)

	def start(self):
		self._is_using_google_speech = True
		self._in_audio_stream.start_stream()
		self._google_speech_interaction.start()

	def stop(self):
		self._is_using_google_speech = False
		self._in_audio_stream.stop_stream()
		self._google_speech_interaction.stop()


if __name__ == "__main__":
	recordAndTransformAudio = RecordAndTransformAudio()
	try:
		recordAndTransformAudio.start()
		while True:
			time.sleep(1)
	except KeyboardInterrupt as e:
		recordAndTransformAudio.stop()
		print("Exiting...")

Slightly wrong word time offsets after upgrading to v2.1.0

After upgrading Speech from v1.3.2 to v.2.1.0, word time offsets are slightly wrong when doing infinite streaming transcribing.
The first request iteration is identical in both versions. After the first request restart, an offset of ~200msec is created between the versions, accumulating for each new iteration.

After investigation, the root cause is a code introduced (stream pre-fetch) in google-api-core v1.17.0:
https://www.github.com/googleapis/python-api-core/commit/2b103b60ece16a1e1bc98cfda7ec375191a90f75

This was later wrapped with the flag prefetch_first_result:
googleapis/python-api-core@74e0b0f#diff-9aeb5107dac746ab0e51a30c001ca48df095ca511bc881c40ed0c5e71cf7dc73

It seems that Speech is also better with the prefetch disabled, so prefetch_first_result should be set to False for streaming_recognize.
File: google/cloud/speech_v1/services/speech/client.py

def streaming_recognize(
        self,
        requests: Iterator[cloud_speech.StreamingRecognizeRequest] = None,
        *,
        retry: retries.Retry = gapic_v1.method.DEFAULT,
        timeout: float = None,
        metadata: Sequence[Tuple[str, str]] = (),
    ) -> Iterable[cloud_speech.StreamingRecognizeResponse]:

        self._transport.streaming_recognize._prefetch_first_result_ = False

        # Wrap the RPC method; this adds retry and timeout information,
        # and friendly error handling.
        rpc = self._transport._wrapped_methods[self._transport.streaming_recognize]

        # Send the request.
        response = rpc(requests, retry=retry, timeout=timeout, metadata=metadata,)

        # Done; return the response.
        return response

AttributeError: module 'proto' has no attribute 'module'

I'm getting this error while trying to use the SpeechClient from google.cloud module. Any idea?

  File "my_env/lib/python3.8/site-packages/google/cloud/speech_v1/__init__.py", line 18, in <module>
    from .services.speech import SpeechClient
  File "my_env/lib/python3.8/site-packages/google/cloud/speech_v1/services/speech/__init__.py", line 18, in <module>
    from .client import SpeechClient
  File "my_env/lib/python3.8/site-packages/google/cloud/speech_v1/services/speech/client.py", line 47, in <module>
    from google.cloud.speech_v1.types import cloud_speech
  File "my_env/lib/python3.8/site-packages/google/cloud/speech_v1/types/__init__.py", line 18, in <module>
    from .cloud_speech import (
  File "my_env/lib/python3.8/site-packages/google/cloud/speech_v1/types/cloud_speech.py", line 26, in <module>
    __protobuf__ = proto.module(
AttributeError: module 'proto' has no attribute 'module'

google-cloud-speech 2.0.0
protobuf 3.14.0
python 3.8

Synthesis failed for python-speech

Hello! Autosynth couldn't regenerate python-speech. ๐Ÿ’”

Here's the output from running synth.py:

rpc]<2.0.0dev,>=1.14.0->google-cloud-speech==1.3.2->-r /home/kbuilder/.cache/synthtool/python-speech/samples/microphone/requirements.txt (line 1)) (49.6.0)
Requirement already satisfied: google-auth<2.0dev,>=1.21.1 in /tmpfs/src/github/synthtool/env/lib/python3.6/site-packages (from google-api-core[grpc]<2.0.0dev,>=1.14.0->google-cloud-speech==1.3.2->-r /home/kbuilder/.cache/synthtool/python-speech/samples/microphone/requirements.txt (line 1)) (1.21.1)
Requirement already satisfied: requests<3.0.0dev,>=2.18.0 in /tmpfs/src/github/synthtool/env/lib/python3.6/site-packages (from google-api-core[grpc]<2.0.0dev,>=1.14.0->google-cloud-speech==1.3.2->-r /home/kbuilder/.cache/synthtool/python-speech/samples/microphone/requirements.txt (line 1)) (2.24.0)
Requirement already satisfied: grpcio<2.0dev,>=1.29.0; extra == "grpc" in /tmpfs/src/github/synthtool/env/lib/python3.6/site-packages (from google-api-core[grpc]<2.0.0dev,>=1.14.0->google-cloud-speech==1.3.2->-r /home/kbuilder/.cache/synthtool/python-speech/samples/microphone/requirements.txt (line 1)) (1.31.0)
Requirement already satisfied: pyasn1-modules>=0.2.1 in /tmpfs/src/github/synthtool/env/lib/python3.6/site-packages (from google-auth<2.0dev,>=1.21.1->google-api-core[grpc]<2.0.0dev,>=1.14.0->google-cloud-speech==1.3.2->-r /home/kbuilder/.cache/synthtool/python-speech/samples/microphone/requirements.txt (line 1)) (0.2.8)
Requirement already satisfied: cachetools<5.0,>=2.0.0 in /tmpfs/src/github/synthtool/env/lib/python3.6/site-packages (from google-auth<2.0dev,>=1.21.1->google-api-core[grpc]<2.0.0dev,>=1.14.0->google-cloud-speech==1.3.2->-r /home/kbuilder/.cache/synthtool/python-speech/samples/microphone/requirements.txt (line 1)) (4.1.1)
Requirement already satisfied: rsa<5,>=3.1.4; python_version >= "3.5" in /tmpfs/src/github/synthtool/env/lib/python3.6/site-packages (from google-auth<2.0dev,>=1.21.1->google-api-core[grpc]<2.0.0dev,>=1.14.0->google-cloud-speech==1.3.2->-r /home/kbuilder/.cache/synthtool/python-speech/samples/microphone/requirements.txt (line 1)) (4.6)
Requirement already satisfied: certifi>=2017.4.17 in /tmpfs/src/github/synthtool/env/lib/python3.6/site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core[grpc]<2.0.0dev,>=1.14.0->google-cloud-speech==1.3.2->-r /home/kbuilder/.cache/synthtool/python-speech/samples/microphone/requirements.txt (line 1)) (2020.6.20)
Requirement already satisfied: idna<3,>=2.5 in /tmpfs/src/github/synthtool/env/lib/python3.6/site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core[grpc]<2.0.0dev,>=1.14.0->google-cloud-speech==1.3.2->-r /home/kbuilder/.cache/synthtool/python-speech/samples/microphone/requirements.txt (line 1)) (2.10)
Requirement already satisfied: chardet<4,>=3.0.2 in /tmpfs/src/github/synthtool/env/lib/python3.6/site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core[grpc]<2.0.0dev,>=1.14.0->google-cloud-speech==1.3.2->-r /home/kbuilder/.cache/synthtool/python-speech/samples/microphone/requirements.txt (line 1)) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /tmpfs/src/github/synthtool/env/lib/python3.6/site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core[grpc]<2.0.0dev,>=1.14.0->google-cloud-speech==1.3.2->-r /home/kbuilder/.cache/synthtool/python-speech/samples/microphone/requirements.txt (line 1)) (1.25.10)
Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /tmpfs/src/github/synthtool/env/lib/python3.6/site-packages (from pyasn1-modules>=0.2.1->google-auth<2.0dev,>=1.21.1->google-api-core[grpc]<2.0.0dev,>=1.14.0->google-cloud-speech==1.3.2->-r /home/kbuilder/.cache/synthtool/python-speech/samples/microphone/requirements.txt (line 1)) (0.4.8)
Installing collected packages: pyaudio
  Running setup.py install for pyaudio: started
    Running setup.py install for pyaudio: finished with status 'error'
    Complete output from command /tmpfs/src/github/synthtool/env/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmpfs/tmp/pip-install-nc8fg8mu/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmpfs/tmp/pip-record-apzjk7ta/install-record.txt --single-version-externally-managed --compile --install-headers /tmpfs/src/github/synthtool/env/include/site/python3.6/pyaudio:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    copying src/pyaudio.py -> build/lib.linux-x86_64-3.6
    running build_ext
    building '_portaudio' extension
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/src
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tmpfs/src/github/synthtool/env/include -I/home/kbuilder/.pyenv/versions/3.6.9/include/python3.6m -c src/_portaudiomodule.c -o build/temp.linux-x86_64-3.6/src/_portaudiomodule.o
    src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
     #include "portaudio.h"
                           ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/tmpfs/src/github/synthtool/env/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmpfs/tmp/pip-install-nc8fg8mu/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmpfs/tmp/pip-record-apzjk7ta/install-record.txt --single-version-externally-managed --compile --install-headers /tmpfs/src/github/synthtool/env/include/site/python3.6/pyaudio" failed with error code 1 in /tmpfs/tmp/pip-install-nc8fg8mu/pyaudio/
You are using pip version 18.1, however version 20.2.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 102, in <module>
    main()
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 94, in main
    spec.loader.exec_module(synth_module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/kbuilder/.cache/synthtool/python-speech/synth.py", line 84, in <module>
    python.py_samples()
  File "/tmpfs/src/github/synthtool/synthtool/languages/python.py", line 132, in py_samples
    sample_readme_metadata = _get_sample_readme_metadata(sample_project_dir)
  File "/tmpfs/src/github/synthtool/synthtool/languages/python.py", line 85, in _get_sample_readme_metadata
    shell.run([sys.executable, "-m", "pip", "install", "-r", requirements])
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 39, in run
    raise exc
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 33, in run
    encoding="utf-8",
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'pip', 'install', '-r', '/home/kbuilder/.cache/synthtool/python-speech/samples/microphone/requirements.txt']' returned non-zero exit status 1.
2020-09-04 06:30:43,215 autosynth [ERROR] > Synthesis failed
2020-09-04 06:30:43,215 autosynth [DEBUG] > Running: git reset --hard HEAD
HEAD is now at abc7d52 chore: fix lint
2020-09-04 06:30:43,229 autosynth [DEBUG] > Running: git checkout autosynth
Switched to branch 'autosynth'
2020-09-04 06:30:43,237 autosynth [DEBUG] > Running: git clean -fdx
Removing __pycache__/
Removing google/__pycache__/
Removing google/cloud/__pycache__/
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 690, in <module>
    main()
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 539, in main
    return _inner_main(temp_dir)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 670, in _inner_main
    commit_count = synthesize_loop(x, multiple_prs, change_pusher, synthesizer)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 375, in synthesize_loop
    has_changes = toolbox.synthesize_version_in_new_branch(synthesizer, youngest)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 273, in synthesize_version_in_new_branch
    synthesizer.synthesize(synth_log_path, self.environ)
  File "/tmpfs/src/github/synthtool/autosynth/synthesizer.py", line 120, in synthesize
    synth_proc.check_returncode()  # Raise an exception.
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 389, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.

Google internal developers can see the full log here.

SpeechAsyncClient calls 'next' on async request generator

Environment details

  • OS type and version: OS X 10.11.6
  • Python version: 3.8.6
  • pip version: 20.2.1
  • google-cloud-speech version: 2.0.1

Steps to reproduce

I'm trying to employ SpeechAsyncClient to perform asynchronous stream recognition. Here's a snippet from the code I came up with:

speech_client = SpeechAsyncClient.from_service_account_json(...)
config_request = ...

async def _generate_requests(voice_stream: 'async_generator'):
    yield config_request
    async for chunk in voice_stream:
        request = StreamingRecognizeRequest()
        request.audio_content = chunk
        yield request

async def recognize_stream(voice_stream):
    recognize_agen = speech_client.streaming_recognize(_generate_requests(voice_stream))

    transcripts = [
        response.results[0].alternatives[0].transcript
        async for response in recognize_agen if response.results[0].is_final]
    ...

Here voice_stream is an async generator which yields chunks of audio to recognize. The problem is that awaiting on recognize_stream(voice_stream) raises unexpected exception:

Stack trace

ERROR:grpc._channel:Exception iterating requests!
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/grpc/_channel.py", line 195, in consume_request_iterator
    request = next(request_iterator)
TypeError: 'async_generator' object is not an iterator

It seems like SpeechAsyncClient calls next on a request generator instead of treating it like an async generator, which I reckon it's supposed to do. I couldn't find any documentation on this API and can only assume the expected behavior, but it surely looks like a bug in implementation. Or am I missing something?

Credential information line is missing for the code provided to utilize Google Cloud STT

Environment details

  • OS type and version: Mac OS Catalina 10.15.3
  • Python version: python 3.8
  • pip version: pip 20.0.2
  • google-cloud-speech version: 1.3.1

Issues

It seems like credential information is missing for the code provided to utilize Google Cloud STT.

from google.cloud import speech_v1
from google.cloud.speech_v1 import enums
def sample_long_running_recognize(storage_uri):
"""
Transcribe long audio file from Cloud Storage using asynchronous speech
recognition
Args:
storage_uri URI for audio file in Cloud Storage, e.g. gs://[BUCKET]/[FILE]
"""
client = speech_v1.SpeechClient()
# storage_uri = 'gs://cloud-samples-data/speech/brooklyn_bridge.raw'

I manually added GOOGLE_APPLICATION_CREDENTIALS information as following:

from google.cloud import speech_v1
from google.cloud.speech_v1 import enums
import io
import os

os.environ[
    "GOOGLE_APPLICATION_CREDENTIALS"
] = r"/Users/noopy/ghoststation_transcript/snoop2head.json"


def sample_long_running_recognize(storage_uri):
    """
    Transcribe long audio file from Cloud Storage using asynchronous speech
    recognition

    Args:
      storage_uri URI for audio file in Cloud Storage, e.g. gs://[BUCKET]/[FILE]
    """

Accuracy of Google Cloud STT is great, even for Korean language.
Thank you for the great work.

Synthesis failed for python-speech

Hello! Autosynth couldn't regenerate python-speech. ๐Ÿ’”

Here's the output from running synth.py:

e see rules_python 0.1 release notes
Analyzing: target //google/cloud/speech/v1p1beta1:speech-v1p1beta1-py (1 packages loaded, 0 targets configured)
INFO: Analyzed target //google/cloud/speech/v1p1beta1:speech-v1p1beta1-py (1 packages loaded, 6 targets configured).
INFO: Found 1 target...
[0 / 4] [Prepa] BazelWorkspaceStatusAction stable-status.txt
ERROR: /home/kbuilder/.cache/synthtool/googleapis/google/cloud/speech/v1p1beta1/BUILD.bazel:158:1: //google/cloud/speech/v1p1beta1:speech_py_gapic: `bazel-out/host/bin/external/com_google_protobuf/protoc --experimental_allow_proto3_optional --plugin=protoc-gen-python_gapic=bazel-out/host/bin/external/gapic_generator_python/gapic_plugin --python_gapic_out=retry-config=google/cloud/speech/v1p1beta1/speech_grpc_service_config.json:bazel-out/k8-fastbuild/bin/google/cloud/speech/v1p1beta1/speech_py_gapic.srcjar.zip -Igoogle/cloud/speech/v1p1beta1/cloud_speech.proto=google/cloud/speech/v1p1beta1/cloud_speech.proto -Igoogle/cloud/speech/v1p1beta1/resource.proto=google/cloud/speech/v1p1beta1/resource.proto -Igoogle/api/annotations.proto=google/api/annotations.proto -Igoogle/api/http.proto=google/api/http.proto -Igoogle/protobuf/descriptor.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/descriptor_proto/google/protobuf/descriptor.proto -Igoogle/api/client.proto=google/api/client.proto -Igoogle/api/field_behavior.proto=google/api/field_behavior.proto -Igoogle/api/resource.proto=google/api/resource.proto -Igoogle/longrunning/operations.proto=google/longrunning/operations.proto -Igoogle/rpc/status.proto=google/rpc/status.proto -Igoogle/protobuf/any.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/any_proto/google/protobuf/any.proto -Igoogle/protobuf/duration.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/duration_proto/google/protobuf/duration.proto -Igoogle/protobuf/empty.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/empty_proto/google/protobuf/empty.proto -Igoogle/protobuf/timestamp.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/timestamp_proto/google/protobuf/timestamp.proto google/cloud/speech/v1p1beta1/cloud_speech.proto google/cloud/speech/v1p1beta1/resource.proto` failed (Exit 1) protoc failed: error executing command bazel-out/host/bin/external/com_google_protobuf/protoc --experimental_allow_proto3_optional '--plugin=protoc-gen-python_gapic=bazel-out/host/bin/external/gapic_generator_python/gapic_plugin' ... (remaining 17 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
google/cloud/speech/v1p1beta1/resource.proto:19:1: warning: Import google/api/annotations.proto is unused.
google/cloud/speech/v1p1beta1/cloud_speech.proto:22:1: warning: Import google/api/resource.proto is unused.
google/cloud/speech/v1p1beta1/cloud_speech.proto:25:1: warning: Import google/protobuf/any.proto is unused.
Traceback (most recent call last):
  File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/45/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/cli/generate_with_pandoc.py", line 3, in <module>
    from gapic.cli import generate
  File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/45/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/cli/generate.py", line 23, in <module>
    from gapic import generator
  File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/45/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/generator/__init__.py", line 21, in <module>
    from .generator import Generator
  File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/45/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/generator/generator.py", line 24, in <module>
    from gapic.samplegen import manifest, samplegen
  File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/45/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/samplegen/__init__.py", line 15, in <module>
    from gapic.samplegen import samplegen
  File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/45/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/samplegen/samplegen.py", line 27, in <module>
    from gapic.schema import wrappers
  File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/45/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/schema/__init__.py", line 23, in <module>
    from gapic.schema.api import API
  File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/45/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/schema/api.py", line 29, in <module>
    from google.api_core import exceptions  # type: ignore
ModuleNotFoundError: No module named 'google.api_core'
--python_gapic_out: protoc-gen-python_gapic: Plugin failed with status code 1.
Target //google/cloud/speech/v1p1beta1:speech-v1p1beta1-py failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.080s, Critical Path: 0.84s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully

Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 102, in <module>
    main()
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 94, in main
    spec.loader.exec_module(synth_module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/kbuilder/.cache/synthtool/python-speech/synth.py", line 34, in <module>
    include_protos=True,
  File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 52, in py_library
    return self._generate_code(service, version, "python", **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 197, in _generate_code
    shell.run(bazel_run_args)
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 39, in run
    raise exc
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 33, in run
    encoding="utf-8",
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['bazel', '--max_idle_secs=240', 'build', '//google/cloud/speech/v1p1beta1:speech-v1p1beta1-py']' returned non-zero exit status 1.
2021-01-28 05:47:27,456 autosynth [ERROR] > Synthesis failed
2021-01-28 05:47:27,456 autosynth [DEBUG] > Running: git reset --hard HEAD
HEAD is now at 7722a2d chore: reorder exceptions (#102)
2021-01-28 05:47:27,462 autosynth [DEBUG] > Running: git checkout autosynth
Switched to branch 'autosynth'
2021-01-28 05:47:27,468 autosynth [DEBUG] > Running: git clean -fdx
Removing __pycache__/
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 354, in <module>
    main()
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 189, in main
    return _inner_main(temp_dir)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 334, in _inner_main
    commit_count = synthesize_loop(x, multiple_prs, change_pusher, synthesizer)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 65, in synthesize_loop
    has_changes = toolbox.synthesize_version_in_new_branch(synthesizer, youngest)
  File "/tmpfs/src/github/synthtool/autosynth/synth_toolbox.py", line 259, in synthesize_version_in_new_branch
    synthesizer.synthesize(synth_log_path, self.environ)
  File "/tmpfs/src/github/synthtool/autosynth/synthesizer.py", line 120, in synthesize
    synth_proc.check_returncode()  # Raise an exception.
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 389, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.

Google internal developers can see the full log here.

Getting started guide for Raspberry Pi fails - 'module' object has no attribute 'RecognitionAudio'

Environment details

  • OS type and version: Rasberry Pi 4, OS Raspbian GNU/Linux 10 (buster)
  • Python version: Python 3.7.3
  • pip version: pip 21.0.1
  • google-cloud-speech version: google-cloud-speech Version: 2.3.0

Steps to reproduce

  1. Follow Google Cloud Text to speech getting started guide at https://cloud.google.com/speech-to-text/docs/quickstart-client-libraries. Follow Python branch as below:
  2. pip install --upgrade google-cloud-speech
  3. try to run below code from the docs

Code example


# Imports the Google Cloud client library
from google.cloud import speech


# Instantiates a client
client = speech.SpeechClient()

# The name of the audio file to transcribe
gcs_uri = "gs://cloud-samples-data/speech/brooklyn_bridge.raw"

audio = speech.RecognitionAudio(uri=gcs_uri)

config = speech.RecognitionConfig(
    encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,
    sample_rate_hertz=16000,
    language_code="en-US",
)

# Detects speech in the audio file
response = client.recognize(config=config, audio=audio)

for result in response.results:
    print("Transcript: {}".format(result.alternatives[0].transcript))

Stack trace

Traceback (most recent call last):
  File "google_speech.py", line 11, in <module>
    audio = speech.RecognitionAudio(uri=gcs_uri)
AttributeError: 'module' object has no attribute 'RecognitionAudio'

Thanks

DeadlineExceeded: 504 Deadline Exceeded (when feeding an hour long audio file)

Hi, I'm getting this error that I'm not quite sure how to solve. I've set timeout=10000 seconds in response = operation.result(timeout=10000) and I'm still getting this error with large audio files. The code below works great for short audio files but not hour long ones. I'm running the code below in a Jupyter Notebook. It's giving me back this error. Furthermore, I don't know if all of these requests are still being processed in the background and if so I have no idea how to access them. Would love any help whatsoever!

Environment details

  • OS type and version: Macos Mojave 10.14
  • Python version: 3.7.2
  • pip version: pip 20.1 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)
  • google-cloud-speech version: 1.3.2

Steps to reproduce

  1. Create a bucket, add an hour long wav file to it.
  2. Run the code below

Code example

def importspeech(speechtype='speech_v1p1beta1'):
    if speechtype == 'speech_v1p1beta1':
        import google.cloud.speech_v1p1beta1 as speech
        from google.cloud.speech_v1p1beta1 import enums
    elif speechtype == 'speech_v1':
        from google.cloud import speech_v1 as speech
        from google.cloud.speech_v1 import enums
        
speech_type = 'speech_v1p1beta1'
importspeech(speechtype=speech_type)

from tqdm.notebook import tqdm
import numpy as np

modeltype = 'default'
punctuation_bool = True
def sample_long_running_recognize(storage_uri):

    filename = storage_uri.split('/')[-1]

    """
    Transcribe long audio file from Cloud Storage using asynchronous speech
    recognition

    Args:
      storage_uri URI for audio file in Cloud Storage, e.g. gs://[BUCKET]/[FILE]
    """

    client = speech.SpeechClient.from_service_account_json('stt.json')

    # storage_uri = 'gs://cloud-samples-data/speech/brooklyn_bridge.raw'

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

    # The language of the supplied audio
    language_code = "en-US"

    # Encoding of audio data sent. This sample sets this explicitly.
    # This field is optional for FLAC and WAV audio formats.
    #encoding = enums.RecognitionConfig.AudioEncoding.LINEAR16
    #encoding = enums.RecognitionConfig.AudioEncoding.ENCODING_UNSPECIFIED
    encoding = enums.RecognitionConfig.AudioEncoding.ENCODING_UNSPECIFIED
    
    config = speech.types.RecognitionConfig(
       language_code='en-US',
       model=modeltype,
       #model='video',
       #encoding='LINEAR16',
       #use_enhanced=True,
        #sample_rate_hertz=sample_rate_hertz,
        encoding=encoding,
       max_alternatives=30,
       audio_channel_count=2,

       enable_word_time_offsets=True,
       enable_automatic_punctuation=True)
    
    #config = {
        #"sample_rate_hertz": sample_rate_hertz,
        #"language_code": language_code,
        #"encoding": encoding,
    #}
    audio = {"uri": storage_uri}

    operation = client.long_running_recognize(config, audio)

    print(u"Waiting for operation to complete...")
    response = operation.result(timeout=10000)
    results_array = []
    for index, paragraph in tqdm(enumerate(response.results)):
        # First alternative is the most probable result
        results_array.append(result)

        for a_index, alternative in enumerate(paragraph.alternatives):
            writetocsv("Google response for " + filename.split('.')[0] + ', modeltype=' + modeltype + "punctuation=" + str(punctuation_bool) + ", speechtype=" + speech_type + '.csv', 
                       [index, a_index, alternative.transcript, alternative.confidence, alternative.words], 
                       header=['Paragraph No.', 'Alternative Index', 'Paragraph', 'Confidence', 'Words'])
    np.save("NPY Google response for " + filename.split('.')[0] + ', modeltype=' + modeltype + ", punctuation=" + str(punctuation_bool) + ", speechtype=" + speech_type + ".npy", response.results)
  


sample_long_running_recognize('gs://bucketname/filename.wav')

Stack trace

---------------------------------------------------------------------------
_InactiveRpcError                         Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api_core/grpc_helpers.py in error_remapped_callable(*args, **kwargs)
     56         try:
---> 57             return callable_(*args, **kwargs)
     58         except grpc.RpcError as exc:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/grpc/_channel.py in __call__(self, request, timeout, metadata, credentials, wait_for_ready, compression)
    825                                       wait_for_ready, compression)
--> 826         return _end_unary_response_blocking(state, call, False, None)
    827 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/grpc/_channel.py in _end_unary_response_blocking(state, call, with_call, deadline)
    728     else:
--> 729         raise _InactiveRpcError(state)
    730 

_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
	status = StatusCode.DEADLINE_EXCEEDED
	details = "Deadline Exceeded"
	debug_error_string = "{"created":"@1599652710.820076000","description":"Error received from peer ipv4:100.108.145.62:443","file":"src/core/lib/surface/call.cc","file_line":1056,"grpc_message":"Deadline Exceeded","grpc_status":4}"
>

The above exception was the direct cause of the following exception:

DeadlineExceeded                          Traceback (most recent call last)
<ipython-input-87-1911f980b0c1> in <module>
----> 1 sample_long_running_recognize('gs://jacquespeechaudio/AH105 AB M1ed2en5 release.wav')

<ipython-input-86-e1758f9339ae> in sample_long_running_recognize(storage_uri)
     73 
     74     print(u"Waiting for operation to complete...")
---> 75     response = operation.result(timeout=10000)
     76     results_array = []
     77     for index, paragraph in tqdm(enumerate(response.results)):

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api_core/future/polling.py in result(self, timeout)
    123                 the timeout is reached before the operation completes.
    124         """
--> 125         self._blocking_poll(timeout=timeout)
    126 
    127         if self._exception is not None:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api_core/future/polling.py in _blocking_poll(self, timeout)
    102 
    103         try:
--> 104             retry_(self._done_or_raise)()
    105         except exceptions.RetryError:
    106             raise concurrent.futures.TimeoutError(

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api_core/retry.py in retry_wrapped_func(*args, **kwargs)
    284                 sleep_generator,
    285                 self._deadline,
--> 286                 on_error=on_error,
    287             )
    288 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api_core/retry.py in retry_target(target, predicate, sleep_generator, deadline, on_error)
    182     for sleep in sleep_generator:
    183         try:
--> 184             return target()
    185 
    186         # pylint: disable=broad-except

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api_core/future/polling.py in _done_or_raise(self)
     81     def _done_or_raise(self):
     82         """Check if the future is done and raise if it's not."""
---> 83         if not self.done():
     84             raise _OperationNotComplete()
     85 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api_core/operation.py in done(self, retry)
    167             bool: True if the operation is complete, False otherwise.
    168         """
--> 169         self._refresh_and_update(retry)
    170         return self._operation.done
    171 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api_core/operation.py in _refresh_and_update(self, retry)
    155         # RPC as it will not change once done.
    156         if not self._operation.done:
--> 157             self._operation = self._refresh(retry=retry)
    158             self._set_result_from_operation()
    159 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api_core/operations_v1/operations_client.py in get_operation(self, name, retry, timeout)
    129         """
    130         request = operations_pb2.GetOperationRequest(name=name)
--> 131         return self._get_operation(request, retry=retry, timeout=timeout)
    132 
    133     def list_operations(

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api_core/gapic_v1/method.py in __call__(self, *args, **kwargs)
    143             kwargs["metadata"] = metadata
    144 
--> 145         return wrapped_func(*args, **kwargs)
    146 
    147 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api_core/retry.py in retry_wrapped_func(*args, **kwargs)
    284                 sleep_generator,
    285                 self._deadline,
--> 286                 on_error=on_error,
    287             )
    288 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api_core/retry.py in retry_target(target, predicate, sleep_generator, deadline, on_error)
    182     for sleep in sleep_generator:
    183         try:
--> 184             return target()
    185 
    186         # pylint: disable=broad-except

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api_core/timeout.py in func_with_timeout(*args, **kwargs)
    212             """Wrapped function that adds timeout."""
    213             kwargs["timeout"] = next(timeouts)
--> 214             return func(*args, **kwargs)
    215 
    216         return func_with_timeout

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api_core/grpc_helpers.py in error_remapped_callable(*args, **kwargs)
     57             return callable_(*args, **kwargs)
     58         except grpc.RpcError as exc:
---> 59             six.raise_from(exceptions.from_grpc_error(exc), exc)
     60 
     61     return error_remapped_callable

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/six.py in raise_from(value, from_value)

DeadlineExceeded: 504 Deadline Exceeded

AttributeError: 'datetime.timedelta' object has no attribute 'nanos'

The real time speech to text example has a bug:

Traceback (most recent call last):
  File "C:/workspace/acessibility-tool/main.py", line 300, in <module>
    main()
  File "C:/workspace/acessibility-tool/main.py", line 283, in main
    listen_print_loop(responses, stream)
  File "C:/workspace/acessibility-tool/main.py", line 203, in listen_print_loop
    if result.result_end_time.nanos:
AttributeError: 'datetime.timedelta' object has no attribute 'nanos'

https://github.com/googleapis/python-speech/blob/master/samples/microphone/transcribe_streaming_infinite.py

Reopen old issue

As far as I know Github users are not able to open issues closed by members who maintain a repository, so I need the following issue reopened

#52

ERROR: No matching distribution found for libcst>=0.2.5

I can't install the newest version of python-speech, i can only install the 1.3.2.
But the version 1.3.2 will occurs the error: "google.cloud.speech can't import "

So I want to install the 2.1.0 version from the source code.

If you are still having issues, please be sure to include as much information as possible:

Environment details

  • OS type and version: mac os 10.15.7
  • Python version: python 3.5
  • pip version: pip 20.3.4
  • google-cloud-speech version: pip show google-cloud-speech

Steps to reproduce

  1. pip install virtualenv
    virtualenv newgooglecloud
    source newgooglecloud/bin/activate
  2. newgooglecloud/bin/pip install google-cloud-speech
    Or
    cd python-speech-v2.1 and newgooglecloud/bin/pip install .

ERROR: Could not find a version that satisfies the requirement libcst>=0.2.5 (from google-cloud-speech)
ERROR: No matching distribution found for libcst>=0.2.5

speec2srt.py is not working because of removal of submodules enums and types

Following this for creating speech to srt using google apis. When running the command python3 speech2srt.py --storage_uri gs://subtitlingsc/en.wav is showing that

File "speech2srt.py", line 19, in <module>
    from google.cloud.speech_v1 import enums
ImportError: cannot import name 'enums' from 'google.cloud.speech_v1'

I think this is due to removal of enums and types. Please do the needful and update those videos and GitHub file

Migration guide: error in example code

In the migration guide, there is following code snippet:

from google.cloud import speech

client = speech.SpeechClient()

request = speech.RecognizeRequest(request={"config": config, "audio": audio})
response = client.list_voices(request=request)

If I don't miss something obvious, it should be as follows:

from google.cloud import speech

client = speech.SpeechClient()

request = speech.RecognizeRequest(config=config, audio=audio)
response = client.recognize(request=request)

Async speech to text - cannot get result based on Job Id

Google Cloud Speech to text API in beta version supports long_running_recognize method which returns FutureOperation. Then you may use result method on it in order to wait for finishing or there is an option to pass callback. Both approaches works fine in case, when processing and analysis is part of same file.

My customer is working on solution, when one microservice is responsible for sending audio file for recognition and second one is taking care about analysis of output. For now, in order to check current progress of job I may use following code:

`from google.cloud import speech_v1p1beta1 as speech

client = speech.SpeechClient()
response = client.transport._operations_client.get_operation('ID_OF_JOB')`

Unfortunately, response is not an object of proper class and developer needs to handle it on its side. I believe you we may just add method like

client.get_long_running_recognize_result('ID_OF_JOB') which may call https://cloud.google.com/speech-to-text/docs/reference/rest/v1p1beta1/operations/get REST API. It will makes it easier to use and it seams to be low hanging fruit.

Enhanced model vs data logging

Hi,
Based on the comment in the sample. Seems to use the enhanced model, you have to opt in data logging.
image

But in this enhanced model description page, looks like to use the enhanced model, you just need to set useEnhanced=True in the client request. Data logging is optional for lowering the cost of enhanced model.
image

Looks like there is a discrepancy between the sample code and feature descriptions? Please confirm whether the enhanced model is decoupled from data logging?

Thanks

Wrong requirements in samples/*/requirements.txt

The requirements.txt in samples still specify version google-cloud-speech==1.3.2. But the code itself (at least in python-speech/samples/microphone) needs version 2.0.0.

As a result, when one blindly runs pip install -r samples/microphone/requirements.txt and then proceeds to run e.g. samples/microphone/transcribe_streaming_mic.py, the result is:

$ python samples/microphone/transcribe_streaming_mic.py 
Traceback (most recent call last):
  File "samples/microphone/transcribe_streaming_mic.py", line 197, in <module>
    main()
  File "samples/microphone/transcribe_streaming_mic.py", line 172, in main
    config = speech.RecognitionConfig(
AttributeError: module 'google.cloud.speech' has no attribute 'RecognitionConfig'

... which provides a suboptimal "getting started" experience.

Steps to reproduce

  1. virtualenv testenv
  2. . testenv/bin/activate
  3. pip install -r samples/microphone/requirements.txt
  4. python samples/microphone/transcribe_streaming_mic.py

The fix is to install google-cloud-speech==2.0.0 instead of the old 1.3.2.

I think this issue is fixed in #78 but as it's not yet merged and others might run into this (and spend time figuring out what's wrong), I'm creating this issue.

Synthesis failed for python-speech

Hello! Autosynth couldn't regenerate python-speech. ๐Ÿ’”

Here's the output from running synth.py:

e see rules_python 0.1 release notes
Analyzing: target //google/cloud/speech/v1p1beta1:speech-v1p1beta1-py (1 packages loaded, 0 targets configured)
INFO: Analyzed target //google/cloud/speech/v1p1beta1:speech-v1p1beta1-py (1 packages loaded, 6 targets configured).
INFO: Found 1 target...
[0 / 4] [Prepa] BazelWorkspaceStatusAction stable-status.txt
ERROR: /home/kbuilder/.cache/synthtool/googleapis/google/cloud/speech/v1p1beta1/BUILD.bazel:158:1: //google/cloud/speech/v1p1beta1:speech_py_gapic: `bazel-out/host/bin/external/com_google_protobuf/protoc --experimental_allow_proto3_optional --plugin=protoc-gen-python_gapic=bazel-out/host/bin/external/gapic_generator_python/gapic_plugin --python_gapic_out=retry-config=google/cloud/speech/v1p1beta1/speech_grpc_service_config.json:bazel-out/k8-fastbuild/bin/google/cloud/speech/v1p1beta1/speech_py_gapic.srcjar.zip -Igoogle/cloud/speech/v1p1beta1/cloud_speech.proto=google/cloud/speech/v1p1beta1/cloud_speech.proto -Igoogle/cloud/speech/v1p1beta1/resource.proto=google/cloud/speech/v1p1beta1/resource.proto -Igoogle/api/annotations.proto=google/api/annotations.proto -Igoogle/api/http.proto=google/api/http.proto -Igoogle/protobuf/descriptor.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/descriptor_proto/google/protobuf/descriptor.proto -Igoogle/api/client.proto=google/api/client.proto -Igoogle/api/field_behavior.proto=google/api/field_behavior.proto -Igoogle/api/resource.proto=google/api/resource.proto -Igoogle/longrunning/operations.proto=google/longrunning/operations.proto -Igoogle/rpc/status.proto=google/rpc/status.proto -Igoogle/protobuf/any.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/any_proto/google/protobuf/any.proto -Igoogle/protobuf/duration.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/duration_proto/google/protobuf/duration.proto -Igoogle/protobuf/empty.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/empty_proto/google/protobuf/empty.proto -Igoogle/protobuf/timestamp.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/timestamp_proto/google/protobuf/timestamp.proto google/cloud/speech/v1p1beta1/cloud_speech.proto google/cloud/speech/v1p1beta1/resource.proto` failed (Exit 1) protoc failed: error executing command bazel-out/host/bin/external/com_google_protobuf/protoc --experimental_allow_proto3_optional '--plugin=protoc-gen-python_gapic=bazel-out/host/bin/external/gapic_generator_python/gapic_plugin' ... (remaining 17 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
google/cloud/speech/v1p1beta1/resource.proto:19:1: warning: Import google/api/annotations.proto is unused.
google/cloud/speech/v1p1beta1/cloud_speech.proto:22:1: warning: Import google/api/resource.proto is unused.
google/cloud/speech/v1p1beta1/cloud_speech.proto:25:1: warning: Import google/protobuf/any.proto is unused.
Traceback (most recent call last):
  File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/43/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/cli/generate_with_pandoc.py", line 3, in <module>
    from gapic.cli import generate
  File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/43/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/cli/generate.py", line 23, in <module>
    from gapic import generator
  File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/43/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/generator/__init__.py", line 21, in <module>
    from .generator import Generator
  File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/43/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/generator/generator.py", line 24, in <module>
    from gapic.samplegen import manifest, samplegen
  File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/43/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/samplegen/__init__.py", line 15, in <module>
    from gapic.samplegen import samplegen
  File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/43/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/samplegen/samplegen.py", line 27, in <module>
    from gapic.schema import wrappers
  File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/43/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/schema/__init__.py", line 23, in <module>
    from gapic.schema.api import API
  File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/43/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/schema/api.py", line 29, in <module>
    from google.api_core import exceptions  # type: ignore
ModuleNotFoundError: No module named 'google.api_core'
--python_gapic_out: protoc-gen-python_gapic: Plugin failed with status code 1.
Target //google/cloud/speech/v1p1beta1:speech-v1p1beta1-py failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.010s, Critical Path: 0.81s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully

Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 102, in <module>
    main()
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 94, in main
    spec.loader.exec_module(synth_module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/kbuilder/.cache/synthtool/python-speech/synth.py", line 34, in <module>
    include_protos=True,
  File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 52, in py_library
    return self._generate_code(service, version, "python", **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 193, in _generate_code
    shell.run(bazel_run_args)
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 39, in run
    raise exc
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 33, in run
    encoding="utf-8",
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['bazel', '--max_idle_secs=240', 'build', '//google/cloud/speech/v1p1beta1:speech-v1p1beta1-py']' returned non-zero exit status 1.
2021-01-21 05:47:05,076 autosynth [ERROR] > Synthesis failed
2021-01-21 05:47:05,076 autosynth [DEBUG] > Running: git reset --hard HEAD
HEAD is now at 7722a2d chore: reorder exceptions (#102)
2021-01-21 05:47:05,081 autosynth [DEBUG] > Running: git checkout autosynth
Switched to branch 'autosynth'
2021-01-21 05:47:05,086 autosynth [DEBUG] > Running: git clean -fdx
Removing __pycache__/
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 354, in <module>
    main()
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 189, in main
    return _inner_main(temp_dir)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 334, in _inner_main
    commit_count = synthesize_loop(x, multiple_prs, change_pusher, synthesizer)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 65, in synthesize_loop
    has_changes = toolbox.synthesize_version_in_new_branch(synthesizer, youngest)
  File "/tmpfs/src/github/synthtool/autosynth/synth_toolbox.py", line 259, in synthesize_version_in_new_branch
    synthesizer.synthesize(synth_log_path, self.environ)
  File "/tmpfs/src/github/synthtool/autosynth/synthesizer.py", line 120, in synthesize
    synth_proc.check_returncode()  # Raise an exception.
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 389, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.

Google internal developers can see the full log here.

ValueError: Protocol message FieldDescriptorProto has no "proto3_optional" field.

Getting an error when trying to import the Google Speech library:
ValueError: Protocol message FieldDescriptorProto has no "proto3_optional" field.

I Googled this extensively and did not find any solutions.

Environment details

  • OS type and version: MacOS 10.15.7
  • Conda version: 4.8.3
  • Python version: 3.7.6
  • pip version: 20.2.2
  • google-cloud-speech version: 2.0.0
  • proto-plus version: 1.11.0

Steps to reproduce

  1. Install the library: pip install google-cloud-speech
  2. Attempt to import the library: from google.cloud import speech

Code example

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from google.cloud import speech

Stack trace

Traceback (most recent call last):

  File "<ipython-input-1-589439c37498>", line 1, in <module>
    from google.cloud import speech

  File "/Users/msanders/opt/anaconda3/envs/workenv/lib/python3.7/site-packages/google/cloud/speech/__init__.py", line 18, in <module>
    from google.cloud.speech_v1.services.speech.async_client import SpeechAsyncClient

  File "/Users/msanders/opt/anaconda3/envs/workenv/lib/python3.7/site-packages/google/cloud/speech_v1/__init__.py", line 18, in <module>
    from .services.speech import SpeechClient

  File "/Users/msanders/opt/anaconda3/envs/workenv/lib/python3.7/site-packages/google/cloud/speech_v1/services/speech/__init__.py", line 18, in <module>
    from .client import SpeechClient

  File "/Users/msanders/opt/anaconda3/envs/workenv/lib/python3.7/site-packages/google/cloud/speech_v1/services/speech/client.py", line 47, in <module>
    from google.cloud.speech_v1.types import cloud_speech

  File "/Users/msanders/opt/anaconda3/envs/workenv/lib/python3.7/site-packages/google/cloud/speech_v1/types/__init__.py", line 18, in <module>
    from .cloud_speech import (

  File "/Users/msanders/opt/anaconda3/envs/workenv/lib/python3.7/site-packages/google/cloud/speech_v1/types/cloud_speech.py", line 50, in <module>
    class RecognizeRequest(proto.Message):

  File "/Users/msanders/opt/anaconda3/envs/workenv/lib/python3.7/site-packages/proto/message.py", line 215, in __new__
    field=[i.descriptor for i in fields],

  File "/Users/msanders/opt/anaconda3/envs/workenv/lib/python3.7/site-packages/proto/message.py", line 215, in <listcomp>
    field=[i.descriptor for i in fields],

  File "/Users/msanders/opt/anaconda3/envs/workenv/lib/python3.7/site-packages/proto/fields.py", line 111, in descriptor
    proto3_optional=self.optional,

ValueError: Protocol message FieldDescriptorProto has no "proto3_optional" field.

Speech: Docs section on model has broken HTML.

The following is displayed on https://googleapis.github.io/google-cloud-python/latest/speech/gapic/v1/types.html#google.cloud.speech_v1.types.RecognitionConfig

model
Optional Which model to select for the given request. Select the model best suited to your domain to get best results. If a model is not explicitly specified, then we auto-select a model based on the parameters in the RecognitionConfig. .. raw:: html

.. raw:: html :: .. raw:: html .. raw:: html :: .. raw:: html .. raw:: html :: .. raw:: html .. raw:: html :: .. raw:: html .. raw:: html :: .. raw:: html .. raw:: html
Model Description
command_and_search Best for short queries such as voice commands or voice search.
phone_call Best for audio that originated from a phone call (typically recorded at an 8khz sampling rate).
video Best for audio that originated from from video or includes multiple speakers. Ideally the audio is recorded at a 16khz or greater sampling rate. This is a premium model that costs more than the standard rate.
default Best for audio that is not one of the specific audio models. For example, long-form audio. Ideally the audio is high-fidelity, recorded at a 16khz or greater sampling rate.

AttributeError: Extensions, google.api_core.exceptions.GoogleAPICallError: None Too many retries, giving up.

Google-cloud-speech, version 1.3.2
Python 3.8
Mac OS 10.14.4

I'm able to use this software and get it working when the files are less than roughly 4 megs. Anything larger than that I have problems. I have added the timeout keyword but that does not work. I'm not sure if you can access the exact file I use on my google cloud, I'm pretty sure you can. In any case, the name of the file is trial_1.mp3. The file in question can be found here
https://drive.google.com/file/d/1GFoA3ukqZVcJwKYvGqjXD8bMYbc1Tk2n/view?usp=sharing
There are two lines of codes which give back different error messages
encoding = enums.RecognitionConfig.AudioEncoding.FLAC

gives back the error message GoogleAPICallError

And this line of code:
encoding = enums.RecognitionConfig.AudioEncoding.LINEAR16
gives back the error message:
AttributeError: Extensions

class audio2txt:
    def __init__(self):
        str1 = '/users/kylefoley/codes/' + "My Project 999999.json"
        os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = str1
        self.all_txt = []
        self.loop_audio2txt()

    def loop_audio2txt(self):
        str1 = f'/users/kylefoley/downloads/audio/'
        self.files = os.listdir(str1)
        self.files.sort()
        for e, file in en(self.files):
            if file[0] != '.':
                p(f'{e} of {len(self.files)}')
                self.file = file
                self.local = f'{str1}{file}'
                self.storage_uri = f'gs://deduction4/audio/{file}'
                self.conver2raw()
                self.upload2cloud(1)
                self.sample_recognize()

    def conver2raw(self):
        sound = AudioSegment.from_mp3(self.local)
        self.content = sound.raw_data
        self.duration = int(sound.duration_seconds)
        return

    def upload2cloud(self, already_uploaded=0):
        storage_client = storage.Client()
        bucket_name = f'deduction4'
        bucket = storage_client.get_bucket(bucket_name)
        if not already_uploaded:
            bucket.blob(f'audio/{self.file}').upload_from_string(self.content, timeout=240)
        self.storage_uri = f'gs://deduction4/audio/{self.file}'
        self.bucket = bucket
        return

    def sample_recognize(self):
        client = speech_v1.SpeechClient()
        storage_uri = self.storage_uri
        sample_rate_hertz = 16000
        language_code = "en-US"
        encoding = enums.RecognitionConfig.AudioEncoding.FLAC
        #encoding = enums.RecognitionConfig.AudioEncoding.LINEAR16
        config = {
            "sample_rate_hertz": sample_rate_hertz,
            "language_code": language_code,
            "encoding": encoding,
        }
        audio = {"uri": storage_uri}
        operation = client.long_running_recognize(config, audio, timeout=240)
        print(u"Waiting for operation to complete...")
        response = operation.result()
        for result in response.results:
            alternative = result.alternatives[0]
            self.all_txt.append(alternative)
        time.sleep(2)

AttributeError: module 'google.cloud.speech' has no attribute 'RecognitionConfig'

I searched StackOverflow and Github.

Environment details

  • OS type and version: Linux Ubuntu 20.04
  • Python version: Python 3.8.2
  • pip version: pip 20.2.3
  • google-cloud-speech : Version: 1.3.2
    Virtual Env and Pycharm

Steps to reproduce

  1. I used the code from this page.
  2. Pycharm makes this warning : Cannot find reference 'RecognitionConfig' in 'speech.py'
  3. When I run, I immediately got an error.

Stack trace

Traceback (most recent call last):
  File "/home/xxxxx/PycharmProjects/english_checker/main.py", line 271, in <module>
    main()
  File "/home/xxxxx/PycharmProjects/english_checker/main.py", line 216, in main
    config = speech.RecognitionConfig(
AttributeError: module 'google.cloud.speech' has no attribute 'RecognitionConfig'

I have all requirements (pyaudio, ...)

I don't understand what the missing part is about.

When tried to call Speech to text from celery it's crashing

Environment details

  • OS type and version: Mac OS
  • Python version: 2.7
  • pip version: 20.0.2
  • google-cloud-speech : 1.3.2

Issue

Trying to run the google speech to text from celery , but worker thread is crashing.

Steps to reproduce

  1. Flask Application with Celery
  2. Api being called , api starts celery task.
  3. Celery executes the google speech to text .

Code example

# Google speech to text function
from google.cloud import speech_v1p1beta1
from google.cloud.speech_v1p1beta1 import enums 
import io
import os
from google.cloud import speech_v1p1beta1 as speech   
from google.cloud.speech_v1p1beta1 import types  
import wave
from google.cloud import storage
import json
import uuid

def transcribe(filePath, language):
    print("Google Transcribe intiated for " +
          filePath + " in language "+language)
    head, tail = os.path.split(filePath)
    uid = uuid.uuid4().hex
    serverFilePath = 'files/'+uid+"/"+tail
    upload_blob(bucket_name, filePath, serverFilePath)
    storage_uri = "gs://transcribe-bkt/"+serverFilePath

    client = speech_v1p1beta1.SpeechClient()

    # The language of the supplied audio
    language_code = "en-US"

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

    # Encoding of audio data sent. This sample sets this explicitly.
    # This field is optional for FLAC and WAV audio formats.
    encoding = enums.RecognitionConfig.AudioEncoding.MP3
    config = {
        "language_code": language_code,
        "sample_rate_hertz": sample_rate_hertz,
        "encoding": encoding,
        "enable_word_confidence": True,
        "enable_word_time_offsets": True,
        "enable_automatic_punctuation": True
    }
    audio = {"uri": storage_uri}
    try:
        response = client.recognize(config, audio)
        print("Transcribe completed")
        # print(response)
        # write_transcripts(response.results, 'response.json')
        result = response.results[0]
        transcript = result.alternatives[0].transcript  

        return transcript
    except Exception as e:
        print("Error IN Transcribing:", e)

Stack trace

`[2020-05-03 21:46:04,761: ERROR/MainProcess] Process 'Worker-1' pid:46661 exited with 'signal 9 (SIGKILL)'
[2020-05-03 21:46:15,212: ERROR/MainProcess] Task app.speech_to_text_task[6f33d360-22c5-474b-98e0-f1c7ca2ab5fc] raised unexpected: WorkerLostError('Worker exited prematurely: signal 9 (SIGKILL).',)
Traceback (most recent call last):
  File "/Users/skytreasure/.virtualenvs/awstranscribe/lib/python2.7/site-packages/billiard/pool.py", line 1175, in mark_as_worker_lost
    human_status(exitcode)),
WorkerLostError: Worker exited prematurely: signal 9 (SIGKILL).`

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

Speech: Metadata for LongRunningRecognize always empty when obtained via 'get_operation'.

When using get_operation method from operations_v1.OperationsClient, speech metadata is always empty. When the operation completes, I get the transcribed text without issue in "response", it's only the "metadata" that is empty (whether before and after the operation is done ).

Metadata is present when the operation is accessed by other methods (e.g. $ gcloud ml speech operations describe , or the operation originally returned when requesting the LongRunningRecognize) - It's only when using get_operation that it is missing.

Environment details

  1. API - Speech, Operations
  2. OS: Mac OS 10.14.6
  3. Python version: 3.7.4
  4. google-cloud-speech version: 1.2.0
    google-cloud-core version: 1.0.3

Steps to reproduce

  1. Create a LongRunningRecognize request and note the operation name
  2. In a separate process, get_operation from operations_v1.OperationsClient to get the operation for the noted name
  3. Observe that the operation's "done" and "response" attributes contain the expected contents, but "metadata" is always empty

Code example

    client = speech.SpeechClient()
    api = operations_v1.OperationsClient(client.transport.channel)
    op = api.get_operation(operation_name)

op.done and op.response have the expected contents, but op.metadata is always empty.

Unstable Speech Diarization Results

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

If you are still having issues, please be sure to include as much information as possible:

Environment details

  • OS type and version: Ubuntu 18
  • Python version: python --version3.7
  • pip version: pip --version 20.0.2
  • google-cloud-speech version: pip show google-cloud-speech Version: 1.3.2

Steps to reproduce

I set up a server that reads audio streamed from ffmpeg, and attempts to label the speaker for every word. The results have pretty poor accuracy, and seem to change drastically in successive calls. The results feel at best unstable, at worst random. I'm wondering if there might be something else I'm missing/doing sub-optimally.

I'm not sure of the best way to "reproduce" in a way that others could as well (if you have guidance there, happy to put something together).

Code example

Here are the relevant code snippets pulled out of the server:

config = dict(
    encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
    language_code='en-US',
    sample_rate_hertz=16000,
    enable_speaker_diarization=True,
    diarization_speaker_count=2
)
args = dict(config=config,
            single_utterance=False,
            interim_results=False)
streaming_config = types.StreamingRecognitionConfig(**args)
...
client = speech.SpeechClient()
args = dict(timeout=1000)
return client.streaming_recognize(self.streaming_config_,
                                          self._requests(), **args)

Streaming microphone->webserver:

ffmpeg -f avfoundation -i ":0"  -ac 1 -f s16le -ar 16000 udp://$HOST:13580

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

Feature Request : Exporting "*Response" Class to JSON.

Is your feature request related to a problem? Please describe.
I'm trying to use Google Speech API to make transcript of some audio files.
It's uncomfortable to export recognition results with full information(Transcript, TimeStamp, Alternatives, WordInfo, Confidence).

Describe the solution you'd like
I want Response classes(LongRunning~, Recognize~, Streaming~) to have features that export information to json.

Describe alternatives you've considered
I wrote the code works well only with RecognizeResponse and using it now.

Additional context

Azerbaijani voice database on gTTS?

As far as I know, there is no Azerbaijani voice database on gTTS. So how can we create the Azerbaijani voice database?
What are the first steps in this regard?

No response from client.recognize

I tried simple example from the documentation but I didn't get any response back from API. I traced the error and it gets stuck on client.recognize function. This happens only on my PC and other PC is fine.

Environment details

  • OS type and version: Windows 10
  • Python version: 3.7
  • pip version: 20.2.3

Code example

import io
import os

# Imports the Google Cloud client library
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types
from google.oauth2 import service_account

creds = service_account.Credentials.from_service_account_file('C:\\Users\\sithu\\Downloads\\speech-to-text-289906-3153d28585c3.json')

# Instantiates a client
client = speech.SpeechClient(credentials=creds)

# The name of the audio file to transcribe
file_name = os.path.join(
    os.path.dirname(__file__),
    'I am an expert.wav')

# Loads the audio into memory
with io.open(file_name, 'rb') as audio_file:
    content = audio_file.read()
    audio = types.RecognitionAudio(content=content)

config = types.RecognitionConfig(
    encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
    sample_rate_hertz=16000,
    language_code='en-US')

# Detects speech in the audio file
response = client.recognize(config, audio)

for result in response.results:
    print('Transcript: {}'.format(result.alternatives[0].transcript))

Thanks!

GCP Speaker diarization with time-stamps

Hi, I have an audio file which i am transcribing using speech_v1p1beta1.SpeechClient() . While the timestamps are at the word level, i would want time-stamps for each transcript along with speaker tag.
Am using the below code to generate the response:

client = speech_v1p1beta1.SpeechClient()
gcs_uri = 'gs://'+ 'emo_det_1' + '/' + 'sample.wav'
diarization_speaker_count=3
config = {
    "sample_rate_hertz": 44100,
    "language_code": "en-IN",
    "audio_channel_count": 2,
    "encoding": enums.RecognitionConfig.AudioEncoding.LINEAR16,
    "enable_word_time_offsets": True,
    #"enable_separate_recognition_per_channel": True,
    "enable_automatic_punctuation": True,
    "enable_speaker_diarization": True,
    "diarization_speaker_count":diarization_speaker_count,
    # "model": 'video', not supported for language en-IN
    #"use_enhanced": True,
    #"speechContexts": [{"phrases": "quarter"}],
    }
audio = {"uri": gcs_uri}
operation = client.long_running_recognize(config, audio)
print(u'transcription in process...')
response = operation.result()

Now i would want the output in the following format:

sentence | sentence_id | speaker_tag | num_speakers | start_time | stop_time
num | sentence | speaker_id | speaker_tag | num_of_speakers | start time | end_time
0 | And then with regards to your partner, here's ... | 1 | 4 | 1 | 0 | 35
1 | That's not why is it you're denigrating the re... | 2 | 4 | 1 | 35 | 65
2 | It's like it's certainly possible that you mar... | 3 | 4 | 1 | 65 | 102

It would be of great help if someone can guide me.

Speech to Text example code breaks on `from google.cloud.speech import enums`

Pasting the example code of how to use the Python client library for speech to text from here fails with an import error:

$ python google.py 
Traceback (most recent call last):
  File "google.py", line 3, in <module>
    from google.cloud import speech
  File "/home/cainejette/src/whatsapp-bot/whatsapp-bot-venv/lib/python3.7/site-packages/google/cloud/speech.py", line 20, in <module>
    from google.cloud.speech_v1 import SpeechClient
  File "/home/cainejette/src/whatsapp-bot/whatsapp-bot-venv/lib/python3.7/site-packages/google/cloud/speech_v1/__init__.py", line 17, in <module>
    from google.cloud.speech_v1.gapic import speech_client
  File "/home/cainejette/src/whatsapp-bot/whatsapp-bot-venv/lib/python3.7/site-packages/google/cloud/speech_v1/gapic/speech_client.py", line 19, in <module>
    import pkg_resources
  File "/home/cainejette/src/whatsapp-bot/whatsapp-bot-venv/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3191, in <module>
    @_call_aside
  File "/home/cainejette/src/whatsapp-bot/whatsapp-bot-venv/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3175, in _call_aside
    f(*args, **kwargs)
  File "/home/cainejette/src/whatsapp-bot/whatsapp-bot-venv/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3219, in _initialize_master_working_set
    for dist in working_set
  File "/home/cainejette/src/whatsapp-bot/whatsapp-bot-venv/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3219, in <genexpr>
    for dist in working_set
  File "/home/cainejette/src/whatsapp-bot/whatsapp-bot-venv/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2726, in activate
    declare_namespace(pkg)
  File "/home/cainejette/src/whatsapp-bot/whatsapp-bot-venv/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2252, in declare_namespace
    _handle_ns(packageName, path_item)
  File "/home/cainejette/src/whatsapp-bot/whatsapp-bot-venv/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2185, in _handle_ns
    loader.load_module(packageName)
  File "/home/cainejette/src/whatsapp-bot/google.py", line 4, in <module>
    from google.cloud.speech import enums
ImportError: cannot import name 'enums' from 'google.cloud.speech' (/home/cainejette/src/whatsapp-bot/whatsapp-bot-venv/lib/python3.7/site-packages/google/cloud/speech.py)

Environment details

Running Pop!_OS, python 3.7.3, google-cloud-speech 1.3.1

speech/cloud-client test failures

Builds
https://source.cloud.google.com/results/invocations/ee35c95b-7ef9-4c90-b5ca-b30534a5c83b/targets
https://source.cloud.google.com/results/invocations/eace6b03-019a-4f2a-9802-4e07135a922d/targets

We don't have xunit xml log file, so build cop bot didn't catch it, but it seems like Python died.
Log:

platform linux -- Python 3.7.7, pytest-6.0.1, py-1.9.0, pluggy-0.13.1 -- /workspace/speech/cloud-client/.nox/py-3-7/bin/python
cachedir: .pytest_cache
rootdir: /workspace, configfile: pytest.ini
collecting ... collected 22 items

beta_snippets_test.py::test_transcribe_file_with_enhanced_model PASSED   [  4%]
beta_snippets_test.py::test_transcribe_file_with_metadata PASSED         [  9%]
beta_snippets_test.py::test_transcribe_file_with_auto_punctuation PASSED [ 13%]
beta_snippets_test.py::test_transcribe_diarization PASSED                [ 18%]
beta_snippets_test.py::test_transcribe_multichannel_file E0828 10:27:18.708634490   13111 sync_posix.cc:67]           assertion failed: pthread_mutex_lock(mu) == 0
Fatal Python error: Aborted

Thread 0x00007f2c36e0e600 (most recent call first):
  File "/usr/local/lib/python3.7/codecs.py", line 322 in decode
  File "/workspace/speech/cloud-client/.nox/py-3-7/lib/python3.7/site-packages/_pytest/capture.py", line 484 in snap
  File "/workspace/speech/cloud-client/.nox/py-3-7/lib/python3.7/site-packages/_pytest/capture.py", line 570 in readouterr
  File "/workspace/speech/cloud-client/.nox/py-3-7/lib/python3.7/site-packages/_pytest/capture.py", line 657 in read_global_capture
  File "/workspace/speech/cloud-client/.nox/py-3-7/lib/python3.7/site-packages/_pytest/capture.py", line 718 in item_capture
nox > Command pytest --junitxm```

google.api_core.exceptions.ServiceUnavailable

I keept getting this error:

Traceback (most recent call last):
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/flask/app.py", line 2464, in call
return self.wsgi_app(environ, start_response)
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/flask_socketio/init.py", line 45, in call
return super(_SocketIOMiddleware, self).call(environ,
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/engineio/middleware.py", line 74, in call
return self.wsgi_app(environ, start_response)
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functionsrule.endpoint
File "/home/yinhan/Chatroom-Flask-Socketio/app.py", line 74, in audio
responses = api['client'].streaming_recognize(streaming_config, requests)
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/google/cloud/speech_v1/helpers.py", line 80, in streaming_recognize
return super(SpeechHelpers, self).streaming_recognize(
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/google/cloud/speech_v1/gapic/speech_client.py", line 410, in streaming_recognize
return self._inner_api_calls["streaming_recognize"](
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/google/api_core/gapic_v1/method.py", line 143, in call
return wrapped_func(*args, **kwargs)
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/google/api_core/retry.py", line 281, in retry_wrapped_func
return retry_target(
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/google/api_core/retry.py", line 184, in retry_target
return target()
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/google/api_core/timeout.py", line 214, in func_with_timeout
return func(*args, **kwargs)
File "/home/yinhan/miniconda3/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 146, in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc)
File "", line 3, in raise_from
# Permission is hereby granted, free of charge, to any person obtaining a copy
google.api_core.exceptions.ServiceUnavailable: 503 Getting metadata from plugin failed with error: 'dict' object has no attribute 'before_request'

below is my code

@app.route('/initial')
def initial():
# See http://g.co/cloud/speech/docs/languages
# for a list of supported languages.

if 'credentials' not in flask.session:
    return flask.redirect('authorize')

# Load credentials from the session.
credentials = google.oauth2.credentials.Credentials(
  **flask.session['credentials'])
flask.session['credentials'] = credentials_to_dict(credentials)
if 'client' not in api:
    api['client'] = speech.SpeechClient(credentials=flask.session['credentials'])
return flask.jsonify({"result":"your credential is verified"})

@app.route('/audio')
def audio():
language_code = 'en-US' # a BCP-47 language tag
RATE = 16000
CHUNK = int(RATE / 10) # 100ms
config = types.RecognitionConfig(
encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=RATE,
language_code=language_code)
streaming_config = types.StreamingRecognitionConfig(
config=config,
interim_results=True)

with MicrophoneStream(RATE, CHUNK) as stream:
    audio_generator = stream.generator()
    requests = (types.StreamingRecognizeRequest(audio_content=content)
                for content in audio_generator)

    responses = api['client'].streaming_recognize(streaming_config, requests)

    # Now, put the transcription responses to use.
    listen_print_loop(responses)

any help?
thanks a lot!!!!!

speaker_tag for interim results OR trigger final response when speaker changes

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

I'm looking to build a real-time application that includes speaker diarization. Waiting for the full responses (which include the transcript and speaker_tag) takes at least 10 seconds, on average. I want to be able to detect change in speaker in near-real time O(1 second).

Describe the solution you'd like

Any of the following would work for me (in order of preference):

  • Interim results include speaker_tag (guess)
  • A "final result" is kicked back every time the speaker tag changes. Then, I can assume the previous speaker is still talking until I see a final response.

Describe alternatives you've considered

I've tried figuring out a way to "flush" more often so that I can see responses every O(1 second), but no luck. Maybe I'm missing something else?

Additional context

Nothing I can think of, but happy to answer any questions :) Thanks team!

Speech: 503 failed to connect to all addresses

Here is my code:

from google.cloud import speech_v1p1beta1
import os
import io
from google.oauth2 import service_account
from google.cloud import speech
credentials = service_account.Credentials. from_service_account_file('booking-ff3af108902e.json')

#speech = speech.SpeechClient(credentials=credentials)

def sample_long_running_recognize(local_file_path):
    """
    Print confidence level for individual words in a transcription of a short audio
    file
    Separating different speakers in an audio file recording
    Args:
      local_file_path Path to local audio file, e.g. /path/audio.wav
    """

    client = speech_v1p1beta1.SpeechClient(credentials=credentials)
    
    # local_file_path = 'resources/commercial_mono.wav'

    # If enabled, each word in the first alternative of each result will be
    # tagged with a speaker tag to identify the speaker.
    enable_speaker_diarization = True

    # Optional. Specifies the estimated number of speakers in the conversation.
    diarization_speaker_count = 10

    # The language of the supplied audio
    language_code = "en-US"
    config = {
        "enable_speaker_diarization": enable_speaker_diarization,
        "diarization_speaker_count": diarization_speaker_count,
        "language_code": language_code,
    }
  
    with io.open(local_file_path, "rb") as f:
        content = f.read()
    audio = {"content": content}
  
    
    operation = client.long_running_recognize(config, audio)
    print("------------")
    print(u"Waiting for operation to complete...")
    response = operation.result()

    for result in response.results:
        # First alternative has words tagged with speakers
        alternative = result.alternatives[0]
        print(u"Transcript: {}".format(alternative.transcript))
        # Print the speaker_tag of each word
        for word in alternative.words:
            print(u"Word: {}".format(word.word))
            print(u"Speaker tag: {}".format(word.speaker_tag))


# [END speech_transcribe_diarization_beta]


def main():
    #import argparse

    #parser = argparse.ArgumentParser()
    #parser.add_argument(
    #    "OSR_us_000_0010_8k.wav", type=str, default="OSR_us_000_0010_8k.wav"
    #)
    #args = parser.parse_args()

    sample_long_running_recognize("OSR_us_000_0010_8k.wav")


if __name__ == "__main__":
    main()

When run on jupyter notebook, it gives the following error:

_InactiveRpcError                         Traceback (most recent call last)
~\Anaconda3\lib\site-packages\google\api_core\grpc_helpers.py in error_remapped_callable(*args, **kwargs)
     56         try:
---> 57             return callable_(*args, **kwargs)
     58         except grpc.RpcError as exc:

~\Anaconda3\lib\site-packages\grpc\_channel.py in __call__(self, request, timeout, metadata, credentials, wait_for_ready, compression)
    823                                       wait_for_ready, compression)
--> 824         return _end_unary_response_blocking(state, call, False, None)
    825 

~\Anaconda3\lib\site-packages\grpc\_channel.py in _end_unary_response_blocking(state, call, with_call, deadline)
    725     else:
--> 726         raise _InactiveRpcError(state)
    727 

_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
	status = StatusCode.UNAVAILABLE
	details = "failed to connect to all addresses"
	debug_error_string = "{"created":"@1577076639.317000000","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":3941,"referenced_errors":[{"created":"@1577076639.317000000","description":"failed to connect to all addresses","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":393,"grpc_status":14}]}"
>

The above exception was the direct cause of the following exception:

ServiceUnavailable                        Traceback (most recent call last)
<ipython-input-20-61140e22100a> in <module>
     72 
     73 if __name__ == "__main__":
---> 74     main()

<ipython-input-20-61140e22100a> in main()
     68     #args = parser.parse_args()
     69 
---> 70     sample_long_running_recognize("OSR_us_000_0010_8k.wav")
     71 
     72 

<ipython-input-20-61140e22100a> in sample_long_running_recognize(local_file_path)
     41 
     42 
---> 43     operation = client.long_running_recognize(config, audio)
     44     print("------------")
     45     print(u"Waiting for operation to complete...")

~\Anaconda3\lib\site-packages\google\cloud\speech_v1p1beta1\gapic\speech_client.py in long_running_recognize(self, config, audio, retry, timeout, metadata)
    341         )
    342         operation = self._inner_api_calls["long_running_recognize"](
--> 343             request, retry=retry, timeout=timeout, metadata=metadata
    344         )
    345         return google.api_core.operation.from_gapic(

~\Anaconda3\lib\site-packages\google\api_core\gapic_v1\method.py in __call__(self, *args, **kwargs)
    141             kwargs["metadata"] = metadata
    142 
--> 143         return wrapped_func(*args, **kwargs)
    144 
    145 

~\Anaconda3\lib\site-packages\google\api_core\retry.py in retry_wrapped_func(*args, **kwargs)
    284                 sleep_generator,
    285                 self._deadline,
--> 286                 on_error=on_error,
    287             )
    288 

~\Anaconda3\lib\site-packages\google\api_core\retry.py in retry_target(target, predicate, sleep_generator, deadline, on_error)
    182     for sleep in sleep_generator:
    183         try:
--> 184             return target()
    185 
    186         # pylint: disable=broad-except

~\Anaconda3\lib\site-packages\google\api_core\timeout.py in func_with_timeout(*args, **kwargs)
    212             """Wrapped function that adds timeout."""
    213             kwargs["timeout"] = next(timeouts)
--> 214             return func(*args, **kwargs)
    215 
    216         return func_with_timeout

~\Anaconda3\lib\site-packages\google\api_core\grpc_helpers.py in error_remapped_callable(*args, **kwargs)
     57             return callable_(*args, **kwargs)
     58         except grpc.RpcError as exc:
---> 59             six.raise_from(exceptions.from_grpc_error(exc), exc)
     60 
     61     return error_remapped_callable

~\Anaconda3\lib\site-packages\six.py in raise_from(value, from_value)

ServiceUnavailable: 503 failed to connect to all addresses

google.api_core.exceptions.Unknown: None Exception iterating requests!

Environment details

  • OS type and version: MacOS catalina 10.15.7
  • Python version: Python 3.8.5
  • pip version: pip 20.2.3
  • google-cloud-speech version: `Name: google-cloud-speech

Version: 1.3.2
Summary: Google Cloud Speech API client library
Home-page: https://github.com/googleapis/python-speech
Author: Google LLC
Author-email: [email protected]
License: Apache 2.0

Steps to reproduce

  1. Followed the instructions [here] (https://github.com/googleapis/python-speech/tree/master/samples/microphone#setup)
  2. Created a service account json key, set up the env path and also did gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS
  3. Ran python transcribe_streaming_mic.py and got this trace:
21:38 $ python transcribe_streaming_mic.py
Traceback (most recent call last):
  File "transcribe_streaming_mic.py", line 197, in <module>
    main()
  File "transcribe_streaming_mic.py", line 177, in main
    streaming_config = speech.StreamingRecognitionConfig(
AttributeError: module 'google.cloud.speech' has no attribute 'StreamingRecognitionConfig'
  1. Made these changes:
    config = speech.types.RecognitionConfig(
        encoding=speech.enums.RecognitionConfig.AudioEncoding.LINEAR16,
        sample_rate_hertz=RATE,
        language_code=language_code,
    )
    streaming_config = speech.types.StreamingRecognitionConfig(
        config=config, interim_results=True
    )

It was originally like this

    client = speech.SpeechClient()
    config = speech.RecognitionConfig(
        encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,
        sample_rate_hertz=RATE,
        language_code=language_code,
    )
    streaming_config = speech.StreamingRecognitionConfig(
        config=config, interim_results=True
    )
  1. The code throws a completely new exception :
21:39 $ python transcribe_streaming_mic.py
Traceback (most recent call last):
  File "/Users/veswara/gcp_priv_voice_key/env/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 150, in error_remapped_callable
    return _StreamingResponseIterator(result, prefetch_first_result=prefetch_first)
  File "/Users/veswara/gcp_priv_voice_key/env/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 73, in __init__
    self._stored_first_result = six.next(self._wrapped)
  File "/Users/veswara/gcp_priv_voice_key/env/lib/python3.8/site-packages/grpc/_channel.py", line 416, in __next__
    return self._next()
  File "/Users/veswara/gcp_priv_voice_key/env/lib/python3.8/site-packages/grpc/_channel.py", line 706, in _next
    raise self
grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
	status = StatusCode.UNKNOWN
	details = "Exception iterating requests!"
	debug_error_string = "None"
>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "transcribe_streaming_mic.py", line 197, in <module>
    main()
  File "transcribe_streaming_mic.py", line 188, in main
    responses = client.streaming_recognize(
  File "/Users/veswara/gcp_priv_voice_key/env/lib/python3.8/site-packages/google/cloud/speech_v1/helpers.py", line 80, in streaming_recognize
    return super(SpeechHelpers, self).streaming_recognize(
  File "/Users/veswara/gcp_priv_voice_key/env/lib/python3.8/site-packages/google/cloud/speech_v1/gapic/speech_client.py", line 410, in streaming_recognize
    return self._inner_api_calls["streaming_recognize"](
  File "/Users/veswara/gcp_priv_voice_key/env/lib/python3.8/site-packages/google/api_core/gapic_v1/method.py", line 145, in __call__
    return wrapped_func(*args, **kwargs)
  File "/Users/veswara/gcp_priv_voice_key/env/lib/python3.8/site-packages/google/api_core/retry.py", line 281, in retry_wrapped_func
    return retry_target(
  File "/Users/veswara/gcp_priv_voice_key/env/lib/python3.8/site-packages/google/api_core/retry.py", line 184, in retry_target
    return target()
  File "/Users/veswara/gcp_priv_voice_key/env/lib/python3.8/site-packages/google/api_core/timeout.py", line 214, in func_with_timeout
    return func(*args, **kwargs)
  File "/Users/veswara/gcp_priv_voice_key/env/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 152, in error_remapped_callable
    six.raise_from(exceptions.from_grpc_error(exc), exc)
  File "<string>", line 3, in raise_from
google.api_core.exceptions.Unknown: None Exception iterating requests!

What could I be doing wrong ?

Regards,
Vinay

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.