translator bot

2023-04-28

Recently, I have been using Shanbay to learn English. Shanbay is a Chinese company that provides English learning services. It has a very good user experience and is very suitable for Chinese people to learn English. Maybe, Shanbay is not the best tool to learn English, but it is quite suitable for me to learn English on my commute. However, Shanbay focus on help people to extend their vocabulary, but not help people to use English. I found one gangster has developed a Shanbay bot which can send word list to users every day via telegram by using javescript. Moreover, it can generate articles based on the word list for review by using chatgpt. Furthermore, voice of article can also be generated by using TTS. I think it is a good idea to use Shanbay bot to practice English reading and listening. Inspired by it, I decided to develop a translator bot using python for myself.

My first step is to reimplement the features of Shanbay bot which I have completed. I call js code by using the execjs package to decrypt the data from Shanbay website.

The source code is available on Github

Secondly, I implement the feature of tranlation between English and Chinese(support more language in the furture). I use vitalets’s repo, which is a free and unlimited API for Google Translate. In order for python to call, I use the express to make it as a service.

Thirdly, the bot can send voice of word to user. I use the edge-tts to implement it. The bot will save the English word to database, once user send the “/text2voice” slash command(as shown below), the bot will query the lastest word from database and generate the voice for user.