EZClips Anki addon

I have finally got round to writing an addon for Anki that allows the creation of audio cards without cutting up the audio, so the cards remain adjustable within Anki.

Addon: LINK

Preconfigured deck: LINK

I have only tested it on Linux, but it should also work on Win/Mac with any luck if I have copied the relevant bits from Anki's source correctly.

For now the user must manually extract audio/subs tracks from the raw file (e.g. using mkvtools). See the placeholder card in the above preconfigured deck for further instructions.

It seems to work OK though it hasn't been through heavy testing yet. Suggestions welcome.

Edit: just discovered that it crashed on empty lines. Updated Rolleyes

Edit: more info:

Deck fields:

ClipInfo: audio-filename|first-subs-line|extra-subs-lines|pad-start-time|pad-end-time
For example blah01.aac|120|1|0.1|0.1 describes a clip from file blah01.aac consisting of lines 120 and 121 from the corresponding subtitles file (required to be blah01.ass), with the start and end timings padded by 0.1s.

Subs: Subtitle text as specified in ClipInfo. Auto-updates if empty or when extra-subs-lines has been adjusted and this field has not been edited (so as not to lose info).

Audio: clipinfo:audio <- this exact string must appear somewhere on the card to get the audio to play.

FrontNotes: Use this field to put extra info on the front of the card (hints, etc)

BackNotes: Use this field to put extra info on the back of the card.


(1) Use mkvextract from MKVToolNix to extract the audio and subs tracks from a video file. Example:

mkvextract tracks "Blah Episode 01.mkv" 1:blah01.aac 2:blah01.ass

Put the resulting files in the Anki/addons/ezclips directory.

(2) Run the ezgen script (to be found in the Anki/addons/ezclips directory) with the audio filename and capture the output to a file. Example:

ezgen blah01.aac > temp.tsv

(3) Import the resulting tsv file into the EZClips deck. The fields are set up to make this easy.


Any audio (or even video) format supported by mplayer, but only .ass format subtitles atm.

Only one set of subs, so probably only useful for more advanced learners.

Edit: location of ezgen script
Edited: 2015-08-23, 6:03 am
Looking at instructions I have absolutely no idea how this works. Why does it need a placeholder deck?
Hi ryuudou, thanks for your feedback. I have updated the description, HTH.

The preconfigured deck just has all the fields set up correctly so the plugin works (the ClipInfo and Subs field names are hard-wired into it) and to make it easy to import the files output from ezgen. It has a placeholder card because AFAIK you can't share an empty deck on Ankiweb.
Wow, that's awesome, this could potentially save me so much time, and also save me an incredible amount of pain with huge media folders. Only probalem is, I assume there's no way to add this to a mobile client でしょう?
Hi NinKenDo, thanks for taking an interest Smile

Unfortunately the resulting decks are dependent on the addon for now, so won't work with Anki mobile.

I do plan to add a feature to convert cards to ordinary "sound:" clips at some point, though as I have no use for it myself it could take a while ...

I have temporarily removed EZClips from Ankiweb as I am about convert the line numbering to 1-based (as opposed to annoyingly 0-based at present), which will irredeemably break any decks produced by the old version.

Completely rebuilding a deck with the new version will be as simple as:

./ezgen *.aac > temp.tsv

Though this will lose card review history plus any edits.

As yet nobody has downloaded the preconfigured shared deck so I'm guessing this won't affect a whole lot of users Smile

Edit: new version uploaded, links changed.
Edited: 2015-07-14, 3:46 pm
This sounds very interesting, unfortunately I have no idea where to get the "ezgen script". Can you help me?

By the way, there are a couple of errors that popup on Windows when starting it:

Line 30: devnull=file(os.devnull,"rw")
* It say "Invalid mode ('rw')". Changing it to w+ or something else makes the error message go away.

Line 60: dir = os.path.dirname(os.path.abspath(sys.argv[0]))
* You need to import sys at the beginning of the script.
Hi Awaken, thanks for the feedback.

I have updated the script - not sure why the devnull thing was there at all ... probly gonna find out Rolleyes

The ezgen script is in the addon's own directory, i.e. Anki/addons/ezclips - I have updated the description to make this a bit clearer.

I've been using EZClips extensively myself & find it very convenient. Processed a whole episode of Prison School in barely 20 mins yesterday.

There are many possible improvements but ... I think they are gonna have to wait until after I ace the N1 Smile

Have you tried using it? Would be nice to know if someone else has got it working
Thanks! I didn't get the ezclips folder before.

In windows, I needed to install Python 2.7 to be able to run the script, like this: python ezgen DC-646.aac > temp.tsv

I tried it with chapter 646 of Detective Conan.

This is the ass file:
And this is the output in the temp.tsv file:

I couldn't import it to Anki.

Then I tried to manually edit the temp.tsv file, so things look properly when I import it to Anki. For example:

[Image: Q3XYMC6.png]

But then, every time Anki plays the audio, it's always from the beginning of the file...

Any help would be appreciated.
Unfortunately I don't think there is any easy way to fix this.

One issue is Window's CRLF line endings, which should be fixable by editing line 93 thusly (not tested):

93: prev,curr=curr,parse_subs_line(rawline.strip()) #add .strip() to rawline to get rid of CRLF

Another issue is that ezgen joins lines on the assumption that they are English, so '.' ends a line, ',' continues it, etc. Obviously this doesn't work for j-subs & looking at the example you provided would need a fair bit of mucking about to do it right. For now just replace line 117 with this and it won't join any lines:

117: return True

For the playback issue, the mplayer commandline to use under Windows needs fixing with some experimentation, but as I use Linux this is a bit tricky. First thing to try is to replace line 59 with:

59: self.cmd = ["mplayer.exe"] # remove "-ao", "win32" options & try default driver

If that doesn't work, on the commandline try: mplayer -ao help to get a list of drivers & try each one in place of "win32" (i.e. try ["mplayer.exe","-ao","other-driver"] in line 59). Note that you will have to restart Anki every time to make it reload the addon, so it might be easier to experiment directly on the commandline:

The current overall play command is something like:

mplayer.exe -ao win32 -really-quiet -noautosub -novideo -ss START_TIME -endpos LENGTH FILENAME

Where START_TIME and LENGTH are in seconds.

If you can get it to play starting in the right place please let me know and I'll update the addon Smile

HTH and thanks for your help. I suspect that the next problem will be insurmountable, however ...
Thanks a lot! I finally got it working. Big Grin

Your fixes for ezgen worked perfectly.

For the other issue, I tried all drivers, but none worked. I thought that it might be the aac file, since I couldn't seek positions even in other players. So I inserted it into a mp4 container and now it works perfectly with the default win32 driver.

So, it might have been a broken aac file or it's just that format that doesn't allow seeking.

After that, in Anki, sounds would only play once. If I tried to play another sound or replay the same sound, I'd get this error:

I deleted these lines in two places:
if self.process:
...And now everything seems to be working great. Big Grin

Anyway, I've been playing around with some cards and this add-on is really awesome. Never again clipped words or long silences! Big Grin
Nice, I'm going to have to try this out, as an alternative to subs2srs. Best part: it works on Linux without a Windows VM. Sadly, I won't be able to review subs2srs cards on android, but that's better than waiting the huge amount of time it takes for the audio files to be split and the inconvenience of a VM.

Plus, I don't need screenshots.
Please, could you explain step by step,how can I Run the ezgen script?
Edited: 2017-03-28, 9:35 am