Tuesday, December 29, 2009

Talking Twitter client

So I learnt this afternoon about this Linux utility called festival. It's a text to speech conversion program. Running it is as simple as

echo "Hello world" | festival --tts

Moreover, installing it on Fedora is as easy as

sudo yum install -y festival

After that, a bit of a bash and a bit of a python and I had a twit-to-speech utility running.

The code is simply this much:

#!/bin/bash

TWITTERURL="http://twitter.com/statuses/friends_timeline.json"
JSON="/tmp/twittline.json"
SPEECH="/tmp/twt.message"
PYCODE="/tmp/twt2speech.py"

read -p "Username: " TUSER && \
read -sp "Password: " TPASS && \
curl -s -u $TUSER:$TPASS $TWITTERURL > $JSON

cat > $PYCODE << "EOF"
import json
import sys
import re
urlp="(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"
twits = json.load(open(sys.argv[1]))
for twit in twits:
    text = twit['user']['name']+' says: '+twit['text']
    text = re.sub(urlp, '', text) 
    print text
EOF

python $PYCODE $JSON > $SPEECH

while read line
do
notify-send -t 15000 "$line"
echo $line | festival --tts
sleep 1
done < $SPEECH

echo "THE END" | festival --tts

code syntax highlighting by GVIM

The above script will ask your twitter credentials, fetch latest 20 twits in friends' timeline, save into a JSON file. A short python script parses the JSON, extracts twit text and user's name from it and outputs in a sanitized format (it removes URLs, because there is no use hearing them).

The sanitized output is  saved in another text file, which is piped one line at a time to festival. In case the speech is not clear, it also shows the text in a pop-up using notify-send.

A full script with some error checking can be found here.

Saturday, December 26, 2009

ReaderScope 1.5 - quicker, better, prettier

ReaderScope 1.5 is ready for the holidays. With the latest improvements it gives the best Google Reader experience out there for your Android phone.

ReaderScope now uses non-blocking UI and the items are now loaded progressively. What does that mean? See it yourself.



As you know, the app is free in various markets. The themes (including the 'Santa' theme in above video) are part of a Theme Pack, which can be purchased for a ONLY $2.49 $3.49

Big thanks to the beta testers who helped testing the unstable 1.5 builds for over a week. Thank you guys!

Also if you like ReaderScope, vote for it at Android Arcade Facebook app.

Tuesday, December 15, 2009

Preview android.R.drawable.* images

This morning I was going through the Android SDK docs- specifically android.R.drawable class, to find out what stock icons android has that I can use in my project. Android has lot of icons in this class and one is encouraged to use stock icons whenever possible.

However I couldn't find any way to see how these icons look like. Their names are supposed to tell something about them, but they are vaguely descriptive at best. So I asked around on stackoverflow for help. I got a helpful link, but it is still a subset of all the drawables.

After a bit of thinking, I figured java reflection can help here and I put some code together. I ended up with a simple app which lists all the icons alongside their names. So now when you want to check out how a particular android.R.drawable.* looks like just scroll through this list.


Get the tarball and the apk. For the basic code snippet, check out my reply on stackoverflow.

Ads:
Professional Android 2 Application Development
The Busy Coder's Guide to Advanced Android Development
Unlocking Android: A Developer's Guide

Sunday, December 13, 2009

on Music: Battle Studies

Past couple of weeks I have been listening to John Mayer's (@johncmayer) latest album - Battle Studies. I am huge fan of JM music. His last album Continuum became my favorite when I listened to it non-stop for three days on a cross country road trip. (You can hear those songs in background in these trip videos).

I love the lyrics among all things. They have deeper meanings which you only understand after listening to them over long period of times. Maybe those meanings are not intentional, maybe we form our own meanings depending on the context or situation we hear them in. I believe that's the sign of true art. A true artwork does not convey a single full baked meaning. Instead, it provokes the audiences' mind to derive their own meanings.



I loved the "Who Says" video at first. Then when I got hold of the entire album, I found other gems like "Heartbreak Warfare" and "All we ever do is say goodbye".



I was more thrilled when I found a collection of JM's guitar tabs from all his albums at ultimate-guitar. I never knew such thing existed. Although, I have never played Guitar, but always hoped to learn it one day, this collection of tabs looked like a solid incentive to work on that plan. If you are serious about Guitar, these youtube videos are also a great source for inspiration and guidance.






So if you are looking for music recommendations, try JM.

Friday, December 11, 2009

ReaderScope 1.4 (with a Theme Pack)

Yes, now you don't have to stare at the black and khaki interface of ReaderScope. With 1.4, ReaderScope adds a theme pack. Right now it comes with three themes which look far more pleasant than the legacy color scheme. Also the Theme Pack is the first premium add-on to ReaderScope. You can buy it for only $3.49, from here. You can see the preview in the Theme switcher, just go to Settings -> Themes.



In future more themes will be added to the theme pack and you can get access to all of them, for just $3.49.

Go on, give it a try.