May 26 2008

Trying speech recognition in Windows Vista

Category: fossmo @ 18:43

Some months ago, I read that Scott Hanselman was using speech recognition in Windows Vista. He was very pleased with the speech recognition, so I tought it was time for me to try this new feature. I have been running Windows XP until now, but after service pack 1 for Windows Vista was released, I decided to try it out.  I am very pleased with this new OS (at least new to me). It is fast, looks nice, and it seems to me that it's very stable.

To day when I was at this big warehouse called Jula to buy a lawn mower, I saw this cheap microphone. So, I bought it. When I came home, I hooked it up to my computer and started two write this post using speech recognition. I think it works perfect, well almost perfect. It has some problems with some letters and some words.  Something the computer finds difficult to understand, is the letter 'V'.  I haven't yet accomplished to get it to understand it. It might, of course, have something to do with my bad English pronunciation.

I first tried it without running the tutorial and the speech training you are supposed to run before using it.  It didn't accomplish to understand many of the words that I was saying, but after running the tutorial it nearly never misses a word.  It is also constantly learning, so it gets better for every word I say.  Two get the best results, I have to speak slow, and in a monotone voice.  A recommend that you try it out.  I think it's available in Windows Vista Home Premium and above.

This feature, I think, is very valuable to people with handicaps.  I can manage my whole computer only using my voice.  If they continued to improve this technology, I guess in few years there will be no need for a keyboard.

image

Tags:

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

May 19 2008

What's your Circle of Interest?

Category: Miscellaneous | Thoughtsfossmo @ 23:47

There's a lot of bloggers posting about something called the Circle of Interest. I was encouraged by Gøran Hansen to post my Circle of Interest. The main idea of setting up this circle, is to show what you are focusing on at the moment. Circle of Interest was started by Paul Stovell. Other people I know posting on this is Jonas Follesø.

Gøran has a good description on what a Circle of interest is over at his blog.

 

image

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

May 17 2008

New exciting podcast

Category: Podcastfossmo @ 23:22

I listen to a lot of podcasts. Some days ago a new podcast was made public; Alt.NET Podcast. The first episode is very good, and I hope they manage to follow up on it in podcasts to come.  And, by the way, Alt.NET means alternative tools and approaches to mainstream .NET.

image

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

May 4 2008

How lambda expressions can replace anonymous methods

Category: C#fossmo @ 23:45

In this blog post I will introduced the syntax of a lambda expression and how it can replace anonymous methods. I will not go into what expression trees are, though it has some very cool features.

So what is a lambda expression?
A lambda expression is an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types.

Lambda expression comes from the world of the lambda calculus:
In mathematical logic and computer science, lambda calculus, is a formal system designed to investigate function definition, function application and recursion. (source: Wikipedia)

A lambda operator is used in a lambda expression.
It is written like "=>" and is read as "goes to". It should not be confused with comparison operators such as <= and >=.
The left side of the lambda operator specifies the input parameter and the right side holds the expression of statement block.

Lambda expressions was introduced to the .NET community in .NET 3.5.

Two different lambda expressions
There are two kinds of lambda expressions. A lambda expression with an expression on the right side is called an expression lambda.
The second kind is a statement lambda, which looks similar to an expression lambda except that its right part consists of any number of statements enclosed in curly braces. 

Expression lambda
Expression lambda can be written as follows:

x => x + 1

It is read as "x goes to x plus 1".

Statement lambda
A statement lambda resembles an expression lambda except that the statement is enclosed in braces.

() => { statement };

Example code using statement lambda:

    class Program
    {
        delegate void WriteText();
        static void Main(string[] args)
        {
            WriteText wt = () => { Console.WriteLine("Text inside a statement lambda!"); };
            wt.Invoke();
            Console.ReadKey();
        }
    }


It is also possible to include multiple statements inside a statement block.

Many functional programming languages such as Lisp use lambda notations to define functions. In addition to allowing the expression of LINQ queries,
the introduction of lambda expressions into C# and VB.NET can be seen as a step toward functional languages.

Following are code examples of how you can use lambda expressions:

"The old way"
What this snippet does, is to output the first number bigger than three. It uses a named method called "FindNumberBiggerThanThree" to sort the numbers.

    class Program
    {
        static void Main(string[] args)
        {
            List<int> numbers = new List<int>() { 1, 2, 3, 4, 5 };
            int result = numbers.Find(FindNumberBiggerThanThree);
            Console.WriteLine(result.ToString());
            Console.ReadKey();
        }
        static bool FindNumberBiggerThanThree(int x)
        {
            return x > 3;
        }
    }


Using Anonymous methods

.NET 2.0 introduced a new construct; anonymous methods.
Instead of declaring a named method in your class and then referencing the method by name you can do this by creating a delegate:

    class Program
    {
        static void Main(string[] args)
        {
            List<int> numbers = new List<int>() { 1, 2, 3, 4, 5 };
            int result = numbers.Find(delegate(int x) { return x > 3; });
            Console.WriteLine(result.ToString());
            Console.ReadKey();    
        }
    }


The advantage of using anonymous methods, over named methods, is that you can reference local variables in the "outer" method from within the anonymous method.
You don't have to clutter up your class with private methods that are only used once in order to pass some custom code to a method.

Using lambda expressions
The previous example with anonymous methods, is easy to read and understand, but it can be done better:

    class Program
    {
        static void Main(string[] args)
        {
            List<int> numbers = new List<int>() { 1, 2, 3, 4, 5 };
            int result = numbers.Find(x => x > 3);
            Console.WriteLine(result.ToString());
            Console.ReadKey();
        }
    }


In this example lambda expression is used. Compared to the example using the delegate keyword, lambda expressions simplifies the code a bit.

When to use lambda expressions
Whenever you need to pass some custom code to a method, lambda expressions are very useful.
The easy and readable syntax of lambda expressions also encourages the use of them.

I was introduced to lambda expressions thru mock-you (Moq is cool!) mocking framework and LINQ. I really like the syntax, and call on others to take a better look at what Lambda can do for them.

Tags:

Currently rated 4.0 by 2 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

May 2 2008

My presentation at NNUG

Category: Presentationfossmo @ 16:15

24. April I held a short presentation about Code Metrics in Visual Studio 2008. Here are the slides from the presentation.

CodeMetrics.ppt (849.50 kb)

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5