Simple java app for listening practice - Demo

Hi! Olá pessoal!

I have been learning Portuguese for a few months now. Sometimes I look up new words on Tatoeba, to see them in context, and then enter the most interesting sentences I find into a spreadsheet. A few hundred sentences have accumulated so far, and I always wondered how I could make the best use of these sentences. I know some basic java, so I decided to put my humble programming skills into action and create an application for improving my listening skills. :-)

I have a Mac, which has two built-in Brazilian Portuguese voices. They are fairly decent, but I decided to go with a third one, which I had to pay for (it was really cheap). I had my computer record all my sentences spoken by this robot lady (in two different speeds, much like in Duolingos listening exercises), and converted the resulting '.aif' files to '.mp3's. I'm not sure how it's done on Windows, but now that I have figured it out, I can reproduce these files anytime from the sentence list in just a few minutes.

Then I created a simple Java application where I can hone my listening skills. Here's a quick demo of it:

I think this is a great way to complement Duolingo. It could be easily expanded to any other language, the only things needed are:

  1. A list of the sentences to be practiced (translation is optional)

  2. A quality TTS voice that you can record your sentences with.

What do you think about it? I could make this public in the future if people are interested, or even large common sentence pools could be built by the community for every language. It took me a few hours to create this application, so I'm pretty sure a knowledgeable programmer could write an much more useful program as well.

September 18, 2014


Sorted by top post

Very nice. The next step is to "gamify" it, that is to add some scoring mechanism to encourage the user to do better next time. You could add longest correct run counts, high scores and all that jazz. I realise that at the moment there is no mechanism to tell you whether you are are right or wrong, but that could easily be added, particularly if nothing less than 100% correctness is desired. Perhaps, though, it would be simpler to use self-assessment: you could add two buttons marked "Right?" and "Wrong?" and use your own judgement about which one to press. That would avoid the pain of writing a complicated algorithm giving the required degree of leeway.

What about including an option to speak the sentence you hear rather than typing it? When you have finished dictating the sentence you can listen to how well you've done. Here, to avoid the complexity of voice recognition, you really would need to use self assessment. Perhaps you could play the synthesised audio on one channel and your attempt on the other channel of a stereo pair. One little niggle is how to deal with the need to listen to the sentence several times as you do when keying it in. Perhaps you would need a small amount of audio processing where the "dead" parts of the recording (I mean the times where you are reviewing the synthesised speech) are sliced off automatically based on when you pressed the "play" buttons. Less complex would be to simply display the text of the sentence and invite the user to say it and then replay both versions for assessment.

Of course as you have the text in both languages and the possibility of synthesising speech in both languages there are many other possibilities for testing the user's translation skills using the simple self-assessment model I mentioned.

Anyway, thanks for telling us about your effort. Have you thought about porting it to HTML5/JavaScript for those of us who no longer trust Java? :-)

September 19, 2014

I have thought about implementing some scoring mechanism as well, it could work similarly to Anki, maybe you could grade your answer yourself on a scale from 1 to 5, or something like that. As to the speaking part, Anki already offers the option to record your voice after reviewing a card and replaying it. I'll think about it though.

The only programming knowledge I have is in Java, so I haven't thought about using anything other than that. :-) I only write programs for my own personal use, so I never had the urge to learn any other programming language, even a user interface like the one in this program is a stretch for me, I usually just run my programs from the console. :-P But it's a very simple program, and I haven't patented it, so anyone can extend the idea. :-)

Since opening this topic, I have found another useful tool that makes collecting sentences a child's play. There is a website called where you can set your source and target language and collect pairs of sentences from native Tatoeba contributors. It's very fast, I managed to save more than 400 sentences in less than an hour. There were only a few sentences that I had to dismiss in the process because the translations weren't good enough. This was the missing piece of the process of building a database for my program, and now it's resolved. :-)

Oh the good old days of console. We should never have moved away from consoles. I recall entire text adventures where you "played" the game only using keywords and text output. :)

Javascript isn't that different from java, the real headache is html, and the other libraries that complement javascript. I'm sure it wouldn't take long to learn it, but you'd probably take time to get used to the whole tagging system.

I'm a PDP-11 Unix veteran. :-)

% cc hello.c
% a.out
Hello, World
% adventure
You are in a maze of twisty little passages, all alike.

User :"Move left"

Game: "You fell on a pit. Game over, you were almost there. New game (Y/N)?" .


Well, keep up the good work, it is an excellent start.

Interesting. The trouble with javascript is that it must be hosted somewhere. So it may even less trustworthy than java which can be hosted locally. So one has to actually weigh the pros and the cons.

What I really meant was that I'm weaning myself off Java and I don't have it on my current PC - I'm sure I have plenty of security holes already and so far I haven't found a pressing need for it. It also annoys me that the Java updater always tries to sneak some unwanted software onto my other machines.

I read that Chrome lets local JavaScript have local file access:

I haven't verified that and I don't know whether that feature is as cross-platform as Chrome itself. Clearly it isn't safe to let any old thing run locally, but for development it sounds good - if it works.

Well, I simply stopped worrying about security holes when I decided to take the plunge with the penguin OS. The waters are cold along this side but you get used to it.

In truth javascript is not much different from java, both require an environment to work on. If browsers ever go out of fashion the same will happen to javascript.

I like the idea of javascript but in the end it requires much more thought processes than simple java. You need to understand HTML + Java + Client server architecture.

In fact I've resisted learning javascript deeply, exactly because of HTML, it is one annoying language with all those double tags for even the simplest of things. I wish I could push the html designer down under.

Anyway, that hack may help with the listening app. :)

Dude I'm a computer scientist and Java programmer, this is awesome and a great idea!! have my lingots!!!

Talk is cheap show me the code!!! :)

That's rather inventive. I think it could actually help the people learning Irish since about 2/3 of the sentences have no translation. Although I'm not so sure any Irish voice is available for sale. I also designed an app for fun a long time ago (Wacky Sudoku). I intended on making crosswords using the same code or similar code. But I never got around to making it.

I hope you do share it.

Nice! There should be a section on the site where we can share such little programs with other DLers, as some ideas will never make it to the main site, but they are still very useful for a lot of people.

I don't know of an Irish voice either, I guess if there was one, the Irish course wouldn't use real voices.

Well, the Duowiki, Userscripts, is pretty much my personal dumping ground for anything remotely related to Duolingo.

There is a Irish TTS voice created by a particular university. But it seems they concentrate on using it for research purposes, and probably aren't very organized in terms of monetizing it.

As for other apps, I'd love to make more, and I kinda thought of making a similar one that scrambles words. But given that Duolingo's api is closed, and extracting words from it is a tedious process I just gave up on the idea.

These userscripts look great, I never knew such a site exists. Thanks!

Achei interessante... E a pronúncia é muito boa também! Eu sou programador, se precisar de ajuda para alguma tradução ou coisa do tipo... pode me contactar.

i have only just started portuguese but i really enjoy it i like what you do to learn more. well done :-)

Eu gostei do seu trabalho! ;-)

Learn Portuguese in just 5 minutes a day. For free.