Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

speech_streaming tests do not pass #403

Closed
raphael0202 opened this issue Jul 5, 2016 · 13 comments
Closed

speech_streaming tests do not pass #403

raphael0202 opened this issue Jul 5, 2016 · 13 comments
Labels
🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@raphael0202
Copy link

After installing the required dependencies, the tests of the streaming Speech API don't pass. The live speech recognition (speech_streaming.py) also don't work: no error is raised, but no response from the Google Cloud server is received, even if Streaming RecognizeRequest are sent regularly.

(googlecloud) raphael@debian-raphael:~/Documents/Projets/ZebrIA/python-docs-samples/speech/api$ python -m pytest speech_streaming_test.py
================================================================================== test session starts ===================================================================================
platform linux2 -- Python 2.7.9, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: /home/raphael/Documents/Projets/ZebrIA/python-docs-samples/speech/api, inifile:
collected 1 items

speech_streaming_test.py F

======================================================================================== FAILURES ========================================================================================
_______________________________________________________________________________________ test_main ________________________________________________________________________________________

resource = <function at 0x7fedc94b3668>, monkeypatch = <_pytest.monkeypatch.monkeypatch instance at 0x7fedc94b97e8>
capsys = <_pytest.capture.CaptureFixture instance at 0x7fedc94b97a0>

@pytest.mark.skipif(
        sys.version_info >= (3, 0),
        reason=("grpc doesn't yet support python3 "
                'https://github.com/grpc/grpc/issues/282'))
def test_main(resource, monkeypatch, capsys):
    monkeypatch.setattr(
        speech_streaming, 'record_audio',
        mock_audio_stream(resource('quit.raw')))
    monkeypatch.setattr(speech_streaming, 'DEADLINE_SECS', 5)

    speech_streaming.main()

speech_streaming_test.py:70:


speech_streaming.py:141: in main
request_stream(stop_audio), DEADLINE_SECS))
speech_streaming.py:117: in listen_print_loop
for resp in recognize_stream:


self = <grpc.framework.crust._control.Rendezvous object at 0x7fedc94ce790>

def next(self):
  with self._condition:
    while True:
      if self._termination.abortion_error is not None:
        raise self._termination.abortion_error

E LocalError: LocalError(code=StatusCode.UNIMPLEMENTED, details="GRPC target method is not implemented.")

/home/raphael/.virtualenvs/googlecloud/local/lib/python2.7/site-packages/grpc/framework/crust/_control.py:415: LocalError

@theacodes
Copy link
Contributor

We merged a version of the sample that was using an internal-only version of the API. We've reverted that change. Can you try this again with the latest code?

@theacodes
Copy link
Contributor

(closing, but feel free to respond and I'll re-open if needed)

@raphael0202
Copy link
Author

An import error occurs, because in speech_streaming.py, the module name was not corrected during the import.
from google.cloud.speech.v1beta1 import cloud_speech_pb2 as cloud_speech
instead of google.cloud.speech.v1

After fixing this ImportError, I get another one:

(googlecloud) raphael@debian-raphael:~/ZebrIA/python-docs-samples/speech/api$ python -m pytest speech_streaming_test.py
======================================================================== test session starts =========================================================================
platform linux2 -- Python 2.7.9, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: /home/raphael/Documents/Projets/ZebrIA/python-docs-samples/speech/api, inifile:
collected 1 items

speech_streaming_test.py F

============================================================================== FAILURES ==============================================================================
_____________________________________________________________________________ test_main ______________________________________________________________________________

resource = <function at 0x7f62f2f2e668>, monkeypatch = <_pytest.monkeypatch.monkeypatch instance at 0x7f62f2f39830>
capsys = <_pytest.capture.CaptureFixture instance at 0x7f62f2f397a0>

@pytest.mark.skipif(
        sys.version_info >= (3, 0),
        reason=("grpc doesn't yet support python3 "
                'https://github.com/grpc/grpc/issues/282'))
def test_main(resource, monkeypatch, capsys):
    monkeypatch.setattr(
        speech_streaming, 'record_audio',
        mock_audio_stream(resource('quit.raw')))
    monkeypatch.setattr(speech_streaming, 'DEADLINE_SECS', 5)
  speech_streaming.main()

speech_streaming_test.py:70:


speech_streaming.py:139: in main
service.Recognize(request_stream(stop_audio), DEADLINE_SECS))
/home/raphael/.virtualenvs/googlecloud/local/lib/python2.7/site-packages/grpc/beta/_stub.py:57: in getattr
return getattr(self._delegate, attr)


