yihong0618 / bilingual_book_maker

Make bilingual epub books Using AI translate
MIT License
6.91k stars 1k forks source link

Question on CustomAPI #357

Closed nikotung closed 6 months ago

nikotung commented 6 months ago

I read the codes on custom_api_translator.py. Do the source_lang and target_lang placed in the wrong position? The target_lang should be the language specified in the cli by —language, right ?

def translate(self, text):
        print(text)
        custom_api = self.custom_api
        data = {"text": text, "source_lang": self.language, "target_lang": "auto"}
        post_data = json.dumps(data)
        r = requests.post(url=custom_api, data=post_data, timeout=10).text
        t_text = json.loads(r)["data"]
        print("[bold green]" + re.sub("\n{3,}", "\n\n", t_text) + "[/bold green]")
        time.sleep(5)
        return t_text
yihong0618 commented 6 months ago

yes, can you open a PR to fix this?