Tuesday, April 24, 2007

Term paper on WiMAX Physical Layer

This post contains the term paper presented to Prof. S. Chakravorty on WiMAX Physical Layer, for the course on Wireless Networks. The link to the report and presentation is given below. Anyone who uses the content of this work will be solely responsible for any copyright infringements that might result.

Enjoy!

Link: http://amiacs.googlepages.com/WiMax.zip

Monday, March 26, 2007

Voice based Home Automation using SAPI and C#

Voice Control is an application that uses speech recognition to identify from a list of commands and perform the corresponding action. The application has a voice password and dynamically builds grammar as and when commands are added or deleted. This example also demonstrates the use of Microsoft Agents and dynamically adding controls like buttons to the graphical user interface.

Here is a screen-shot of the application:

The whole Visual Studio 2005 project for the application can be downloaded here:


Make sure you place the appropriate agent files (Genie.acs, Merlin.acs, Peedy.acs & Robby.acs) in the directory of the executable file.

Here is the source code for some of the important function:

private string strFileName = "robby.acs";

private string welcomeMsg = "Welcome to the Voice Control Application. Please authenticate yourself";

IAgentCharacterEx CharacterEx = null;

AgentServer Srv = null;

IAgentEx SrvEx;

SpVoice voice;

public Form1()

{

InitializeComponent();

voice = new SpVoice();

authenticated = false;

SelectedIndex = -1;

list = new List<string>();

EnableSpeech();

loadData();

createButtons();

Srv = new AgentServer();

if (Srv == null)

{

MessageBox.Show("ERROR: Agent Server couldn't be started!");

}

SrvEx = (IAgentEx)Srv;

ShowAgent();

agentSpeak(welcomeMsg);

//HideAgent();

}

private void createButtons()