self = <grpc.framework.crust.implementations._DynamicStub object at 0x7f62f21e32d0>, attr = 'Recognize'

def __getattr__(self, attr):
  method_cardinality = self._cardinalities.get(attr)
  if method_cardinality is cardinality.Cardinality.UNARY_UNARY:
    return _UnaryUnaryMultiCallable(self._end, self._group, attr, self._pool)
  elif method_cardinality is cardinality.Cardinality.UNARY_STREAM:
    return _UnaryStreamMultiCallable(self._end, self._group, attr, self._pool)
  elif method_cardinality is cardinality.Cardinality.STREAM_UNARY:
    return _StreamUnaryMultiCallable(self._end, self._group, attr, self._pool)
  elif method_cardinality is cardinality.Cardinality.STREAM_STREAM:
    return _StreamStreamMultiCallable(
        self._end, self._group, attr, self._pool)
  else:
  raise AttributeError('_DynamicStub object has no attribute "%s"!' % attr)

E AttributeError: _DynamicStub object has no attribute "Recognize"!

@theacodes
Copy link
Contributor

I can't debug any further, @xinjiez @jerjou any ideas?

(jerjou is ostensibly out until mid-next week, but ccing him just in case)

@theacodes
Copy link
Contributor

@puneith as well.

@theacodes
Copy link
Contributor

@raphael0202 does the sample itself work if you run it directly?

@raphael0202
Copy link
Author

@jonparrott I have the same error if I run speech_streaming.py directly:

Traceback (most recent call last):
File "speech_streaming.py", line 147, in
main()
File "speech_streaming.py", line 139, in main
service.Recognize(request_stream(stop_audio), DEADLINE_SECS))
File "/home/raphael/.virtualenvs/googlecloud/local/lib/python2.7/site-packages/grpc/beta/_stub.py", line 57, in getattr
return getattr(self._delegate, attr)
File "/home/raphael/.virtualenvs/googlecloud/local/lib/python2.7/site-packages/grpc/framework/crust/implementations.py", line 271, in getattr
raise AttributeError('_DynamicStub object has no attribute "%s"!' % attr)
AttributeError: _DynamicStub object has no attribute "Recognize"!

@theacodes
Copy link
Contributor

Great, just making sure. And you are on the latest HEAD of master, right?

@theacodes theacodes reopened this Jul 6, 2016
@xinjiez
Copy link
Contributor

xinjiez commented Jul 6, 2016

Could you please do this
pip install -r requirements-speech_grpc.txt

and use google.cloud.speech.v1 instead of google.cloud.speech.v1beta1 and see if it fixes the problem?

Because we rollback please refer to the original README and run the instructions again. Sorry for the inconvenience.

Thanks.

@raphael0202
Copy link
Author

Yes, latest HEAD on master branch. Did you manage to reproduce the bug?
By the way, I don't know if you previously noticed this info in my previous message, but I had to manually fix an ImportError in speech_streaming.py:

Traceback (most recent call last):
File "speech_streaming.py", line 22, in
from google.cloud.speech.v1 import cloud_speech_pb2 as cloud_speech
ImportError: No module named v1

@raphael0202
Copy link
Author

raphael0202 commented Jul 6, 2016

Ok, I used pip install -r requirements-speech_grpc.txt

