Skip to content

Language Learning – Using Anki with GoogleTTS

October 17, 2011

Even though I mentioned Anki (first and later) back in 2008, but not until 2009 I first tried it out for learning French. At that time it was already a pretty good learning tool based on space repetition method. It provides cross-platform desktop and mobile softwares and AnkiWeb with synchronization between them , so that you can learn your topic anywhere.

I typed the French phrases or sentences I learned from Pimsleur so that I could practice later. From typing them, I could also check the spelling part. The only drawback was that I couldn’t practice listening and speaking. Anki does have option to let you add audio files to each card. If you have a phrase book that comes with mp3 files, then it is not a big issue. But what if you don’t have? What if you just want to learn whatever text you input (such as new words from a book or an article)?

Google Translator can translate the text from one language to another and it offers “text to speech” option below the text box. It’s very handy and I use that option sometimes. Mr. Fragoso wrote a small program (GoogleTTS, i.e. Google Text to Speech) to let you generate audio files (mp3) from the text in each card, or play it on the fly (connected to the internet).

This is exactly what I need. :D

However when I first tried it, it took me sometimes to get it work. Part of the reason is that the documentation is not very clear, especially difficult for the Anki newbies. Hopefully the following instruction can be useful for them.

Installation

In Anki desktop software (I’m using Windows version), File\Download\Shared Plugin…

GTTS-01

After download the plugin, restart Anki and it’s ready to go. You can find the plugin shown in Settings\Plugins\Startup. Click at “Open Plugin Folder” to locate GoogleTTS.py file. Open the file using a text editor (like Notepad++), and read the information (usage) on the header.

GTTS-02

In “Tools/GoogleTTS”, you can set the language used in Google TTS

GTTS-04

The default setting is English. You can change the default setting in GoogleTTS.py ( TTS_language = ‘en’). In my case, I change it to French (fr).

How to Use GoogleTTS

1. Play over the Air

(a) Use hot keys

  • F3 – get the [GTTS::] tags in the Question pronounced
  • F4 – get the [GTTS::] tags in the Answer pronounced
  • F6 – get the whole Question pronounced
  • F7 – get the whole Answer pronounced

The easiest way is to use F6/F7 hot keys, provided that your card model  is “Basic” and only use one language for each field. For instance, below is my French Test. Pressing F7 GoogleTTS will pronounce “l’eau minérale” in French.
Anki-01

However, if Question and Answer (Front/Back field) use different language, then you’ll need to change language every time when you switch field. That’s very inconvenient. You can solve this using the following method.

(b) Use [GTTS::] tag

In Card Layout (visible when you’re reading one of cards or through “Browser” from “Edit\Browse items…”), you can add “<!– [GTTS:en:{{Field Name}}] –>”. Currently I use this method for my French learning. You can download my example “French Numbers“.

Here I want it to pronounce the whole Answer in French. This way will also hide the [GTTS::] tag and everything inside it, as seen in the preview.

GTTS-07

You can tells GoogleTTS which section of the text in one field to pronounce by using [GTTS:language_code:text].

Here beside the Arabic number I add English pronunciation in the Question (Front field). It will first pronounce “zero” in English, and then “zéro” in French when clicking “Show Answer”.
GTTS-08

Notice that this tag will be visible when viewing the card. The only way to hide it is to set the font color as white.

You now can press F3 to play it again. If press F6 instead, you will hear the whole Question including the tag.

Decks using [GTTS] tags will not be pronounced when viewing them in mobile devices or in AnkiWeb. You’ll need the next method.

2. Generate MP3 Files

GTTS-03

(a) Generate MP3 file(s) in one or multiple cards

Highlight the ones you want GoogleTTS to generate MP3 files and choose (A).

Then choose the language, and set the source and destination fields. If I want it automatically to generate MP3 files for the answer, this is how I should set. However, this way also replace the French word in the Answer with the sound file link. In other words, you won’t see the French word, when clicking at “Show Answer”. With [Sound] tag, it makes the file link invisible.
GTTS-09

(b) Generate MP3 file(s) by entering the text

In Question or Answer text box, clicking (B) brings up this window.
GTTS-05

Enter the text and choose the language you want. You can hear the pronunciation by clicking “Preview”. Clicking “OK”, it will generate the MP3 file and put the file link in place.

GTTS-06

Some Notes

This covers the basic of GoogleTTS usage. But if you want the pronunciation working in your mobile devices or in AnkiWeb, you need to do few extra steps. Read this section “Syncing Media” before start generating audio files for your deck.