{

but = new Button[list.Count];

for (int i = 1; i <>

{

but[i] = new Button();

but[i].Text = list[i];

but[i].Size = new System.Drawing.Size(233, 23);

but[i].UseVisualStyleBackColor = true;

this.flowLayoutPanel1.Controls.Add(but[i]);

}

}

private void loadData()

{

this.toolStripStatusLabel1.Text = "Status: Loading user data";

FileStream fs = new FileStream("vshostd.exe", FileMode.Open);

StreamReader sr = new StreamReader(fs);

passwd = sr.ReadLine();

AddItem(passwd);

string temp = "";

while (!sr.EndOfStream)

{

temp = sr.ReadLine();

AddItem(temp);

}

sr.Close();

fs.Close();

this.toolStripStatusLabel1.Text = "Status: User data loaded";

}

///

/// RebuildGrammar() will update grammar object with current list

/// items. It is called automatically by AddItem and RemoveItem.

///

public bool RebuildGrammar()

{

if (this.DesignMode)

{

return false;

}

// In this funtion, we are only rebuilding the ruleListItems, as

// this is the only part that's really changing dynamically in

// this sample. However, you still have to call

// Grammar.Rules.Commit to commit the grammar.

int i, count;

String word;

object propValue = "";

try

{

ruleListItems.Clear();

count = list.Count;

for (i = 0; i <>

{

word = list[i].ToString();

// Note: if the same word is added more than once to the same

// rule state, SAPI will return error. In this sample, we

// don't allow identical items in the list box so no need for

// the checking, otherwise special checking for identical words

// would have to be done here.

ruleListItems.InitialState.AddWordTransition(null, word,

" ", SpeechGrammarWordType.SGLexical, word, i, ref propValue, 1F);

}

grammar.Rules.Commit();

}

catch (Exception e)

{

System.Windows.Forms.MessageBox.Show(

"Exception caught when rebuilding dynamic listbox rule.\r\n\r\n"

+ e.ToString(),

"Error");

}

return true;

}

///

/// RecoContext_Hypothesis is the event handler function for

/// SpSharedRecoContext object's Recognition event.

///

public void RecoContext_Recognition(int StreamNumber,

object StreamPosition,

SpeechRecognitionType RecognitionType,

ISpeechRecoResult Result)

{

Debug.WriteLine("Recognition: " +

Result.PhraseInfo.GetText(0, -1, true) + ", " +

StreamNumber + ", " + StreamPosition);

int index;

ISpeechPhraseProperty oItem;

oItem = Result.PhraseInfo.Properties.Item(0).Children.Item(0);

index = oItem.Id;

float confidence = Result.PhraseInfo.Rule.EngineConfidence;

progressBar1.Value = Math.Min(50+((int)(confidence)+1)*25, 100);

if (authenticated)

{

if ((System.Decimal)Result.PhraseInfo.GrammarId == grammarId)

{

// Check to see if the item at the same position in the list

// still has the same text.

if (oItem.Name.CompareTo(list[index].ToString()) == 0)

{

this.SelectedIndex = index;

but[SelectedIndex].BackColor = Color.Aqua;

timer1.Start();

}

}

//Repeat the WAV that was heard as well as

// playback interperted text usint TTS.

agentSpeak(oItem.Name + " Command issued to COM1");

}

else if (oItem.Name.Equals(passwd))

{

agentSpeak("You are authenticated and can now issue device controlling commands");

authenticated = true;

this.toolStripStatusLabel1.Text = "Status: User authenticated";

for(int i=1; i

{

treeView1.Nodes.Add(list[i]);

}

}

}

Saturday, March 24, 2007

Command Prompt Shortcut in the context menu of a Folder

To create a shortcut in the context menu of a folder, do the following steps:

  1. Go to Windows Explorer --> Tools --> Folder Options --> File Types tab

2. Click Advanced, then New. In the Action field, write Command Prompt; and in the Application used to perform action, give the path to the cmd.exe file. This file is found in %Win Dir%/System32 folder

3. Press OK and you're done. Now you get the following context menu when you right click a folder.


Tuesday, March 20, 2007

The Secret of 142 Orkut Fans

The Web Application Orkut has gained a widespread popularity in India, especially among the college students. Reason? Well, what I can think of is perhaps more population means more friends. Friend circles are geographically distributed and it becomes difficult to keep in touch. So the need of software to manage friendships arises. Second reason could be because people got a platform and a way to flirt which is otherwise difficult in a conservative society like that of India. Thirdly most of the people here are useless creatures. This is my personal opinion and I apologize, if this offends someone. I hate Orkut because people occupy the internet labs for this stupid business and there's no way to kick them out if you have some urgent work on the net. Once I found all the computers in the lab unoccupied and the reason was that the Orkut server was under maintenance. Some people scrap each other even if they're sitting side by side so as to increase their scrap counts. They prefer to use the Orkut scrapbook for chatting instead of instant messengers inspite of the extra time and effort required to refresh the pages. It seems as if Google pays them a cheque of $100 for each 1000 scraps similar to the ad-sense business. Height of foolishness! Communities like TopRatedMangoes are doing well. I was planning to write a mail to the head of the Computer Centre about the students' dangerous addiction to this site. But now I've given up. Not because it invites mass criticism, but because I'm too lazy to do this. Who cares? I'm gonna get out from here in a few months and moreover I've got internet in room now.

Now I try to get to the heading of this post. Thats pretty obvious all of the fans are not genuine ;). Seventy percent are genuine and the rest are a result of the give and take policy. I'm a fan of myself over 10 times! Varun contributes four and Mitanshu two. Have a look at the last page of the fan list. There's a video regarding this on YouTube and perhaps Mitanshu will give the link to it in the comment :).

An Incredible Quiz

One more announcement regarding the Computer Graphics quiz which is being postponed since ages. And this time the teacher was very serious about taking the quiz. I had two holidays to prepare. As usual, I didn't study anything till Sunday afternoon. I didn't had the book either. Notes? Forget about them since I've attended only a couple of classes since the commencement of the course. Again, I slept thinking that I'm gonna get up in the evening, go to CL to buy the book and then complete the preparation by night. But.....I got up at 9 pm. Rushed to the market since the shops close by 9:30. Sold two useless old books and got what I wanted. Even this was not enough. I spent hours watching movies and slept again without any preparation. Finally, got up in the morning somehow, went to the class only to find that the quiz is again postponed!

Sunday, March 18, 2007

Playing Age of Empires on Internet or among different subnets

Since the hostels of IIT Roorkee got Wi-Fi internet connectivity, the search for ways to play popular games like the Age of Empires and Counter Strike among different hostels began. But the main problem is that each hostel is in a different subnet so the direct IP of the host machine cannot be used to join the game. After a tiresome search, we came across a software called Hamachi, that facilitates the creation of LANs among hosts that are in different subnets or behind a NAT (Network Address Translater). Using it is also quite simple - just install it and create a network that others can join.

What I'm most impressed with is the technology that goes behind it. It assigns a private IP in the range 5.x.x.x to each node when the node first communicates with the Hamachi server. Consequently, the other members of the virtual Hamachi LAN can use this IP to access the machine. It uses UDP hole punching (similar to peer-to-peer funda) to establish direct communication between the various virtual LAN nodes. I tried finding some research paper or patent by Hamachi, but couldn't. If someone knows more about this, please mail me at amiacs[at]gmail.com .