Requirement already satisfied (use --upgrade to upgrade): gcloud==0.17.0 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from -r requirements-speech_grpc.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): grpcio==0.14.0 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from -r requirements-speech_grpc.txt (line 2))
Requirement already satisfied (use --upgrade to upgrade): PyAudio==0.2.9 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from -r requirements-speech_grpc.txt (line 3))
Collecting grpc-google-cloud-speech==1.0.4 (from -r requirements-speech_grpc.txt (line 4))
  Downloading grpc_google_cloud_speech-1.0.4-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): gax-google-logging-v2>=0.7.10 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from gcloud==0.17.0->-r requirements-speech_grpc.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): oauth2client>=2.0.1 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from gcloud==0.17.0->-r requirements-speech_grpc.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): httplib2>=0.9.1 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from gcloud==0.17.0->-r requirements-speech_grpc.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): google-gax>=0.12.1 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from gcloud==0.17.0->-r requirements-speech_grpc.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): protobuf!=3.0.0.b2.post1,>=3.0.0b2 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from gcloud==0.17.0->-r requirements-speech_grpc.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): googleapis-common-protos in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from gcloud==0.17.0->-r requirements-speech_grpc.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): gax-google-pubsub-v1>=0.7.10 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from gcloud==0.17.0->-r requirements-speech_grpc.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): six in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from gcloud==0.17.0->-r requirements-speech_grpc.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): enum34>=1.0.4 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from grpcio==0.14.0->-r requirements-speech_grpc.txt (line 2))
Requirement already satisfied (use --upgrade to upgrade): futures>=2.2.0 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from grpcio==0.14.0->-r requirements-speech_grpc.txt (line 2))
Requirement already satisfied (use --upgrade to upgrade): grpc-google-logging-v2>=0.7.11 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from gax-google-logging-v2>=0.7.10->gcloud==0.17.0->-r requirements-speech_grpc.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): rsa>=3.1.4 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from oauth2client>=2.0.1->gcloud==0.17.0->-r requirements-speech_grpc.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): pyasn1>=0.1.7 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from oauth2client>=2.0.1->gcloud==0.17.0->-r requirements-speech_grpc.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): pyasn1-modules>=0.0.5 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from oauth2client>=2.0.1->gcloud==0.17.0->-r requirements-speech_grpc.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): ply==3.8 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from google-gax>=0.12.1->gcloud==0.17.0->-r requirements-speech_grpc.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): setuptools in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from protobuf!=3.0.0.b2.post1,>=3.0.0b2->gcloud==0.17.0->-r requirements-speech_grpc.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): grpc-google-pubsub-v1>=0.7.11 in /home/raphael/.virtualenvs/googlecloud/lib/python2.7/site-packages (from gax-google-pubsub-v1>=0.7.10->gcloud==0.17.0->-r requirements-speech_grpc.txt (line 1))
Installing collected packages: grpc-google-cloud-speech
Successfully installed grpc-google-cloud-speech-1.0.4

But now everything works, both the tests and the script.

@theacodes
Copy link
Contributor

theacodes commented Jul 6, 2016

It did install grpc-google-cloud-speech-1.0.4. So is this resolved?

@raphael0202
Copy link
Author

Yes indeed. And yes this is resolved. Thanks!

@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 6, 2020
msampathkumar pushed a commit that referenced this issue Nov 14, 2022
* chore(python): drop python 3.6

Source-Link: googleapis/synthtool@4f89b13
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:e7bb19d47c13839fe8c147e50e02e8b6cf5da8edd1af8b82208cd6f66cc2829c

* add api_description to .repo-metadata.json

* require python 3.7+ in setup.py

* remove python 3.6 sample configs

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* trigger CI

* add python_requires to setup.py

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
telpirion pushed a commit that referenced this issue Jan 18, 2023
dandhlee pushed a commit that referenced this issue Feb 6, 2023
telpirion pushed a commit that referenced this issue Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

4 participants