Creating Anki flashcards with audio from any Book2 / 50Languages phrasebook

Tristrum Tuttle
4 min readDec 31, 2024

--

I am currently learning Marathi, a language with limited learning resources for native English speakers. You won’t find Marathi on Duolingo, Rosetta Stone or most other language course providers. After lots of searching I discovered Book2 (now 50languages), which does offer a Marathi phrasebook including 2000 common phrases along with phonetic translations in English and audio.

Unfortunately, the Marathi phrasebook is only provided as a textbook or free MP3 audio book. On the 50languages website, I can view all the phrases and play individual audio recordings for each one, but there are no flashcards. Separately, Anki, the free and open source flashcard tool I wanted to use, does not have any shared Marathi flashcard decks available that included both audio and English phonetic spelling.

Luckily, I was able to create my own flashcards and import them into Anki using a Python script. In previous years, it likely would have taken me a whole afternoon to figure out the best way to grab specific HTML text elements in BeautifulSoup4 and google the Python syntax for writing / reading CSV files, but ChatGPT was able to spit out some starter scripts and made debugging a breeze:

All the code for this project can be found in this public Github repository: https://github.com/triton11/50-Languages-Book2-to-Flashcards

Steps for creating Anki flashcards from ANY Book2 / 50 Languages phrase book using the repository:

  1. Clone or download the repository from https://github.com/triton11/50-Languages-Book2-to-Flashcards
  2. Install: Python 3 (already installed on most new macbooks), then pip install beautifulsoup4 and pip install requests
  3. From the main directory, run python3 scraper.py first. This will create a csv file that can be imported into Anki to generate the flashcards. You will be prompted to enter the language code (i.e. Marathi is ‘mr’ in https://www.50languages.com/em/learn/phrasebook-lessons/162/mr) as well as the start page and end page. I think this may just be 162 and 261 respectively, for all languages, but I haven’t confirmed manually.
  4. After running scraper.py, download the audio for each phrase by running python3 language_downloader.py. This will save one audio file per phrase into the “audio” directory.
  5. To set up the flashcards in Anki, install Anki on your desktop.
  6. Copy the audio files in the “audio” directory to the collection.media directory of your Anki desktop app. This folder was a bit buried, but can be found by navigating to Tools → Check Media → View Files in the Anki desktop application. These files can now be automatically referenced by any flashcards using a field with a value like: “[sound:MY_AUDIO_FILE.mp3]”

7. In the Anki desktop app, navigate to “Browse” then “Fields…” to create the fields we need for the file import:

8. Next, from “Browse”, navigate to “Cards…” to customize the card template. I have my cards set up to display the English Text on the front, and the Phonetic Translation and Audio on the back. If the Audio files were imported correctly in step #6, then adding the {{Audio}} field should be all that is needed to get the ⏯ button to appear and play the audio automatically when the card is flipped.

9. In the Anki desktop app, from “Decks” select “Import File” and import the csv generated in step #3. Make sure to change the delimiter to “comma” and map the fields correctly (map Audio to Audio File Name)

And thats it! At this point, you should have your 50languages / Book2 flashcards set up and available in Anki!

Additional Notes:

  • My wife is fluent in Marathi (it is the language of her parent’s home state in India) and has been helping me with the proper pronunciation and easier / more casual alternative phrasing than Book2 versions. I haven’t figured out a technical solution to make this feature widely available to other learners, but I highly recommend falling in love with someone that can support your learning journey!
  • I decided on Anki after researching a few options, including Quizlet (limited support for Spaced Repitition) and Brainscape (seemed expensive for the features I wanted). I really wanted a flashcard app with 1) a mobile app, 2) easy import of custom cards and 3) spaced repetition, so Anki ended up being an obvious choice!
  • I reached out to 50languages to see if I could publish the Marathi flashcards publicly on Anki’s shared decks, since it seems like at some point the Book2 resources were licensed under the Creative Commons. Unfortunately, they emailed me back and confirmed the materials are copyrighted and cannot be published elsewhere.

--

--

No responses yet