Ruby script (mac only)for audio only vocab drills using the Lingq API

Let me know what you think guys. I made this script because I felt like I was over doing it with reading but neglecting my listening skills. I know text to speech is not ideal, but it is better than nothing at all.

Source code:

Video of it working for all the non-mac users:

Good idea!

I get an error.

$ ruby eartrainer.rb
eartrainer.rb:1:in `require’: no such file to load – rest_client (LoadError)
from eartrainer.rb:1

I tried “gem install rest-client” and that didn’t seem to help. Any tips?

Nice work

keke_eo – assuming you’re on a *nix platform you’ll have to do “gem install rest-client” “gem install json” and “gem install pry” I don’t know anything about Windows, so you’re on your own there

Opps. I forgot to remove the pry gem. Thats one I used only for debugging. I would like to point out though that this app will ONLY work on mac. It’s unfortunate, but I couldnt find w better speech api to use. Suggestions and forks are welcome.

I reinstalled the xcode tools with the command line tools option. I still get the same error as above after doing “gem install rest-client” “gem install json” and “gem install pry”. I’m on a mac running OS X 10.7.5. any ideas?

Try typing that command with the word “sudo” in front of it to install those gems as system administrator. Also, delete the line of code from the program that says “require pry”. That was a mistake on my part and you really don’t need pry to run this program.

sudo gem install rest-client
sudo gem install json
sudo gem install pry (if you don’t delete the line from the app that says ‘require pry’- but I recommend you do)

This will install those files system wide (It sounds like you installed them, but Ruby can’t find them in your current directory). Let me know how it goes. Also, make sure you enter your API Key into the line that says “api_key =”. If you don’t do that you’ll get an error about invalid URL’s.

I ran all the commands with sudo.

$ sudo gem list

*** LOCAL GEMS ***

coderay (1.0.8)
json (1.7.5)
method_source (0.8.1)
mime-types (1.19)
pry (0.9.10)
rest-client (1.6.7)
slop (3.3.3)

I’ll investigate further tonight. Probably a path issue.

Is it correct that it requires rest_client but the gem name is rest-client?

Yes, that’s correct. Let me know what you find.

I used

brew install ruby

to install the latest ruby version, set the path to match that, then ran

sudo gem install rest-client

and it works! Will give it a go in the coming days.

I downloaded it and when I try to open it I just get a lot of script. What am I supposed to do?

@steve
You are supposed to have the Ruby interpreter in the first place: Download Ruby

Steve: Thanks for checking out my script! I was about to post a screencast of how the app works and a detailed explanation tonight as a response to the youtube video you just released a few days ago (I forget the title, but it was posted on twitter and you talked about how you should always value listening over speaking). It’s a little bit complicated to get up and running for those unfamiliar with Ruby, but I have been using it for the past 2 days and really prefer it over flashcards.

Anyway, Eugrus is correct, the script requires you to have the Ruby interpreter installed on your machine.
After that, type this into the terminal:

sudo gem install rest-client
sudo gem install json
sudo gem install pry

THEN go into the folder where the script is saved and type:

ruby _NAME_OF_THE_FILE.rb (you should save the script as a .rb)

Let me know if you have any other issues.

Steve: Thanks for checking out my script! I was about to post a screencast of how the app works and a detailed explanation tonight as a response to the youtube video you just released a few days ago (I forget the title, but it was posted on twitter and you talked about how you should always value listening over speaking). It’s a little bit complicated to get up and running for those unfamiliar with Ruby, but I have been using it for the past 2 days and really prefer it over flashcards.

Anyway, Eugrus is correct, the script requires you to have the Ruby interpreter installed on your machine.
After that, type this into the terminal:

sudo gem install rest-client
sudo gem install json
sudo gem install pry

THEN go into the folder where the script is saved and type:

ruby _NAME_OF_THE_FILE.rb (you should save the script as a .rb)

Let me know if you have any other issues.

@Steve : Just uploaded the video to youtube. Comments welcome. This is an idea I would love to see implemented or collaborated upon through open source.

hmm…
What is my problem?
Is this script OS X dependent?

C:\Ruby193\bin>ruby “C:\Users\eugrus\Downloads\gist4169502-f49051d68790db5138d91
df64daa02b184644680\gist4169502-f49051d68790db5138d91df64daa02b184644680\eartrai
ner.rb”
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- rest_client (LoadError) from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:i n require’
from C:/Users/eugrus/Downloads/gist4169502-f49051d68790db5138d91df64daa0
2b184644680/gist4169502-f49051d68790db5138d91df64daa02b184644680/eartrainer.rb:1
:in `’

The text to speech part is osx only I think, but eugrus, your errors are like mine above - you need to install the rest-client gem.

@rickc Thanks for the great video. If you have an ios or android device, have a look at the Book2 app for one take on audio flashcards.

@rick1987 - Thanks for creating this neat little tool. I’ve shared the video on our LingQ Facebook page and hope that you continue to develop this idea. :slight_smile:

BYKI and Declan Software have iOs versions of audio flash cards. ‘Notes in Spanish’ has audio flash cards, too, but I don’t think they have a version for hand-helds. None is free, though each has a free demo of sorts. Don’t forget LingQ’s own Dictation exercise in the Vocabulary section.

However, none of these apps or applets encompasses the breadth of your notion. If I understand you correctly, Rick, you envision an all-audio LingQ. That would indeed be a very useful application to have.