Thursday, December 24, 2009

How to Use TextToSpeech Feature of Google

Here is how you can make your own TextToSpeech App, using Google's un-documented API.

Google Has an undocumented REST API to get TextToSpeech

http://translate.google.com/translate_tts?q=your+text+goes+here
Here is the HTML Code. Do not miss to see the screen-cast.

<html>
<head>
<title>
Text To Speech Demo
</title>
<script>
function GetSpeech()
{
var framehtml="<iframe src=\"http://translate.google.com/translate_tts?q=";
framehtml+=escape(document.getElementById("mytext").value);
framehtml+="\" </iframe>";

document.getElementById("myframe").innerHTML=framehtml;
/*we are done!!!!!*/
/* we will test now*/
/*wow!!!!! its working :) */

}
</script>
</head>
<body>
Enter your text Here
<textarea id="mytext">
</textarea>
<button id="mybutton" onclick="GetSpeech();">
Click me to get the text
</button>
<div id="myframe">
</div>
</body>
</html>

Here is a screen-cast


Thanks Guys
Happy Christmas

Sunday, December 20, 2009

Jump into 3D maps by calculating orientation

Lets make a VirtualDrive MashUp today. As you know that Google maps API has Street view feature and Live maps has Bird’s Eye view feature. We will mix these 2 things in our mash-up.
Feature of This MashUp will be
  • To Take input as source and destination address.
  • Animate the street view & Bird’s Eye from source to destination.
To get this done you will need direction API to know the path between source and Destination. Eventually Google’s Direction API will do this for us. Direction API returns a PolyLine from source to destination. We will use GDirections.getPolyline() Function. Once you have all the points (Latitude and Longitude) along the path you are all set to go. But wait street-view and Bird’s Eye view are 3D Maps they also have something called orientation .
Bird’sEye View requires only one extra parameter "orientation" which can be
  • North
  • East
  • South or
  • West
Where as Google Street View is more complicated , its requires Yaw and Pitch (i am ignoring zoom level which applies to all kind of maps)
image
Since we will concentrate on driving , we will keep the pitch horizontal i.e. pitch will be zero.
Yaw can be calculated by using 2 points along the path. Yaw is the angle of your driving direction from North, in degrees.
Here is a JavaScript code to calculate Yaw with given 2 values of GLatLng.
(Note that Yaw & Bearing is closely related terms and they are having same value here.)
function GetBearing(GLatLng1, GLatLng2) {

var lat1 = GLatLng1.lat();
var lon1 = GLatLng1.lng();
var lat2 = GLatLng2.lat();
var lon2 = GLatLng2.lng();
lat1 = lat1.toRad();
lat2 = lat2.toRad();
var dLon = (lon2 - lon1).toRad();

var y = Math.sin(dLon) * Math.cos(lat2);
var x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon);
return Math.atan2(y, x).toBrng();
}
One feedback about street-view API though, function setLocationAndPOV is very mysterious and I could not make it work.
Individual Code snippets I picked from here
  1. Google AJAX Playground
  2. Live Map APIs Sample
  3. movable-type
Now Jump To Demo

And Do ViewSource to see the code.

Saturday, November 21, 2009

Google's "Chrome OS" is Bad Evolution

I am a computer engineer. I will always love to see computing evolving in right direction.
Google Chrome OS is bad for evolution of computing.

Computing evolved with Desktop computing and then web apps. Browser Based apps are always slow and faulty, they can never be as robust as a desktop application can be.

After The invention of web services and REST API, I would love to see web enabled desktop Apps.

I love the concept of Portable Apps , When we mix concept of portable Apps and Cloud Based storage, we can achieve much better results.  BUT Google will never let it happen, they are re-inventing all those age old things again in browser. I have posted a small video response on you tube.

Here it is.

Wednesday, November 11, 2009

Phonetic Translation For Hindi

Hello!! I am an Indian, and for obvious reasons I have many friends on twitter who are also Indian and  we communicate in Hindi very often. Wait!! We don't type Hindi on twitter, because Hindi typing requires a special keyboard (or at least special Input Method), which we typically don't keep with us. Its because we Indian officially work in English Language.

So if you are a foreigner and You see this phonetically typed Hindi, No way you can get it translated to your own language.

So For you I have created a small JavaScript hack so that you can translate Phonetic Hindi into your own language.

This is not for only who are foreigners, If you are Indian & still you have problem in understanding Hindi, here is Tool for you.

Demo

How to develop on your own??

This is a Mashup. I am using 3 different service.

1.Script Convertor

2.Google Translate API

3.YQL (a very useful platform for creating mashup)

To see the source code open the demo page and view source.

I have written only few lines of  of JavaScript to do this.

Sunday, November 8, 2009

Coding Bullshit Meter (Outlook Addin)

I thought this will be fun. We developers often get some mail from corporate management, which are completely bullshit to us. How much bullshit it has?? Lets calculate? To calculate I have created a small outlook Add-in (plug-in) which will Display the bullshit percentage on the ToolBar when you select the mail item.


Some of the keywords its uses to calculate the bullshit is this


synergy,strategic fit,gap analysis,revisit,bandwidth,best practice,bottom line,hardball,out of the loop,benchmark,value added,proactive,win-win,think outside the box,fast track,result driven,empower,knowledge base,total quality,quality driven,touch base,mindset,client focus

This is the first time i am developing any kind of Add-In for any application. I used Visual Studio 2010 (beta) 2010 for developing.

You will get many problems,  when you will develop an outlook plug-in. One of the biggest problem I faced was that "Event of 'Item selection change' was not firing".
this.Application.ActiveExplorer().SelectionChange
I finally come to know that you need to keep a reference of the ActiveExplorer all the time in the class.

Ok, this trick worked!!!

Download Source Code Here

I am not creating installer for this (or any kind of set-up). If at all you want to use this, please download the source code and compile on your machine. You might need Visual studio 2010 for this.