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

[Bug]: not removing non UTF-8 characters before Youdao API call #742

Open
frank3215 opened this issue Nov 15, 2024 · 0 comments
Open

[Bug]: not removing non UTF-8 characters before Youdao API call #742

frank3215 opened this issue Nov 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@frank3215
Copy link

frank3215 commented Nov 15, 2024

Issue

UTF-8 characters should be deleted before sending request to Youdao, else the request will result in 202.

如果确认应用ID和应用密钥的正确性,仍返回202,一般是编码问题。请确保翻译文本 q 为UTF-8编码.

https://ai.youdao.com/DOCSIRMA/html/trans/api/wbfy/index.html

Command Line Arguments

-m manga_translator -v --translator=youdao -l CHS -i --use-gpu

Console logs

[batch] Loading models
[batch] Running text detection
[DefaultDetector] Detection resolution: 1536x1280
[batch] Running ocr
[Model48pxOCR] prob: 0.29797518253326416 👌 fg: (153, 160, 152) bg: (249, 186, 215)

...

[batch] No pre-translation replacements made.
[batch] Running text translation
[YoudaoTranslator] Translating into Chinese (Simplified)
ERROR: [batch] InvalidServerResponse: Youdao returned invalid response: {'requestId': '382cd8df-0ed6-4647-8f81-39cc98d5e543', 'errorCode': '202', 'l': 'auto2zh-CHS'}
Are the API keys set correctly?
Traceback (most recent call last):
  File "manga-image-translator/manga_translator/__main__.py", line 99, in <module>
    loop.run_until_complete(dispatch(args))
  File "/opt/homebrew/Cellar/[email protected]/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "manga-image-translator/manga_translator/__main__.py", line 59, in dispatch
    await translator.translate_path(path, dest, args_dict)
  File "manga-image-translator/manga_translator/manga_translator.py", line 178, in translate_path
    if await self.translate_file(file_path, output_dest, params):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "manga-image-translator/manga_translator/manga_translator.py", line 205, in translate_file
    return await self._translate_file(path, dest, ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "manga-image-translator/manga_translator/manga_translator.py", line 248, in _translate_file
    ctx = await self.translate(img, ctx)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "manga-image-translator/manga_translator/manga_translator.py", line 305, in translate
    return await self._translate(ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "manga-image-translator/manga_translator/manga_translator.py", line 470, in _translate
    ctx.text_regions = await self._run_text_translation(ctx)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "manga-image-translator/manga_translator/manga_translator.py", line 579, in _run_text_translation
    await dispatch_translation(ctx.translator,
  File "manga-image-translator/manga_translator/translators/__init__.py", line 130, in dispatch
    queries = await translator.translate('auto', tgt_lang, queries, use_mtpe)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "manga-image-translator/manga_translator/translators/common.py", line 183, in translate
    _translations = await self._translate(*self.parse_language_codes(from_lang, to_lang, fatal=True), queries)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "manga-image-translator/manga_translator/translators/youdao.py", line 66, in _translate
    raise InvalidServerResponse(f'Youdao returned invalid response: {result}\nAre the API keys set correctly?')
manga_translator.translators.common.InvalidServerResponse: Youdao returned invalid response: {'requestId': '382cd8df-0ed6-4647-8f81-39cc98d5e543', 'errorCode': '202', 'l': 'auto2zh-CHS'}
Are the API keys set correctly?
@frank3215 frank3215 added the bug Something isn't working label Nov 15, 2024
@frank3215 frank3215 changed the title [Bug]: Youdao can only handle UTF-8 characters [Bug]: not removing non UTF-8 characters before Youdao API call Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant