pyscript
pyscript copied to clipboard
Blocking Call Error
Very new to all of this, but I am trying to use a python script to interact with an api to translate some text. My code is:
from google_trans_new import google_translator
@service
def translate(text=None, destlang=None):
translator = google_translator()
#translate_text = translator.translate(str(text),lang_tgt=destlang)
translate_text = task.executor(translator.translate, text)
log.info(translation)
For my requirements I have:
google_trans_new
But when trying to call this service (and/or just on the automatic reload) I get:
2022-07-19 13:39:51 INFO (MainThread) [custom_components.pyscript.global_ctx] Reloaded /config/pyscript/translate.py
2022-07-19 13:39:56 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Running websocket_api script
2022-07-19 13:39:56 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Executing step call service
2022-07-19 13:39:56 ERROR (MainThread) [custom_components.pyscript.file.translate.translate] Exception in <file.translate.translate> line 7:
translate_text = task.executor(translator.translate, text)
^
JSONDecodeError: Extra data: line 1 column 2485 (char 2484)
@Jracon could you please update or close the issue? Thank you