GeezerVison is showing github.com — speech_streaming tests do not pass · Issue #403 · GoogleCloudPlatform/python-docs-samples
speech_streaming tests do not pass #403Labels 🚨This issue needs some love.triage meI really want to be triaged. DescriptionAfter 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 Activitytheacodes commented on Jul 6, 2016 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 commented on Jul 6, 2016 (closing, but feel free to respond and I'll re-open if needed) raphael0202 commented on Jul 6, 2016 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_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 commented on Jul 6, 2016 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 commented on Jul 6, 2016 theacodes commented on Jul 6, 2016 @raphael0202 does the sample itself work if you run it directly? raphael0202 commented on Jul 6, 2016 @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 commented on Jul 6, 2016 Great, just making sure. And you are on the latest HEAD of master, right? xinjiez commented on 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 commented on Jul 6, 2016 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 commented on 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 commented on Jul 6, 2016 It did install grpc-google-cloud-speech-1.0.4. So is this resolved? raphael0202 commented on Jul 6, 2016 Yes indeed. And yes this is resolved. Thanks!
MetadataMetadata🚨This issue needs some love.triage meI really want to be triaged. DevelopmentNo branches or pull requestsIssue actions
|