26 Comments leave one →
  1. Ryan permalink
    November 10, 2011 10:00 am

    Great tute – it’s even easier if you have an android phone. Your can sync a deck to Ankidroid (manually or via a private deck stored on anki’s server). Then the first time you review that deck it will ask you if you want the question and/or answer field(s) read out automatically. All software should be so easy to use!

    • November 10, 2011 10:07 am

      Thanks for the tip, Ryan. Unfortunately my cellphone is a very simple one. Will keep that in mind.

    • Ramon permalink
      June 23, 2012 12:18 am

      Wildeny,

      I have ankidroid, but i could not understand what you mean. Doy you mean that mobile android anki can reproduce sounds from cards? How is that possible?

      • June 23, 2012 12:24 am

        A short answer is yes, it can. I recently bought a smartphone so I had tried this feature in Ankidroid. Pretty good for the default text-speech engines provided in Android system. Maybe I can demo this in details later.

    • Ramon permalink
      June 23, 2012 12:20 am

      sorry, my question was for Ryan.

  2. just me permalink
    December 22, 2011 12:54 pm

    The better way to do this is to create a new field in card layout. Call the field sound and then when you use Mass generator just select sound as the destination field. Also your card layout will have to look like this:
    {{Front}}
    {{Back}}{{sound}}

    you could put the {{sound}} field wherever you wish to hear the sound such as on the front card or on the back card or both

  3. Laura permalink
    January 18, 2012 6:49 am

    Hi, I’ve learned english using anki and it was really helpful. Now I’m thinking about learn French but I don’t know how to start. Because I don’t know no one word e so it’s very difficult get a phrase. And I’ve read that isn’t good leave words loose on your cards due the problem that one words can have differents meanings. I’m thinking to start with children’s stories, that usually have simple phrases, but I don’t know. How did you start?

    • January 18, 2012 7:20 am

      Hi, Lauda. My French is still very limited. What you said is true, that one word can have many meanings. Using flashcard method like Anki is to help memorzing some things. It can be still useful even just to learn part of the meanings of one word or some phrases. To be frank, currently I use Anki to learn to sing some French songs. :P

      Reading Children’s stories is a good idea too. You can start with some famous French children’s books. How about Titin’s? :-)

      • Laura permalink
        January 18, 2012 10:42 am

        Thank’s for the hint! I try it.

  4. Edwin permalink
    April 18, 2012 12:23 am

    awesome info!! You might want to add that

    if you DON`T want to overwrite your source field (back of the card) you can simply go to card layout (while viewing any card) and ADD a field (let`s say….”sound”). Then you can go to browser, selct all, source field as back(or wherever the language you want pronounced is) and set the destination as SOUND. done!

  5. frito permalink
    April 27, 2012 9:47 am

    thx for the tut.

    Do you know how to get it to Sound the word asap the word appears(without the need to push the button)?

    • April 27, 2012 9:53 am

      You can try the method described in my post. It automatically speaks the words I assgin.

  6. frito permalink
    April 27, 2012 5:00 pm

    So there is no way by using GTTS:: tag to trigger sound playback automatically without pressing anything?

    What works as I wanted is simple use of [sound:foo.mp3], GTTS would not work that way.

    • frito permalink
      April 27, 2012 5:23 pm

      Well never mind GTTS tag.

      The method described above in 2. a) + the comment by ‘Just me’ of using another field e.g. {{Sound}} works just fine. ^_^

      • Chrono permalink
        September 4, 2012 4:53 am

        The way I get sound to play automatically when the answer appears:

        1. Go to Card layout
        2. Add the sound field to the question or answer, for example:

        {{{Back}}}

        becomes

        {{{Back}}}{{{SOUND}}}

  7. June 25, 2012 6:27 pm

    I’m a pretty new Anki user learning Arabic vocab, and I’m using Forvo for pronunciations (it’s a great open-source pronunciation site that tells me what Arabic dialect I’m hearing when I download). The problem is, I’m not sure on which side of the card I should add the audio file. Should I do text + audio on one side of the card, and the picture on the other? Or should I do picture + audio on one side, with text on the other? Is there a way to do both?

    • June 25, 2012 7:10 pm

      It really depends on what you’re targeting at.
      When I learn French with Anki, I use audio (French) on both cards, because I just want to be familiar with the French pronunciation.

  8. Ramon permalink
    June 29, 2012 2:03 am

    Hello again,

    I use ankidroid to study Japanese language, but so far ankidroid does not support text-to-speech for this language. It does for common languages as English, Spanish, etc, but no Japanese.

    Could you help to find a way to select Japanese voice on text-to-speech option for ankidroid?

    • June 29, 2012 2:08 am

      I noticed this problem too. Unfortunately there is no free text-to-speech for Japanese in Android system. Here is the suggestion for paid-version engines for Japanese.

  9. anki88 permalink
    January 26, 2014 11:09 am

    Hi, everyone!
    I stuck with a problem. When I use ankiweb from PC it plays audio, but when I do the same from my mobile it doesn’t play any sounds.
    Can I solve this issue? Thanks in advance :)

    • January 26, 2014 6:21 pm

      I have the same problem. It seems that AnkiDroid has remove the TTS option from its settings. I haven’t found a solution yet.

  10. July 22, 2014 3:47 pm

    I just found your post when I was looking for a solution for the exact problem (TTS to create sound files (so that they are also synced to mobile)). And there is a plugin called awesomeTTS (I guess it wasn’t available when you wrote the post). It can also use GoogleTTS and works really well for batch adding the sound files. Maybe you want to check it out. https://ankiweb.net/shared/info/301952613

    • July 22, 2014 6:03 pm

      Thank you for your information. I did try this awesomeTTS. It works great in Anki desktop version but not as what I wanted (TTS over the air) in the mobile version (AnkiDroid).

      • July 23, 2014 4:39 pm

        True, it is not over the air, but if you simply batch add the mp3 files on your desktop once you have it on all your mobile devices. I don’t see any disadvantage in having them generated once instead of everytime again. But if it doesn’t work for you I wish you good luck for your further search :-)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: