Closed extenlabs closed 3 years ago
I had the previous version of googletrans, reinstalled all dependencies, including googletrans (pip3 install googletrans==4.0.0rc1), and it worked. Thank you very much for the tool, it saved me a lot of time.
Can you create something similar for Japanese? Downloading audio is not an issue but linking it with other data to import everything to Anki is another matter.
I am also planning similar tool for Japanese. In meantime you can use this api.
https://jisho.org/api/v1/search/words?keyword=
If words.txt
file contains following japanese characters
学
好
但
Then using following scripts, reading and meaning can be fetched.
import requests, json
base_url = "https://jisho.org/api/v1/search/words?keyword="
words_file = "words.txt"
save_meaning = "meaning.txt"
m_file = open(save_meaning, "w", encoding="utf-8")
with open(words_file, "r", encoding="utf-8") as f:
for line in f:
url = base_url + line
response = requests.get(url)
print(line)
if response.status_code == 200:
data = response.json()
reading = data["data"][0]["japanese"][0]["reading"]
print (reading)
meaning = data["data"][0]["senses"][0]["english_definitions"]
print (meaning)
print("\n")
# word, reading, meaning
w_r_m = line.rstrip() + "\t" + str(reading) + "\t" + ", ".join(meaning) + "\n"
m_file.write(w_r_m)
#print(response)
m_file.close()
f.close()
After fetching data, it get written to meaning.txt
file
学 がく learning, scholarship, study, erudition, knowledge, education
好 こう good
但 ただ ordinary, common, usual
Audio can also be linked to output result.
Awesome, thank you! I could not fetch the audio but generated some data. It is a great starting point. Now it's time to study 🙂.
I've got these exceptions and could not generate any output.txt.
user@user Anki-Chinese-Vocabulary-Generator-master % python3 main_for_mac.py
Exception in Tkinter callback
AttributeError: 'NoneType' object has no attribute 'group'
Thanks a lot for your help!