This is a continuation from this post about creating your own ANKI SRS card deck for learning a foreign language. The following part is here

Step 3 – Create the translations for your wordlist

If you sourced your words from a textbook you might already have the translations. If so, just put them in the next column. I however didnt have a translation list, so I copied the list of English words and pasted them into Google Translate. This gave a corresponding list on the right hand side. I also checked the “phonetic” button underneath the translation to give the Pinyin translation.

Copy the list of translations to matching positions in the spreadsheet

because I also wish to learn Simplified Chinese, i also translated my list into Simplified Chinese too. (the pronunciations are the same for Mandarin) here is my list after adding all the translations

At this point it will be good to get these translations sanity checked by a native speaker. As I found in case of Taiwanese Chinese, there are some words different in Taiwan than in mainland China. I exported the spreadsheet to an XLS spreadsheet file and I have a friend who was kind enough to take the file and mark down the incorrect ones and replace with the correct taiwanese words. Afterwards I updated my own list in google with the corrections.

Step 4. Generate the sounds.

A great feature of anki is you can attach media to the flashcards. rather than spend the time to create my own samples I wanted to use google translate’s voice to generate the voice samples and attach to my cards.

** UPDATE: I created an open-source app for Mac/Windows that downloads the sounds without having to write and execute scripts. The app is available here. It greatly simplifies the process of downloading the voice files and creating data for ANKI

Thanks to this post on stackoverflow its possible to make a script that will download the mp3 from google translate in the language of choice and save it to a file of the same name. The script looks like this

 # write a Chinese text string as an audio file using Google Translate
 # usage: <text>
 wget -q -U Mozilla -O $1.mp3 "$1"

To create a script, I used the TextWrangler mac app to create a new text file, copy the script text over and save it as (zh being the code for chinese, but it can be any filename you like) to a new empty folder
After you save this file, give it a test run to see that it works.

 $ sh ./ 你好

Should create a file in that directory called 你好.mp3. Check the file and see that it sounds right. (你好, ni-hao, hello)

Also mentioned on that page is how to install wget if its not already installed (which wasn’t installed on this Mac with Mountain Lion) from here.
In the end I created a script from a site online which installed wget for me

 curl -O
 tar -xzvf wget-1.13.tar.gz
 cd wget-1.13
 ./configure --with-ssl=openssl
 sudo make install
 which wget #Should output: /usr/local/bin/wget

try typing wget on the terminal line to see whether not its installed. Obviously, you don’t need to install this if you already have it and the zh2mp3 script worked.

The next part is to create a script that will grab every mp3 sound for your vocabulary list.
Go back to your spreadsheet and add a column called Filenames. In the next row down, type in this formula

 =SUBSTITUTE( TRIM(C2) ; " " ; "")

Be sure to choose the column that relates to the text you want spoken by google translate.
Fill down this formula to every cell in the column (highlight all the cells from E2 down and press CTRL+D / Command D (for macs) to fill down, or drag the selection box down from the bottom right corner. This will copy the cell and change the position to the correct relative position cell reference) This formula removes any spaces, This is necessary for the file names, this isn’t a problem in Chinese or Japanese but may be problematic for other languages that need spaces.

The next step is to create the script call using the source file name. Create a new column title called “Script”. In the 2nd row, write the following script

 =CONCATENATE("sh ./ ",E2)

The result should be something like this: sh ./ 你好
There should be no space in words to translate. If there is, it will affect the file names created.

Again, fill this down so you have one per line for your vocabulary.

Next step is to create a script file. Copy this column’s cells and past them into a new file in TextWrangler. Save this as in the same folder as

Now go to the terminal window and run the script.

 $ sh ./

After some time, you should see mp3’s appearing in the folder in your finder window. When the process is complete, the terminal prompt will re-appear.

These mp3s need to be copied manually to your ANKI media folder. Use Finder to copy every new mp3 file in this folder and paste them over to your ANKI media folder. On mac, this is typically at /Users/username/Documents/Anki/User 1/

you should now have the mp3s you need for each card.

The next part is here.

Share Button