Code and docs written by ChatGPT. Proofread and edits by human.
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.
- 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).
-
Export your Anki flashcards. Use following options:
-
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"
-
After processing, a new file with pronunciation links will be generated in the same directory as your original file. See script output for details.
-
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.
- 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.