Skip to content

Latest commit

 

History

History
48 lines (32 loc) · 2.87 KB

README.md

File metadata and controls

48 lines (32 loc) · 2.87 KB

Code and docs written by ChatGPT. Proofread and edits by human.

What it is

This script fetches pronunciation audio for words in Anki flashcards from forvo.com. It processes Anki flashcard export files in plain text format and adds pronunciation audio links to each flashcard. Anki will automatically play those audio.

Prerequisites

  • Node.js installed on your system.
  • Anki app installed on your system.
  • You cards front include only the word you want to fetch pronunciation for. Articles are allowed (see usage for details).

Usage

  1. Export your Anki flashcards. Use following options:

    • make sure all card front should be in target language (the one we want to fetch pronunciation for)
    • "Notes as in Plain text" format
    • all checkboxes unchecked (except for "Include unique identifier")Screenshot
  2. Run the script using the following command:

    npx anki-forvo-enrich <path-to-file> <lang> --articles <list>

    Replace <path-to-file> with the path to your exported Anki file and <lang> with the ISO 639-1 language code (en/es/nl...). Articles are optional comma separated list of article for <lang>. If no article is provided, the script will attempt to fetch pronunciations ignoring articles if needed.

    Example: npx anki-forvo-enrich /tmp/Spanish.txt es --articles "el,la"

  3. After processing, a new file with pronunciation links will be generated in the same directory as your original file. See script output for details.

  4. Import this new file back into Anki using the "Import" feature. You can either use new deck or import into existing deck, existing cards will be updated.

Screenshot

Screenshot

Libs Used

  • axios: For making HTTP requests.
  • cheerio: For parsing HTML and extracting data.
  • fast-csv: For reading and writing deck files.
  • fs: For handling file system operations.
  • path: For handling file paths.
  • ISO-639-1: For validating ISO 639-1 language codes.
  • os: For handling OS-specific operations.
  • chalk: For colored console output.
  • commander: For command-line interface options.