robwolff3 / google-assistant-webserver

Docker for google-assistant-webserver
GNU General Public License v3.0
41 stars 15 forks source link

getting encoding error KOREAN #2

Open myrayearth opened 5 years ago

myrayearth commented 5 years ago

Hello, I'm getting encoding error: i use Language KOREAN and test JAPANESE language too. i try -e PYTHONIOENCODING=utf-8 and euc-kr , but can't work it. can you fix it?

192.168.0.200 - - [28/May/2019 15:35:07] "GET /command?message=turn%20off%20light HTTP/1.1" 200 -, [2019-05-28 15:35:18,202] ERROR in app: Exception on /command [GET], Traceback (most recent call last):, File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1832, in full_dispatch_request, rv = self.dispatch_request(), File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1818, in dispatch_request, return self.view_functionsrule.endpoint, File "/usr/local/lib/python3.5/dist-packages/flask_restful/init.py", line 458, in wrapper, resp = resource(*args, kwargs), File "/usr/local/lib/python3.5/dist-packages/flask/views.py", line 88, in view, return self.dispatch_request(*args, *kwargs), File "/usr/local/lib/python3.5/dist-packages/flask_restful/init.py", line 573, in dispatch_request, resp = meth(args, kwargs), File "/gawebserver.py", line 169, in get, assistant.send_text_query(message), File "/usr/local/lib/python3.5/dist-packages/google/assistant/library/assistant.py", line 215, in send_text_query, self._lib.assistant_send_text_query(self._inst, query.encode('ASCII')), UnicodeEncodeError: 'ascii' codec can't encode character '\ubd88' in position 0: ordinal not in range(128), 192.168.0.200 - - [28/May/2019 15:35:18] "GET /command?message=불%20꺼 HTTP/1.1" 500 -,

jsj0318 commented 5 years ago

On line 215 of the assistant.py file self._lib.assistant_send_text_query (self._inst, query.encode ('ASCII')) to self._lib.assistant_send_text_query (self._inst, query.encode ('UTF-8')) change 'ASCII' to 'UTF-8', you can make Korean commands without any problem.

myrayearth commented 5 years ago

On line 215 of the assistant.py file self._lib.assistant_send_text_query (self._inst, query.encode ('ASCII')) to self._lib.assistant_send_text_query (self._inst, query.encode ('UTF-8')) change 'ASCII' to 'UTF-8', you can make Korean commands without any problem.

thank you so much! it's work now!

almostserious commented 5 years ago

In case somebody else is wondering about this. If you want to edit the assistant.py directly in the docker you can do that via:

sudo docker container exec -it gawebserver nano /usr/local/lib/python3.5/dist-packages/google/assistant/library/assistant.py

You might need to install nano beforehand. You can do that via: sudo docker container exec -it gawebserver apt-get update & sudo docker container exec -it gawebserver apt-get install nano Not sure if this survives redeployment... but a docker restart seems fine for this :)