Skip to content

fix(python): handling support for python 3.6.4#399

Merged
germanattanasio merged 2 commits intodevelopfrom
fix-web-socket-3.6
Mar 8, 2018
Merged

fix(python): handling support for python 3.6.4#399
germanattanasio merged 2 commits intodevelopfrom
fix-web-socket-3.6

Conversation

@ehdsouza
Copy link
Copy Markdown
Contributor

@ehdsouza ehdsouza commented Mar 8, 2018

Got the following two errors in python 3.6.4:
*

Traceback (most recent call last):
  File "examples/speech_to_text_v1.py", line 57, in <module>
    audio=audio_file, recognize_callback=mycallback)
  File "/Users/erikadsouza/anaconda3/envs/testpypi/lib/python3.6/site-packages/watson_developer_cloud/speech_to_text_v1.py", line 245, in recognize_with_websocket
    self.username + ':' + self.password)
  File "/Users/erikadsouza/anaconda3/envs/testpypi/lib/python3.6/base64.py", line 58, in b64encode
    encoded = binascii.b2a_base64(s, newline=False)
TypeError: a bytes-like object is required, not 'str'
  • urlencode support


def build_close_message(self):
return json.dumps({'action': 'close'})
return json.dumps({'action': 'close'}).encode('utf8')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for the error in python 3.6.4:

24, in onMessage
    self.sendMessage(self.build_close_message())
  File "/Users/erikadsouza/anaconda3/envs/python-3.6.4/lib/python3.6/site-packages/autobahn/websocket/protocol.py", line 2164, in sendMessage
    assert(type(payload) == bytes)
builtins.AssertionError:

@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #399 into develop will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@           Coverage Diff           @@
##           develop    #399   +/-   ##
=======================================
  Coverage        0%      0%           
=======================================
  Files           21      21           
  Lines        10614   10618    +4     
=======================================
- Misses       10614   10618    +4
Impacted Files Coverage Δ
watson_developer_cloud/speech_to_text_v1.py 0% <0%> (ø) ⬆️
...oud/websocket/speech_to_text_websocket_listener.py 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d8a0955...b09e8a3. Read the comment docs.

version='2017-10-16',
username=os.getenv('DISCOVERY_TO_TEXT_USERNAME'),
password=os.getenv('DISCOVERY_TO_TEXT_PASSWORD'))
username="YOUR SERVICE USERNAME",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be os.getenv('DISCOVERY_USERNAME')

@germanattanasio germanattanasio merged commit d9e4e45 into develop Mar 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants