Original link: https://blog.amamiyayuuko.com/p/use-chatgpt-for-translation/
Chatgpt has been developed for many strange uses. The other-dimensional software has collected a bunch of third-party programs based on its API, and the niche software has also collected a lot. Here I found a python program called bilingual_book_maker
, which can call the openai API machine to turn the entire foreign language book into a bilingual epub, but because this thing is a python program, it needs to be called by the command line, and it will be far away when the author makes it into an exe. It is difficult to use, so I wrote a tutorial to use this tool easily.
Before jumping into this tutorial, first I’m going to make a checklist to make sure you have these things:
- Foreign language books to be translated, either txt or epub, but not pdf
- github account
- The git client can be a command line, but if you are a novice, I recommend using github desktop
- Text editor, in theory, the Notepad that comes with windows is also available, but it is recommended that you use VSCode, Sublime Text and the like
- The openai account that has been linked to the card
If you have all these, then we can enter the text.
0. First you need to bind the bank card to the openai account
Although this is also mentioned in the previous list, but because it is very troublesome, I will mention it again. The online tutorials basically use depay virtual cards. I also use this method, but I have to say that the virtual cards given by this method are very cheating. If you have the conditions, it is best to find a foreign buddy to get one. Card, otherwise it’s really too bad.
The process of using the depay virtual card to bind openai is as follows
- Register a dapay account, here you can use my invitation code
715205
- After submitting very vulgar personal information to depay, you can open a card that is free but has a huge monthly fee
- Recharge virtual currency to depay (yes, depay can only recharge virtual currency first and then convert it into US dollars)
- In order to engage in virtual currency, you have to register a virtual currency trading platform, such as Ouyi , here you can also use my invitation code
85118482
- Buy USDT on the trading platform, wait for 24 hours and then charge the currency to the depay account, convert it into USD and then charge it to the card. After a long wait and N hand draw fees, the card is finally unlocked
- Finally, bind the card on the billing page of openai . This step needs to use the incognito mode of the browser, link the US node, and then fill in the billing address with a random US address (I filled in the Google headquarters, but it may be better to fill in a tax-free state address )
In this way, you will get an openai account tied to the card. Binding a card is very important to openai, because the API response speed of an account without a card is extremely slow, and it is basically impossible to realize the task of translating a book.
1. Steal work from other people’s project warehouses
First of all, we find the address of the project warehouse of others, click the Fork button in the upper right corner of others, and carry out a live steal.
Then use the tool github desktop to copy the stolen live copy to the local. Preparations are complete. The next step is to start editing other people’s files.
2. Set the API key
Let’s advance the webpage and add a secret named OPENAI_API_KEY
according to the steps shown in the figure, and the content is the API set on the API management page of openai .
3. Put in the files to be translated and edit the workflows file
I stole someone else’s warehouse to the local area before. The thing to do now is
- First, delete the test_books folder of others. This is the folder used by others to test whether the translation is normal. We don’t need it
- Put the book to be translated in the root directory and write down the file name.
For example, the file structure of my directory is
│ .dockerignore │ .gitignore │ disclaimer.md │ Dockerfile │ LICENSE │ make_book.py │ prompt_template_sample.json │ prompt_template_sample.txt │ README-CN.md │ README.md │ requirements.txt │ setup.py │ Sex_and_the_Failed_Absolute.epub │ ├─.github │ └─workflows │ make_test_ebook.yaml │ └─book_maker │ cli.py │ obok.py │ utils.py │ __init__.py │ __main__.py │ ├─loader │ base_loader.py │ epub_loader.py │ helper.py │ srt_loader.py │ txt_loader.py │ __init__.py │ └─translator base_translator.py caiyun_translator.py chatgptapi_translator.py deepl_translator.py google_translator.py gpt3_translator.py __init__.py
Don’t worry about anything else here, the only thing you need to pay attention to is Sex_and_the_Failed_Absolute.epub
, this is the book I plan to translate, write down the file name, it will be needed later.
Then find the file in the \.github\workflows\make_test_ebook.yaml
directory, and draw the gourd directly from my modified file . It doesn’t matter if you don’t want to read the code, just change a few keywords.
- name: translate run: | python3 make_book . py -- book_name "Sex_and_the_Failed_Absolute.epub" -- language zh - hans - name: Rename and Upload ePub if : env . OPENAI_API_KEY != null uses: actions / upload - artifact @v2 with : name: epub_output path: "Sex_and_the_Failed_Absolute_bilingual.epub"
Here you can see that the name of the book to be translated is also mentioned. Every time you translate a different book, you must change this file to be the same as the one you want.
After all changes are made, push these local modifications to the Internet on github desktop.
After that, you can go to sleep and wake up to see if the translation is successful.
3.5. Why use continuous integration
By the way, the serious way of playing this is to run it locally with python. Because I can’t get the local python operating environment, I use a free Microsoft server to run this. The benefits are:
- Their server is already abroad, so don’t worry about openai being blocked by the wall
- Running this program locally requires a python operating environment, which I can’t get
- Running this program locally needs to be turned on all the time, and this one can grow vegetables before going to bed and wake up the next day to collect vegetables
4. The translation is successful
If there is an error, I will probably send you an email in advance. If the error is not reported the next day, it is probably good.
The translated file can be downloaded as shown in the figure.
Finally, I began to taste what strange things Guo Nan said in Eastern Europe.
5. If you bother…
I have been working on this for a long time before I can get it done. Although this process has been simplified many times, if you still find it troublesome, you can use the service that Fengshengyusheng has already built. Remember to use my invitation code: 65BC5C
.
This article is transferred from: https://blog.amamiyayuuko.com/p/use-chatgpt-for-translation/
This site is only for collection, and the copyright belongs to the original author.