Archive for December, 2010


Chơi AOE – Bạn có biết ?

Trong 1 trận đấu AOE, có rất nhiều tình huống khác nhau cần xử lý, nên đôi khi các bạn ko thể để ý đến những chi tiết nhỏ nhặt mà chỉ có thể phán đoán dựa vào cảm tính. Tuy nhiên, đôi khi những chi tiết này ko chỉ giúp bạn hiểu thêm về AOE, mà nó có thể mang lại cho bạn những lợi thế ko nhỏ trong trận đấu nếu bạn biết tận dụng.

1 – Dân Pal làm ruộng ko nhanh hơn các dân khác

Ai cũng nghĩ rằng dân Pal đắt hơn, làm hươu, gỗ, thịt, vàng… nhanh hơn các dân khác (VD: dân Greek chặt 10 gỗ hết 20s, dân Pal hết 15s), đương nhiên dân Pal khi làm ruộng cũng nhanh hơn. Trên thực tế, dân Pal, cũng như mọi dân khác, để làm được 10 thịt mất khoảng 20s (trong máy). Dân Pal chỉ thực sự lợi hơn dân khác khi làm 2 dân 1 ruộng.

AoE0099

Kết quả từ thực tế:

Dân thường 2 dân 2 ruộng: 210 thịt trong 4′.
Dân thường 2 dân 1 ruộng: 110 thịt trong 4′.
Dân Pal 2 dân 2 ruộng: 210 thịt trong 4′.
Dân Pal 2 dân 1 ruộng: 160 thịt trong 4′.
2 – Giáp của dân Pal

Dân Pal có 1 giáp, nhìn là thấy ngay. Nhưng cũng chỉ vì “nhìn là thấy” cái giáp đó, nên nhiều người ngay lập tức nghĩ rằng đấy là giáp cận chiến (chỉ có tác dụng với quân chém). Hiếm người để ý rằng: giáp nay có cả công dụng của giáp cận chiến và giáp bắn tên (VD: quẩy 2+1 bắn dân Pal chỉ mất 2 máu).

4
3 – Lợi thế Free tribute của Palmyran

Vâng, lại là Pamyran. Phần Help trong AOE có ghi rõ ràng: Palmyran có thể cho đồng minh mà ko mất thêm 25% tài nguyên dù ko cần nâng cấp đào vàng lần 2 như những quân khác. Tuy nhiên, một điều ít người biết: ngay cả khi để full, nếu bạn chọn Palmyran thì cũng ko mất đi lợi thế Free tribute đó.

AoE0100
4 – Những lợi ích của việc nâng cấp đào vàng lần 2

Đơn giản thôi: Dân sẽ mang về 16 vàng mỗi lần trong thời gian khoảng 17s (vừa đào nhanh hơn, vừa mang về nhiều hơn) và ko mất thêm 25% tài nguyên khi cho đồng minh.

Ngoài ra, còn 1 điều khó tin, nhưng có thật và rất quan trọng: sau khi nâng cấp đào vàng lần 2, khi dân mang về 16 vàng thì mỏ vàng chỉ mất đi 13 vàng. Điều đó có nghĩa là với cùng 1 mỏ vàng, bạn có thể đào được nhiều hơn so với khi ko nâng cấp đào vàng lần 2, thậm chí nhiều hơn cả số vàng của mỏ đó.

2

Garena Việt Nam – Theo Blood AOEVN

Hướng dẫn cách đánh cung Assyrian trong AOE

Giải cung R đã qua, nhưng những dư âm của nó để lại vẫn còn đọng lại. Phong cách đánh R Assyrian đã được nhiều người chú ý đến hơn. Tuy nhiên chưa hẳn tất cả đã biết cách chơi cung R, bài viết sau đây sẽ cho bạn cái nhìn khái quát về  cách đánh Assyrian.

1
Cách đánh Assyrian
1. Lên đời và bố trí nhà:

Với Assyrian, việc lên đời không quá khó khăn vì dân Assyrian chạy rất nhanh, nên khá dễ để cân đối thực gỗ. Với tầm 26-28 dân có thể dễ dàng kick đời 3 ở phút thứ 10 – 11.

Những cao thủ lên đời thường lên với 25-28 dân, xây được 3BS và tầm 6-8 ruộng trước khi lên đời xong. Với số ruộng và BS như thế sẽ đảm bảo được khả năng sinh quân đều trong 5 nhà A. Cách phát triển với 3 BS và đóng ruộng thật sự thình hành và phát triển sau các đợt giao lưu Assyrian với Trung Quốc.

Cần chú ý là xây nhà A trên dốc sẽ tiện việc thủ, có dốc trước mặt nhà A là tốt nhất. Nếu xây dưới dốc thì khi địch tấn công sẽ gặp rất nhiều bất lợi, rất dễ bị ốp nhà A dẫn đến thất bại. Cũng tránh việc xây nhà A có dốc đằng sau, sau này nếu bị ốp A sẽ rất khó thủ vì lui quân về sẽ xuống dốc.

2
Xây nhà trên dốc sẽ dễ dàng phòng thủ.
2. Tấn công:
Bạn là người thích phong cách đánh công, bạn thích đè bẹp đối phương thật nhanh chóng, ko cho họ có cơ hội bật, thích đối phương quit với 1 time khủng khiếp vậy thì bạn phải học cách công.

Tấn công vào kinh tế:

Bạn lên đời sớm hơn đối phương hãy chú ý ép thịt gỗ thật đều để sinh quân, đừng quá ham đẻ dân hay đắp quá nhiều ruộng (ảnh hưởng rất lớn đến việc ra quân đều). Khi  có quân hãy cho đi dò nhà họ ngay, chú ý turn quân đầu tiên đừng bao giờ nghĩ đến việc ốp BA, hãy đi sâu vào trong xem xét địa hình nhà đối phương, tìm dân làm ruộng của họ và quấy rối.

Có thể bắn chết được chú nào thì tốt nếu ko chỉ cần quấy họ là đủ, bắt buộc họ phải chạy dân. Vì đã chạy dân rồi, việc cho mỗi con dân làm việc 1 ruộng là rất mất thời gian nên việc quấy dân làm ruộng hiệu quả hơn rất nhiều so với quấy dân làm gỗ. Trường hợp quấy dân làm gỗ có khi còn bị họ quây dân đập, rất bất lợi

Khi họ đã có quân chống trả, phải biết giữ quân đừng ham 1 vài thằng dân mà để chết 4,5 con ngựa. Hãy chạy Turn ngựa đầu đi  và cho Turn ngựa thứ 2 đi quấy các mỏ gỗ, thực khác của đối phương. Cứ như thế sau 1 thời gian vài turn ngựa đối phương đã ko thể cân đối tài nguyên, ko thể xin quân đều, lúc đó hãy gộp ngựa lại và bắt đầu đấu quân, công BA.

Trường hợp bạn sang nhà đối phương đã thấy họ bo nhà kín, có quân chống trả , hay cho ngựa bắn những hàng Be họ xây gây chú ý cho địch thủ, rồi bất ngờ gộp 1 đạo ngựa lớn vào BA. Đảm bảo sẻ gây bất ngờ vì họ đã để 1 số lượng quân lớn vào thủ sau hàng BE mà bạn đang công.

3
Quấy rối mỏ ruộng, sẽ làm địch rối loạn

Tấn công vào quân sự:

Đối phương lên đời ngang ngửa mình và bo nhà rất kín, khi sang nhà họ cũng đã có cung. Vậy chỉ còn cách là đấu quân với đối phương.

Cách tấn công này đòi hỏi có khả năng điều quân cực tốt, vây bắt lấy R của địch tạo nên chênh lệch lực lượng giữa 2 quân và sau đó là tẩn công thẳng vào nhà A.

Cách bắt quân của địch rất đa dạng, có thể vây bắt từng đạo R nhỏ đi móc của địch bằng cách tạo nên những góc chết trong nhà hay là chặn ở các dốc đi từ nhà địch tới nhà mình (đứng trên dốc chờ, địch sơ ý sẽ thiệt hại quân). Hay cũng có thể lừa đạo cung R lớn của địch đi xa nhà (hoặc phát hiện đối phương mang hết R đi) rồi chiếm dốc ốp nhà A.

Có một phong cách tấn công rất đáng nói ở đây mà được rất nhiều cao thủ thế giới áp dụng. Cách tấn công này cần có khả năng điều R  và quản lý bản đồ tốt. Phong cách này thường lên đời với 27 28 dân dò rất rộng , lên đời xong không đẻ thêm dân hay xây ruộng, mà  đi ăn hoang để mua quân đều với 6 nhà A trong 4-5 turn đầu.

Với lượng dân ăn hoang sẽ có khả năng đẻ 6 nhà A đều cộng với khả năng điều R tốt sẽ ốp nhà A luôn. Với khả năng điều R tốt và lượng quân đông hơn, sẽ rất dễ dàng để vây hãm đối phương buộc đối phương phải quit hoặc là bỏ nhà. Nếu đối phương bỏ nhà thì với khả năng quản lý bản đồ tốt, sẽ rất khó để có thể phát triển lại.

Cách đánh này được Unbroken (cao thủ hang đầu của thế giới áp dụng rất nhiều). Cụ thể như trận Unbroken – Family, Family lên đời với 4 nhà A và đã nhanh chóng phải quit sau 3 turn R của Unbroken.

Video trận đấu Unbroken – Family: (Unbroken xanh 6)

unbroken

Một người có đầu óc sáng tạo sẽ có vô vàn cách công, có thể là kết hợp những cách trên hoặc có thể là một cách thức tấn công mới mà bạn chưa gặp bao giờ. Trên đây chỉ nêu ra những phong cách công thường thấy tại thời điểm hiện tại.

3. Phòng thủ

Phòng thủ có nghĩa là làm cho địch không thể tấn công mình được, về cả kinh tế lẫn quân sự. Nếu họ tấn công nhất định phải nhận lấy thiệt hại.

Thủ gặp công:

Cũng như bóng đá, có nhiều người thích công song cũng có rất nhiều người thích thủ. Một người tấn công giỏi cũng chưa chắc thắng được người thủ giỏi, vì công thường bao giờ cũng khó hơn thủ. Vì nếu lên đời bằng nhau thì đương nhiên lượng quân thủ nhiều hơn công (ít nhất là trong thời gian đầu).

Điều đầu tiên và quan trong nhất trong cách đánh thủ đó là bo nhà. Đầu tiên cần bo nhà kín những chỗ dễ bo, quan trong trước rồi dần dần mới bo những chỗ còn lại. Mỗi khi phát triển làm ăn ra khu vực mới cũng nên bo vào ngay tránh thiệt hại dân không đáng có. Cũng có nhiều người không bo kín nhà mình, và dành 1 lối vào cho quân địch vào lừa cho quân địch vào nhà và bắt sạch.

Xây ruộng: hãy xây ruộng gần kín ở khu vực nhà chính, BG( vì dân Assy chạy nhanh nên ko nhất thiết phải xây ruộng quá sát), đóng thêm 1 vài cái BE sao cho chỗ tiếp nối giữa ruộng và be, mép bản đồ là kín. Lúc quân đich bắn dân làm ruộng bạn chỉ cần cho quân đứng sau là bắt sach được cả đạo quân của họ. Tránh trường hợp quân địch vào có thể chạy vòng quanh mỏ ruộng rỉa dân.

4
Bo kín mỏ ruộng tránh quân địch quấy rối

Cần ước lượng số lượng quân đối phương tấn công để có thể điều  quân thủ hợp lý. Ví dụ như bạn thấy có 4 con ngựa địch vào nhà mình hãy cho 4,5 con ngựa đuổi theo hoặc thủ những chỗ có nông dân mà ngựa địch đi qua. Có rất nhiều người lấy 1 đạo ngựa ra đuổi 1 vài con ngựa, và rất dễ bị ốp nhà A như đã nói ở phần trên.

Bắt quân: Đừng bao giờ tập trung quân tại 1 chỗ quá đông, hãy phân tán quân ra các nơi trọng yếu lúc cần thiết sẻ rất dễ vây quân địch (ưu tiên canh các dốc quanh nhà). Khi địch tấn công sẽ ở thế dưới dốc hoặc các vị trí không thuận lợi, nếu địch quá ham tấn công tất nhiên sẽ nhận lấy thiệt hại nặng hơn.

5
Cho quân đứng thủ ở các vị trí thuận lợi
Khi đã thủ thành công tức là địch sẽ thiệt hại về quân sự, vì thủ cần ít quân hơn nên có thể phát triển kinh tế nhanh hơn. Khi đó sé có 2 lựa chọn đó là xây thêm nhiều nhà A mua quân vào bắt đầu chuyển sang tấn công đổi phương. Hoặc có thể thủ tiếp phát triển lên 4, với những nhà kín, địa thế đẹp thì việc dùng ít quân thủ rồi phát triển lên 4 rất hay được áp dụng.

Thủ gặp thủ:

Nếu đối phương không tấn công thì sao? Đương nhiên lúc đấy thì 2 bên thi nhau phát triển, thường những trận đấu như vậy rất nhàm chán và kéo dài. Nhưng cũng cần lưu ý những điều sau tránh những thất bại không đáng có:

Với việc đánh giằng co lâu dài, đừng bao giờ ham tấn công địch mà hãy dành thời gian bo nhà, đóng lại BS, đóng thêm BA, chiếm rừng, chiếm địa hình. Liên tục sinh quân cho đứng tụ lại những nơi hiểm yếu đồng thời phát triển nhảy 4.

Chú ý: Đừng bao giờ vác 1 kick ngựa vào nhà đối phương, thích đi móc thì chỉ cần vác 6,7 con đi là đủ, vác 1 kick vào nhà họ bị bắt mất thì coi như thua luôn.

6
Thủ lên 4 trong những trận giằng co

Lời kết: Lý thuyết là như vậy nhưng trong một trận đấu việc công hay thủ, cách đánh thế nào đều dựa vào rất nhiều yếu tố. Một cao thủ khi thi đấu luôn luôn biết kết hợp giữa công và thủ. Khi nào cần công,  khi nào cần thủ thì cần có tư duy tốt hoặc kinh nghiệm thi đấu nhiều mới có thể đúc rút ra được.

Garena Việt Nam

Lực tấn công được cộng thêm (bonus damge) tức là lượng sát thương được cộng vào ngoài sát thương chính của một đơn vị quân, khi cho một quân này đấu với một loại  quân khác.

Có lẽ ai chơi AoE đều biết lạc đà thắng ngựa C khi 1vs1 dù ít máu hơn (126 so với 150) và lực đánh yếu hơn (6 so với 8). Có người thì cho rằng lạc đà chém nhanh hơn, người khác lại cho rằng lạc đà chém vào đầu (từ trên xuống), còn ngựa C chém vào lưng (chém ngang) nên ngựa C sẽ nhanh chết hơn.

Tuy nhiên, cả hai cách giải thích trên đều ko đúng. Lạc đà có thể thắng ngựa C là do lạc đà được cộng 8 damage khi đánh ngựa C. Chuyện này xuất phát từ thực tế là con ngựa rất sợ mùi của lạc đà và thường tránh lại gần lạc đà.

1
Ngựa chém rất sợ  lạc đà

Để giúp mọi người rõ ràng hơn, sau đây tác giả sẽ đưa ra các trường hợp được cộng lực tấn công trong AOE:

Cộng lực đánh giữa các loại quân:
  • Lạc đà được cộng 8 damage khi đánh ngựa C chém và horse archer (C bắn), cộng 4 damage khi vs ngựa R (cả ngựa R sọc và ngựa R cung).
2
  • Ngựa C chém được cộng 5 damage khi vs lính Z và rìu chém.
3
  • Quẩy đá được cộng 2 damage khi vs tất cả các loại quân trong nhà cung BA. Ngoài ra, quẩy đá cũng được cộng damage khi công thành và chòi (ko biết chính xác).
4
Quẩy đá cũng có thể chiến thắng cung R
  • Ngựa R sọc và cung R khi vs phù thủy được cộng 7 damage. Cả hai loại ngựa này đều có khả năng chống hú rất tốt và thường được dùng để chống phù thủy.
5
Ngựa gỗ khắc tinh của phù thủy
Cộng lực đánh khi đứng trên dốc:
  • Đối với quân cung: các loại quân cung sẽ được cộng 50% sức tấn công khi đứng trên dốc. VD: ngựa R thường có lực bắn là 4, khi đứng trên dốc bắn xuống sẽ có lực tấn công là 6. Heavy horse archer (Horse thần) có lực tấn công là 8, đứng trên dốc sẽ thành 12.
6
Đứng trên dốc cộng 50% damge
  • Đối với quân cận chiến: quân đứng trên dốc sẽ ko được cộng lực tấn công mà quân đứng dưới dốc bị trừ 33% lực công. VD: voi húc có lực tấn công là 15, khi đứng dưới dốc đánh lên chỉ còn 10.
    7
    Quân cận chiến dưới dốc giàm 33% damge
    Garena Việt Nam – Theo AOEVN
    Multithreading is tough. This is what John Robbins says about it in his excellent book Debugging Microsoft .NET 2.0 Applications:

    “Don’t do it… Make sure there’s no other way you can structure your program before you decide to incorporate multithreading into your application… you are easily adding a minimum of an extra month of development and testing to your schedule”. I agree with it completely. But there are times multithreading is unavoidable. Especially when more and more Services popping up in the wild…

    From Asynchronous Pages in ASP.NET 2.0

    Customer Case Study

    I am working with the customer to improve their ASP.NET 2.0 application performance. The application issues multiple requests to the backend middleware that is exposed as a web service. The application cannot get a hold on the actual proxies rather it is provided with the components that wrap the web services proxies. The application needs to issue concurrent  requests. Serial request would result in serious latency which is unacceptable by end users.

    Analysis

    Since we cannot get hold on web services proxies we cannot utilize available asynchronous methods available with it: BeginMyMethod/EndMyMethod and MyMethodAsync/MyMethodCompleted. But we definitely can utilize another option available with ASP.NET 2.0 – registering asynchronous tasks using PageAsyncTask class.

    The following information is based on the following materials:

    PageAsyncTask Implementation Steps

    This is the summary of the steps to implement and register PageAsyncTask:

    • Create a class that contains lengthy operation
    • Declare AsyncTaskDelegate
    • Add OnBegin, OnEnd, OnTimeout methods to the class
    • Mark the calling page as Async=”true”
    • Register the PageAsyncTasks in the ASPX page and execute it

    You can grab the Visual Studio 2008 project with the implementation from my SkyDrive here:

    The Evolution of the Web Developer

    In the past, memory leaks haven’t posed huge problems for Web developers. Pages were kept relatively simple and navigation between different locations within a site was a great way to clean up any loose memory. If there was a leak, it was most likely small enough to go unnoticed.

    New Web applications live up to higher standards. A page might run for hours without being navigated and retrieve updated information dynamically through Web services. Language features are pushed to the breaking point by combining complex event schemes, object-oriented JScript, and closures to produce entire applications. With these and other changes, certain memory leak patterns are becoming more prominent, especially those previously hidden by navigation.

    The good news is that memory leak patterns can be easily spotted if you know what to look for. Most of the troublesome patterns you might face have known workarounds requiring only a small amount of extra work on your behalf. While some pages might still fall prey to small memory leaks, the most noticeable ones can be easily removed.

    Leak Patterns

    The following sections will discuss patterns of memory leaks and point out some common examples of each pattern. One great example of a pattern is the closure feature of JScript, while another example is the use of closures in hooking events. If you’re familiar with the event hooking example, you might be able to find and fix many of your memory leaks, but other closure-related issues might go unnoticed.

    Now, let’s look at the following patterns:

    1. Circular References—When mutual references are counted between Internet Explorer’s COM infrastructure and any scripting engine, objects can leak memory. This is the broadest pattern.
    2. Closures—Closures are a specific form of circular reference that pose the largest pattern to existing Web application architectures. Closures are easy to spot because they rely on a specific language keyword and can be searched for generically.
    3. Cross-Page Leaks—Cross-page leaks are often very small leaks of internal book-keeping objects as you move from site to site. We’ll examine the DOM Insertion Order issue, along with a workaround that shows how small changes to your code can prevent the creation of these book-keeping objects.
    4. Pseudo-Leaks—These aren’t really leaks, but can be extremely annoying if you don’t understand where your memory is going. We’ll examine the script element rewriting and how it appears to leak quite a bit of memory, when it is really performing as required.

    Circular References

    Circular references are the root of nearly every leak. Normally, script engines handle circular references through their garbage collectors, but certain unknowns can prevent their heuristics from working properly. The unknown in the case of IE would be the status of any DOM elements that a portion of script has access to. The basic principle would be as follows:

    Figure 1 Basic Circular Reference Pattern

    Figure 1. Basic Circular Reference Pattern

    The cause of the leak in this pattern is based on COM reference counting. The script engine objects will hold a reference to the DOM element and will be waiting for any outstanding references to be removed before cleaning up and releasing the DOM element pointer. In our case we have two references on the script engine object: the script engine scope, and the DOM element expando property. While terminating the script engine will release the first reference, the DOM element reference will never be released because it is waiting on the script engine object to release it! You might think it would be easy to detect this scenario and fix the problem, but in practice the basic case presented is only the tip of the iceberg. You could have circular references at the end of a 30 object chain and those would be much harder to detect.

    If you are wondering what this pattern looks like in HTML, you can cause a leak by using a global script engine variable and a DOM element as shown.

    <html>
        <head>
            <script language="JScript">
    
            var myGlobalObject;
    
            function SetupLeak()
            {
                // First set up the script scope to element reference
                myGlobalObject =
                    document.getElementById("LeakedDiv");
    
                // Next set up the element to script scope reference
                document.getElementById("LeakedDiv").expandoProperty =
                    myGlobalObject;
            }
    
            function BreakLeak()
            {
                document.getElementById("LeakedDiv").expandoProperty =
                    null;
            }
            </script>
        </head>
    
        <body onload="SetupLeak()" onunload="BreakLeak()">
            <div id="LeakedDiv"></div>
        </body>
    </html>

    To break the leak pattern you can make use of explicit null assignments. By assigning null before the document unloads you are telling the script engine there is no longer an association between the element and the object inside the engine. It can now properly clean up references and will release the DOM element. In this case, you as the Web developer know more about the relationships between your objects than the script engine does.

    While that is the basic pattern, it can be difficult to spot more complex scenarios. A common usage of object-oriented JScript is to extend DOM elements by encapsulating them inside of a JScript object. During the construction process, you generally pass in the DOM element you want to attach to and then store a reference to the DOM element on the newly constructed object while at the same time storing an instance of the newly constructed object on the DOM element. That way your application model always has access to everything it needs. The problem is this is a very explicit circular reference, but because it uses different language aspects it might go unnoticed. Breaking up this kind of pattern can become more complex, and you can use the same simple methods discussed earlier.

    <html>
        <head>
            <script language="JScript">
    
            function Encapsulator(element)
            {
                // Set up our element
                this.elementReference = element;
    
                // Make our circular reference
                element.expandoProperty = this;
            }
    
            function SetupLeak()
            {
                // The leak happens all at once
                new Encapsulator(document.getElementById("LeakedDiv"));
            }
    
            function BreakLeak()
            {
                document.getElementById("LeakedDiv").expandoProperty =
                    null;
            }
            </script>
        </head>
    
        <body onload="SetupLeak()" onunload="BreakLeak()">
            <div id="LeakedDiv"></div>
        </body>
    </html>
    

    More complex solutions to this problem involve registration schemes to note which elements/properties need to be unhooked, having the peer element hook events so that it can clean up before the document unloads, but often you can run into additional leak patterns without actually fixing the problem.

    Closures

    Closures are very often responsible for leaks because they create circular references without the programmer being fully aware. It isn’t immediately obvious that parent function parameters and local variables will be frozen in time, referenced, and held until the closure itself is released. In fact this has become such a common programming tactic, and users have run into issues so often, there are quite a few resources already available. Because they detail some of the history behind closures as well as some of the specific instances of closure leaks we’ll check those out after applying the closure model to our circular reference diagram and figuring out where these extra references are coming from.

    Figure 2 Circular References with Closures

    Figure 2. Circular References with Closures

    With normal circular references there were two solid objects holding references to each other, but closures are different. Rather than make the references directly, they are made instead by importing information from their parent function’s scope. Normally, a function’s local variables and the parameters used when calling a function only exist for the lifetime of the function itself. With closures, these variables and parameters continue to have an outstanding reference as long as the closure is alive, and since closures can live beyond the lifetime of their parent function so can any of the locals and parameters in that function. In the example, Parameter 1 would normally be released as soon as the function call was over. Because we’ve added a closure, a second reference is made, and that second reference won’t be released until the closure is also released. If you happened to attach the closure to an event, then you would have to detach it from that event. If you happened to attach the closure to an expando then you would need to null that expando.

    Closures are also created per call, so calling this function twice will create two individual closures, each holding references to the parameters passed in each time. Because of this transparent nature it is really easy to leak closures. The following example provides the most basic of leaks using closures:

    <html>
        <head>
            <script language="JScript">
    
            function AttachEvents(element)
            {
                // This structure causes element to ref ClickEventHandler
                element.attachEvent("onclick", ClickEventHandler);
    
                function ClickEventHandler()
                {
                    // This closure refs element
                }
            }
    
            function SetupLeak()
            {
                // The leak happens all at once
                AttachEvents(document.getElementById("LeakedDiv"));
            }
    
            function BreakLeak()
            {
            }
            </script>
        </head\>
    
        <body onload="SetupLeak()" onunload="BreakLeak()">
            <div id="LeakedDiv"></div>
        </body>
    </html>

    If you are wondering how to break this leak, it won’t be as easy as a normal circular reference. The “closure” can be viewed as a temporary object that exists in the function scope. Once the function exits, you lose reference to the closure itself, so what would you end up calling detachEvent with? One of the most interesting approaches to this problem was demonstrated on MSN spaces thanks to Scott Isaacs. The approach uses a second closure to additionally hook the window’s onUnload event, and because this closure has the same “scoped” objects it is able to detach the event, detach itself, and finish the clean up process. To make everything easily fit with our model we can also store the closure on an expando, detach it, and then null the expando, as in the following example.

    <html>
        <head>
            <script language="JScript">
    
            function AttachEvents(element)
            {
                // In order to remove this we need to put
                // it somewhere. Creates another ref
                element.expandoClick = ClickEventHandler;
    
                // This structure causes element to ref ClickEventHandler
                element.attachEvent("onclick", element.expandoClick);
    
                function ClickEventHandler()
                {
                    // This closure refs element
                }
            }
    
            function SetupLeak()
            {
                // The leak happens all at once
                AttachEvents(document.getElementById("LeakedDiv"));
            }
    
            function BreakLeak()
            {
                document.getElementById("LeakedDiv").detachEvent("onclick",
                    document.getElementById("LeakedDiv").expandoClick);
                document.getElementById("LeakedDiv").expandoClick = null;
            }
            </script>
        </head>
    
        <body onload="SetupLeak()" onunload="BreakLeak()">
            <div id="LeakedDiv"></div>
        </body>
    </html>

    In a Knowledge Base article, we actually recommend that you try not to use closures unless they are necessary. In the example, I’ve given we don’t need to use a closure as the event handler, instead we can move the closure to a global scope. When the closure becomes a function, it no longer inherits the parameters or local variables from its parent function so we don’t have to worry about closure-based circular references at all. Most code can be fixed by creating an architecture that doesn’t rely on closures where they aren’t necessary.

    Finally, Eric Lippert, one of the developers of the scripting engines, has a great post on closures in general. His final recommendations are also along the lines of only using closures when truly necessary. While his article doesn’t mention any of the workarounds for the closure pattern, hopefully we’ve covered enough examples here to get you started.

    Cross-Page Leaks

    Leaks that are based on order of insertion are almost always caused by the creation of intermediate objects that don’t get cleaned up properly. That is exactly the case when creating dynamic elements and then attaching them to the DOM. The basic pattern is attaching two dynamically created objects together temporarily which creates a scope from the child to the parent element. Later, when you attach this two-element tree to the primary tree, they both inherit the scope of the document and a temporary object is leaked. The following diagram shows two methods for attaching dynamically created elements to the tree. In the first model, attach each child element to its parent, and finally attach the entire subtree to the primary tree. This method can cause leaks through temporary objects if other conditions are met. In the second model, we attach elements into the primary tree working our way from top-level dynamically created element down through all of the children. Because each attachment inherits the scope of the primary document we never generate temporary scopes. This method is much better at avoiding potential memory leaks.

    Figure 3 DOM Insertion Order Leak Model

    Figure 3. DOM Insertion Order Leak Model

    Next, we are going to cover an example of a leak that is transparent to most leak-detection algorithms. Because we don’t leak any publicly visible elements and the objects we leak are very small you might never notice this problem. For our example to work, the dynamically created elements will have to contain a script pointer in the form of an inline function. This will allow us to leak an internal script object that is created temporarily as we attach elements together. Because the leak is small, we’ll have to run thousands of samples. In fact, the objects leaked are only a few bytes. By running the sample and navigating to an empty page, you can see the difference in memory consumption between the two versions. When we use the first DOM model of attaching child to parent, then parent to the primary tree, our memory usage goes up a bit. This is a cross-navigation leak and the memory isn’t reclaimed until you restart the IE process. If you run the sample a few more times, using the second DOM model of attaching the parent to the primary tree and then the child to the parent, your memory won’t continue to climb and you’ll find that you’ve fixed the cross-page navigation leak.

    <html>
        <head>
            <script language="JScript">
    
            function LeakMemory()
            {
                var hostElement = document.getElementById("hostElement");
    
                // Do it a lot, look at Task Manager for memory response
    
                for(i = 0; i < 5000; i++)
                {
                    var parentDiv =
                        document.createElement("<div onClick='foo()'>");
                    var childDiv =
                        document.createElement("<div onClick='foo()'>");
    
                    // This will leak a temporary object
                    parentDiv.appendChild(childDiv);
                    hostElement.appendChild(parentDiv);
                    hostElement.removeChild(parentDiv);
                    parentDiv.removeChild(childDiv);
                    parentDiv = null;
                    childDiv = null;
                }
                hostElement = null;
            }
    
            function CleanMemory()
            {
                var hostElement = document.getElementById("hostElement");
    
                // Do it a lot, look at Task Manager for memory response
    
                for(i = 0; i < 5000; i++)
                {
                    var parentDiv =
                        document.createElement("<div onClick='foo()'>");
                    var childDiv =
                        document.createElement("<div onClick='foo()'>");
    
                    // Changing the order is important, this won't leak
                    hostElement.appendChild(parentDiv);
                    parentDiv.appendChild(childDiv);
                    hostElement.removeChild(parentDiv);
                    parentDiv.removeChild(childDiv);
                    parentDiv = null;
                    childDiv = null;
                }
                hostElement = null;
            }
            </script>
        </head>
    
        <body>
            <button onclick="LeakMemory()">Memory Leaking Insert</button>
            <button onclick="CleanMemory()">Clean Insert</button>
            <div id="hostElement"></div>
        </body>
    </html>

    This leak deserves clarification, because our workaround goes against some best practices in IE. The key points to understand about the leak are that DOM elements are being created with scripts already attached. This is actually crucial to the leak, because if we create DOM elements that don’t contain any script and attach them together in the same manner we don’t have a leak problem. This gives rise to a second workaround that might be even better for larger subtrees (in the example we only have two elements, so building the tree off the primary DOM isn’t a performance hit). The second workaround would be to create your elements with no scripts attached initially so that you can safely build your subtree. After you’ve attached your subtree to the primary DOM, go back and wire up any script events at that point. Remember to follow the principles for circular references and closures so you don’t cause a different leak in your code as you hook up your events.

    I really wanted to point out this issue because it shows that not all memory leaks are easy to find. It could take thousands of iterations of a smaller pattern to become visible, and it might be something slight, like the order of insertion of DOM elements that causes the problem to arise. If you tend to program using only best practices, then you think you are safe, but this leak shows that even best practices can exhibit leaks. Our solution here was to improve upon the best practice or even introduce a new best practice in order to remove the leaking condition.

    Pseudo-Leaks

    Often times the actual behavior and expected behavior of some APIs can lead you to misdiagnose memory leaks. Pseudo-leaks almost always appear on the same page during dynamic scripting operations and should rarely be visible after navigation away from the page to a blank page. That is how you can eliminate the issue as a cross-page leak and then start to work on whether the memory consumption is expected. We’ll use script text rewriting as our example of a pseudo-leak.

    Like the DOM Insertion Order issue, this issue also relies on the creation of temporary objects in order to “leak” memory. By rewriting the script text inside of a script element over and over again, slowly you’ll begin to leak various script engine objects that were attached to the previous contents. In particular, objects related to debugging script are left behind as are fully formed code elements.

    <html>
        <head>
            <script language="JScript">
    
            function LeakMemory()
            {
                // Do it a lot, look at Task Manager for memory response
    
                for(i = 0; i < 5000; i++)
                {
                    hostElement.text = "function foo() { }";
                }
            }
            </script>
        </head>
    
        <body>
            <button onclick="LeakMemory()">Memory Leaking Insert</button>
            <script id="hostElement">function foo() { }</script>
        </body>
    </html>

    If you run the above code and use the Task Manager trick again, while navigating between the “leaking” page and a blank page, you won’t notice a script leak. This script leak is entirely within a page and when you navigate away then you get your memory back. The reason this one is bad is due to expected behavior. You expect that after rewriting some script that the original script won’t stay around. But it really has to, because it might have been used already for event attachments and there might be outstanding reference counts. As you can see, this is a pseudo-leak. On the surface the amount of memory consumption looks really bad, but there is a completely valid reason.

    Conclusion

    Every Web developer builds a personal list of code examples that they know leak and learns to work around those leaks when they see them in code. This is extremely handy and is the reason the Web is relatively leak-free today. Thinking about the leaks in terms of patterns instead of individual code examples, you can start to develop even better strategies for dealing with them. The idea is to take them into account during the design phase and make sure you have plans for any potential leaks. Use defensive coding practices and assume that you’ll need to clean up all your own memory. While this is an overstatement of the problem, you very rarely need to clean up your own memory; it becomes obvious which variables and expando properties have the potential for leaking.

    In the interest of patterns and design I highly recommend Scott’s short blog entry because it demonstrates a general purpose example of removing all closure-based leaks. It does require a bit more code, but the practice is sound and the improved pattern is easy to spot in code and to debug. Similar registration schemes can be used for expando-based circular references as long as care is taken that the registration method itself isn’t riddled with leaks (especially where closures are used)!

    About the author

    Justin Rogers recently joined the Internet Explorer team as an Object Model developer working on extensibility and previously worked on such notable projects as the .NET QuickStart Tutorials, .NET Terrarium, and SQL Reporting Services Management Studio in SQL Server 2005.

    Enhance Windows Speech Recognition by Using Macros

    In this article I will talk again about Windows Speech Recognition and how you can enhance its functionality by using macros. I will show you how to create macros which do things such as: insert specific blocks of text, run programs with specific parameters and send keystrokes to any application. You will also learn how to create aliases for existing Windows Speech Recognition commands which are are hard to remember and replace them with more meaningful voice commands. At the end I will detail how to create macros which execute more advanced commands such as searching weather information for a given location.

    What is a Windows Speech Recognition Macro?

    Windows Speech Recognition macro is a vocal command that can be used to execute more than one action. Think of a macro as an alias for more operations. For example, instead of dictating all letters from A to Z, you could just say ‘Type Alphabet’ andWindows Speech Recognition will type all letters of the alphabet for you. As you will see, Windows Speech Recognition macros can be used to do many useful things which will improve your productivity.
    What to Install in Order to Use Windows Speech Recognition Macros

    The first step is to download an application made by Microsoft called Windows Speech Recognition Macros. Before you download it, Microsoft will verify if you have a genuine copy of Windows. If you don’t, you won’t be able to download the application. If you do have a genuine copy of Windows Vista, then download the ‘WSRMacros.msi’ file found at the bottom of Microsoft’s download page. After you have finished the download, run the setup and install it.

    Windows Speech Recognition Macros

    Go to Start Menu -> Windows Speech Recognition Macros. The application can be also found in the folder ‘C:\Program Files\WSRMacros\’.

    Windows Speech Recognition Macros

    When you click on the shortcut, it will launch both Windows Speech Recognition and Windows Speech Recognition Macros. In the system tray, in the down right corner of your screen, you will see the Windows Speech Recognition Macros icon.

    Windows Speech Recognition Macros
    How to Create Windows Speech Recognition Macros

    Once you have started the application, you can see the Windows Speech Recognition Macros in the down right corner of your screen. Right click and, in the contextual menu, click on New speech Macro. Alternatively you can double click on the Windows Speech Recognition Macro icon.

    Windows Speech Recognition Macros

    A new window called New Speech Macro will appear, with five available options from which to choose. Each of these options will let you create a macro which does a specific action. I will explain what you can do with these options and how they can make your day to day computer activities easier and less time consuming. To select an option, just click on its button.

    Windows Speech Recognition Macros
    Create Macros Which Insert Specific Blocks of Text

    By clicking on the first option, called Insert Text, you will create a macro which can insert a specific text. For example, imagine having to sign yourself at the end of each e-mail. Instead of dictating With Respectyour name, your position in the company and other similar details, you could just say sign my name or something else more to your liking, and Windows Speech Recognition will type it all for you.

    Once you click on the Insert Text button, the New Speech Macro window will pop-up. Now you have to specify the trigger and the text you want to insert. The trigger is a sign, in our case a voice command that is expected before the action can be done. For example, you need to say ‘Start listening’ (trigger) before Windows Speech Recognition starts listening (action trigger) to any of your commands. If you don’t say the trigger command, Windows Speech Recognition remains idle without doing anything.

    The first field from the New Speech Macro window is the trigger field. Type or dictate the trigger, in our case ‘sign my name’. In the second field called the ‘action triggered’, you should type the text that will be inserted. This can be of any length. For this example, I typed With Respectnew linename and the remaining details.

    Once you are done with the trigger and the action triggered, click on Next.

    Windows Speech Recognition Macros

    Now you are given the opportunity to recheck the trigger and the action triggered. Also, you can give a specific name to the macro file you are creating.

    NOTE: Every macro is saved into a file and all macros are located by default in the ‘Documents -> Speech Macro’ folder. It is recommended NOT to change their location. By default, Windows Speech Recognition looks for macros in this folder and will load them and use them when triggered.

    Leave the ‘Digitally sign’ option checked and click on the Create button.

    Windows Speech Recognition Macros

    A new window will appear coupled with an User Access Control (UAC) prompt, asking for your permission to continue. Afterwards, you will see a window called ‘Signing data with your private signature key’. Click on OK and you will be announced that your macro has been created.

    Windows Speech Recognition Macros
    Create Macros Which Run Programs

    With this option you can create macros which open an application of your choice when you dictate a certain command. To create such a macro, when you are in the New Speech Macro window, choose the second option called ‘Run a Program’.

    Windows Speech Recognition Macros

    You are prompted for a voice trigger command and for the path to the application you wish to open. To select the application, click on the Browse button.

    Windows Speech Recognition Macros

    Look for the application you want to start when saying the trigger command and click on OK.

    Windows Speech Recognition Macros

    In the last field you can add command line arguments for the application you just selected. For example, in the screenshot below, I am making a macro which launches Mozilla Firefox so that, every time it starts, it loads our site.

    Windows Speech Recognition Macros

    When done, click on Next. Afterwards, you will see a window called ‘Signing data with your private signature key’. Click on OKand you will be announced that your macro has been created.
    Create Macros Which Send Keystrokes

    With this option you can create macros which send keystrokes to the computer when you dictate a certain command. Once theNew Speech Macro window appears, choose the third option called ‘Send Keystrokes’.

    Windows Speech Recognition Macros

    You are now prompted for a voice trigger command and the keys you wish to have pressed when the action is triggered. With this option you can create voice triggers for specific keyboard commands. Instead of ‘ALT+F4′ (close current application) you can dictate ‘close window’.

    Enter the voice command that you want to use and the combination of keys that will be sent to the currently running application.

    Windows Speech Recognition Macros

    IMPORTANT: The keys between double braces -{{key}}- are really important and are called modifiers. As a rule, they will always be higher in precedence than all the other keys. The keys enclosed in single braces -{key}- are called non-modifiers. The rest of the keys are considered normal keys (letters or numbers) and they don’t need braces.

    The keys that are mainly used for double or single braces are Ctrl, Alt, Shift, F1 to F9 , TAB, ESC and such keys. The last set of keys, normal ones such as a letters or numbers, won’t have any set of braces and they will be last in the sequence.

    A modifier is a key that is pressed, awaits for another key to be pressed and then they are both released. This is used when using combination such as {{CTRL}} C (copy), {{CTRL}} V (paste), {{CTRL}}{{SHIFT}}{ESC}.

    The keys that are enclosed in single braces are those that aren’t apart of simple numbers and letters and are also not pressed and kept pressed awaiting for another key.

    It is important to keep the braces precedence to have a macro working properly. The order is {{all modifiers}} {all non-modifiers} normal keys . To better understand this, it is correct to use {{CTRL}}{{SHIFT}}{ESC} (notice that there is no modifier after the non-modifier), but incorrect to use {ESC}{{CTRL}}{{SHIFT}} or {{CTRL}}{ESC}{{SHIFT}}. The modifiers -{{keys}}- must always be put first.

    When creating this type of macros be careful to the numbers of braces used for modifiers and non-modifiers keys and the order in which you write them. If there is one little mistake, the macros won’t function correctly and you will get an error message similar to the one below.

    Windows Speech Recognition Macros
    Create Alias Macros for Default Commands

    With this option you can create a Speech Macro that emulates an existing Windows Speech Recognition command using a phrase of your own. If you want to know the complete list of Windows Speech Recognition, go to Control Panel -> Ease of Access -> Speech Recognition Options -> Open the Speech Reference Card. If you think that some of the commands are not really natural and easy to remember, you can use this option to define other commands which do the same thing but are easier to remember.

    To quickly create such aliases, click on Emulate Recognition in the New Speech Macro window.

    Windows Speech Recognition Macros

    In the first field type the command you want to use. In the second, write the Windows Speech Recognition command that you want to emulate.

    Windows Speech Recognition Macros

    Review the macro you just created, specify the filename and click on Create.

    Windows Speech Recognition Macros
    Create Macros which Execute Advanced Commands

    You can create also more advanced macros which execute commands stored as XML code. XML is a simple markup language designed for easy information sharing between computers, applications, etc. It is generally used to describe different kinds of data in a structured way.

    Windows Speech Recognition Macros allows you to load and use advanced commands stored as XML files. This kind of XML macros can execute tasks such as searching the weather for a specific location or help you navigate through your PowerPoint slides. Microsoft provides you a small library of advanced macros which you can download and use. They can be found on theWindows Speech Recognition Macros download page.

    To create such macros, click on Advanced in the New Speech Macro window.

    Windows Speech Recognition Macros

    Next, download the macros you want from the Windows Speech Recognition Macros download page. Open them using Notepad or any other text editor. If you don’t know how to do it, read our tutorial called How to open files using a different program than the default.

    Then copy the whole text from Notepad, paste it into the New Speech Macro window and click on Next.

    Windows Speech Recognition Macros

    Then save your macro and you are done.
    Conclusion

    As you can see from this article, Windows Speech Recognition Macros is a very useful application which can simplify the way you use Windows Speech Recognition. If you have used it already don’t hesitate to share your experience with us and our readers. All will be happy to learn more about this application.

    In previous articles I talked about how to use Windows Speech Recognition and how to take advantage of its advanced configuration options so that you can have a great experience. In this article I will talk about Windows Speech Recognition Profiles and how to easily backup and restore them any time you need to. As you will see for yourself, the procedure is very simple and involves using a small tool.
    What a Speech Profile Is

    A profile is basically the collection of all settings and information about how to recognize your voice when using Windows Speech Recognition. Before changing the language used or letting other persons use Windows Speech Recognition it is best to create a new profile so that your current one will remain unaltered. If another person will use Windows Speech Recognition and you don’t create another profile, it will alter the performance of the application and it is very likely to have worse results when working with it in the future.

    How To Make a New Profile

    To learn how to create a new profile, check out our previous article called Windows Speech Recognition: How To Benefit From its Advanced Configuration Options. In that article you will find a chapter called How To Create, Change or Remove Windows Speech Recognition Profiles. Carefully read and follow the instructions shown there.

    Why Backup Speech Profiles

    There are many reasons why you should backup your speech profile(s). First of all, in case your computer crashes and you need to reinstall Windows Vista, you will loose all the training and settings you made for Windows Speech Recognition. Having a backup is always handy as you can quickly restore everything once you reinstall your operating system. Also, if you have your profile saved you can also migrate it to another computer and use it there as well.

    How To Backup and Restore a Speech Profile

    First, you need to download a free application called the Speech Recognition Profile Manager Tool.

    After the download is complete, run the SpProfileMgr.exe file. You will receive a security warning. Click on Run.

    Speech Recognition Profile Manager Tool

    Accept the license agreement and extract the application in a folder of your choosing. Now, go to the folder where you unpacked the program and run SpProfileMgr.exe.

    Speech Recognition Profile Manager Tool

    Once the application has opened, you are presented with two options: import and export.

    If you previously saved a profile and want to add that profile, click on the Import button and load the file containing the previously backed up profile. To enable the newly imported profile as the default one, go to Control Panel -> Ease of Access -> Speech Recognition Options -> Advanced Speech Properties and check the profile you want. More information can be found in our previous article called Windows Speech Recognition: How To Benefit From its Advanced Configuration Options. There you will find a chapter called How To Create, Change or Remove Windows Speech Recognition Profiles. Carefully read and follow the instructions shown there.

    The Export option can be used to create backups of your current profiles. Select the profile you want to backup, click on Export, select the folder where you want to save it and type the file name. When done, click on Save.

    Speech Recognition Profile Manager Tool

    IMPORTANT: It is necessary to close Windows Speech Recognition before attempting to import or export a profile. Once you have imported a profile you need to start the Set up a microphone wizard from within Control Panel for optimal use. To do that, go to Control Panel -> Ease of Access -> Speech Recognition Options -> Set up a microphone.

    Speech Recognition Options

    NOTE: If you want to import your profiles on other computers with Windows Vista installed, download the Speech Recognition Profile Manager Tool and follow the same instructions.

    How To Install and Setup a Microphone

    I always wanted to hear my voice. I tried recording on an old cassette but didn’t like the results and it was hard to rewind exactly at the point at which my voice was heard. Thankfully the technology evolved and now, with the help of microphones and computers, I can hear my voice crystal clear. However, to make a microphone work in Windows Vista, sometimes you need to do a few little extra steps than the regular plug and play. So, with that said, in this article we will show you how to quickly make your microphone work in Windows Vista.

    Setting up the Microphone

    Before you start communicating with your computer you need to have a microphone set up. To do this, plug the microphone into your computer. Generally, the color of the microphone jack has the same color as the slot you need to plug it into. If that is not the case, then consult the manual of the sound card and see what is the appropriate port for the microphone.

    Next, click on the Start Menu button and click on Control Panel.

    Microphone Setup

    Once the Control Panel window opens, click on Hardware and Sound.

    Microphone Setup

    When you are in the Hardware and Sound list, click on em>Sound.

    Microphone Setup

    In the Sound window you have three tabs: click on the Recording tab.

    Microphone Setup

    Once you are in the Recording tab, right click on the microphone device you just plugged in and select the ‘Set as Default Device’option.

    Microphone Setup

    Now, to test and see if it really works, tap the microphone with your finger a few times. In the Sounds window, the empty lines next to the default microphone should fill up with a green color.

    Microphone Setup

    If you are in the Recording tab and you can’t see your microphone device, right click on any device shown in the Recording tab. In the contextual menu, click ‘Show Disabled devices’ if it isn’t marked with a check sign.

    Microphone Setup

    If you still can’t see your microphone, you might have not plugged it properly or you need to install a driver for it to work. In the first case, check to see if you have plugged it properly into your computer, plug it again or, if it is on a USB port, plug it in another USB port. As for the second case, use the drivers from the manufacturer’s site or from the CD that came along with the product.

    Read the text aloud

    At this point Windows Vista may still not recognize that the microphone has been activated. So we need to make Windows Vista aware of the tone and sound of our voice.

    Important: The following steps will be also done in the Windows Speech Recognition article so, if you came to this article from that one, you can now go to that one and continue reading from there.

    Open the Control Panel window and click on Ease of Access.

    Microphone Setup

    Now, in the Ease of Access window, click on Set up Microphone.

    Microphone Setup

    Choose the microphone device that you currently use and click on the Next button.

    Microphone Setup

    A few indications are given and, if they are followed, will give a better user experience. In my case, since I have selected the Headset microphone the indications are as shown in the image. Once you have read the advice given, click on the Next button.

    If you accidentally selected the wrong device or want to go back to a previous page of the setup, click on the blue Back arrow positioned in the top left corner of the setup wizard.

    Microphone Setup

    Read the given text aloud and, afterwards, click on the Next button.

    Microphone Setup

    In some cases the microphone does not work in the wizard setup, although it might be enabled and functions properly according to the Recording tab. If this happens, close the wizard setup and, after you checked to see you have the correct microphone device enabled, open the setup wizard again.

    In my case, for example, I have activated the microphone on the headset only when I got to this step and it doesn’t seem to work. A few taps on the microphone shows me that it works in the Recording tab, but does not work in the setup wizard, so I must restart the wizard setup.

    Microphone Setup

    Now, assuming you read the text and clicked on the Next button, the wizard setup will tell you that the microphone has been set up and also you will be prompted about setting up the Speech Recognition by pressing the Finish button.

    Microphone Setup

    If you encountered any problems while setting up your microphone and you managed to solve them, let us know about it. Others might find useful the solution you have found.

    In this article I will talk once more about Windows Speech Recognition and how to benefit from all its advanced configuration options. I will show you how to create new speech profiles and how to manage them, how to add vocabularies or change the existing ones used by the tool. Other topics that will be covered include: how to change the language used by Windows Speech Recognition, how to work with speech dictionaries, audible cues, and how to dictate in other applications.

    How To Work with Speech Dictionaries, Audible Cues, and How To Dictate Everywhere

    I will start with some basic configuration options which can prove to be very useful when working with Windows Speech Recognition. To get to these options, start the application and right click on it or on its taskbar icon.

    Windows Speech Recognition

    In the Options menu there are four options, as you can see in the screenshot below:

    Windows Speech Recognition

    • ‘Play audible feedback’ – every time you start, stop, make a mistake, or an important action related to Windows Speech Recognition, a distinct sound cue will be heard. This way, the application draws your attention if something important has happened. There are two kind of sound cues: one is used when you start or stop the application while the other one is used to signal problems when you dictate wrong words and commands that have not been understood by the application. In order to differentiate and understand why you hear a sound cue, you can read the text that appears in the application’s message zone. If you want to hear the sounds cues, leave this option checked.
    • Windows Speech Recognition

    • ‘Run at startup’ – will make the application always start when Windows Vista starts. This option is good if you decide to useWindows Speech Recognition on a daily basis. By leaving this option checked you won’t have to manually start it every time you want to use it.
    • ‘Speak text in correcting dialog’ – this is an interesting option which you can use to improve the application. When this option is enabled, each time you correct something you dictated, when using the correction dialog, Windows Speech Recognitionwill play the sound of your voice that was assigned to that word. For example, if I were to say tutorials and the application would understand tutorial, I would say correct tutorial. In the correction dialog I will hear my voice as it was recorded by the application when it was written. Now, I can change the word identified with the voice I heard myself saying and will make the application improve itself. Although this is an interesting option, the improvements are automatically done even when you don’t use it. Therefore, the only thing the option offers is the feedback you receive when hearing your own voice while dictating the word you are correcting.
    • ‘Enable dictation everywhere’ – if you leave this option checked, you can dictate in any application be it with support for speech recognition or not. However, if an application doesn’t offer support for speech recognition, you can only dictate text. You cannot make more advanced actions such as copy, undo, redo. As a reminder, to work with Windows Speech Recognition in an application, it needs to offer support for the Text Service Framework. Windows Vista can be commanded with Windows Speech Recognition because it uses this framework.

    Other important configuration options can be found in the Options context menu, in the Configuration sub-menu. There you canSet up the microphone, start another speech training session to make it easier for the application to recognize your voice or you can click on Open Speech Recognition Control Panel to quickly get to Control Panel -> Ease of Access -> Speech Recognition Options. All these options have been covered already in our Windows Speech Recognition Guide.

    How To Add Words to the Windows Speech Recognition Dictionary

    Below Options and Configuration you have the Open the Speech Dictionary option. This can be used to enrich the knowledge base of the application. Imagine that the application is a person that has basic knowledge of your language. If it hears new words, it won’t easily recognize them without further explanation. In order for Windows Speech Recognition to recognize a new word it needs it to be added in the dictionary used by the application. To add a word, Open the Speech Dictionary. The first time you use it, you will see two options: add a new word and prevent a word from being dictated. The first option can be used to add new words to the application dictionary and make it more familiar to your way of speaking. The second one will help you block words and prevent the application from reacting to them when you dictated them.

    NOTE: in the screenshot below you see three options. The third one – change existing words – appears after you created a few rules. The rules that are created can be modified at any time using this option.

    Windows Speech Recognition

    Next, I will show you how to create a new word. The same rules will apply to the other options as well so there is no need to go through all of them. While you are in the window shown in the screenshot above, click on the ‘Add a new word’. Then, dictate the word you want to add. If it is not recognized, correct it. When done, click on the Next button.

    Windows Speech Recognition

    When done, click on Finish.

    Windows Speech Recognition

    How To Use Alternative Vocabularies for Windows Speech Recognition

    You can always add Windows Speech Recognition vocabularies for specific domains such as medicine, engineering and others. There are companies such as Trigram Technologies which sell specialized vocabularies to those who need them. These vocabularies will help the application to recognize uncommon words used in specialized fields. If the speech engine cannot understand the phonetics used by you, it will never get the correct word no matter how many words you defined in the default dictionary. Using specialized vocabularies will make Windows Speech Recognition more accurate.

    After you install an additional vocabulary, you need to enable it in order for Windows Speech Recognition to use it. To do this, start the application and right click on it or on its taskbar icon. After that select Dictation Topic and then the vocabulary you just installed.

    Windows Speech Recognition

    NOTE: Every time it starts, Windows Speech Recognition will set itself to the default Narrative vocabulary. Therefore you might need to manually select the other vocabulary each time you want to use it.

    How To Access Advanced Speech Options

    NOTE:When changing the options described below, it is best to have Windows Speech Recognition closed. Restart the application after you have made the changes you want.

    First, go to Control Panel -> Ease of Access -> Speech Recognition Options. Once you are in the Speech Recognition Optionswindow, click on ‘Advanced speech options’, in the top left corner.

    Windows Speech Recognition

    In the Speech Properties window, go to the Speech Recognition tab. There you will have four distinctive functions, as shown below.

    Windows Speech Recognition

    These are: language, recognition profiles, user settings and microphone. For more details about them and what they do, please continue reading.

    How To Create, Change or Remove Windows Speech Recognition Profiles

    Even though it is not the first option in the list, I will talk about it firstly, as it is the most important. A profile is basically the collection of all settings and information about how to recognize your voice when using Windows Speech Recognition. Before changing the language used or letting other persons use Windows Speech Recognition it is best to add another one so that your current one will remain unaltered. If another person will use Windows Speech Recognition and you don’t create another profile, it will alter the performance of the application and it is very likely to have worse results when working with it in the future.

    Windows Speech Recognition

    To begin, in the Speech Properties window you have the option to create a new profile. Click on the New button, type the name for the new profile and follow the instructions shown by the wizard.

    Windows Speech Recognition

    When done, the profile will be created and you can start training Windows Speech Recognition.

    If you have more than one profile, you can change it just by checking the name of another profile. You can also delete profiles that you previously created. To do this, first select the profile, click on the Delete button and confirm the operation.

    Windows Speech Recognition

    NOTE: Before you enable, disable or delete a profile, close Windows Speech Recognition. Otherwise you will receive an error message like the one shown below.

    Windows Speech Recognition

    How To Change the Language used by Windows Speech Recognition

    If you want to use a different language than the default one, you first need to install it. To learn how to do this, read our guide on how to change the interface language in Windows Vista.

    After you have installed and enabled the additional language, in my case French, open the the Speech Properties window again. Create a new speech profile as shown above and, from the Language drop-down menu, select the language you want to use.

    Windows Speech Recognition

    NOTE: The dialog that takes place between you and the computer can only be done if the language used for dialogs and menus by Windows Vista is the same as the language set for Windows Speech Recognition. Imagine, for example, sayingwelcome to a French person. While the French person may probably understand, the computer will be confused because it awaits only for the French word for welcome.

    Windows Speech Recognition

    Now, when opening Windows Speech Recognition, the new language will work properly. If it does not work, redo the steps and make sure you have the Windows Speech Recognition closed, have set the language correctly and checked the correct profile.

    Windows Speech Recognition

    The next time you open Windows Speech Recognition it will work with the new language that was set as default. All that remains is to take the tutorials using the new language. Details about how to train can be found in our Windows Speech Recognition Guide.

    How To Configure User Settings

    The next set of configuration options from the Speech Properties window allows you to start Windows Speech Recognitionautomatically at startup and to use your documents to improve itself.

    Windows Speech Recognition

    The last setting is about how many spaces Windows Speech Recognition will add after the punctuation you dictate. The default value is 2 and can be changed from the drop-down list.

    How To Setup the Microphone

    The last set of configuration options from the Speech Properties window allows you to configure the microphone used byWindows Speech Recognition.

    Windows Speech Recognition

    If you click on Audio Input it will open the Sound window where you can configure the microphone device you are using. To learn how to do this, check our previous tutorial on this topic called How To Install and Setup a Microphone.

    The Advanced button, when clicked, will allow you to change the audio input device. You can change this to use a device only with Windows Speech Recognition while keeping another microphone device for other uses as the default. If you don’t have such plans, leave it set on the ‘Use preferred audio input device’.

    Windows Speech Recognition

    The ‘Configure Microphone’ button opens the Set up a microphone wizard from the Windows Speech Recognition Options. More information on how to setup your microphone to work with Windows Speech Recognition can be found here.

    Conclusion

    As you can see from this article, Windows Speech Recognition is a very versatile tool with many configuration options which can help satisfy your needs. If you have additional information on how to configure and work with this tool, don’t hesitate to leave a comment and share it with us and our readers. There are many people who will find it useful as there is not much in-depth information about how to work with this tool available on the Internet.

    The Windows Speech Recognition Guide

    Since I saw my first Sci-Fi movie flicks, I wanted to have the technology they were using. I still haven’t touched or seen flying spaceships at that scale, teleporting devices, robots that can dance or other similar gadgets. However, I have found a piece of that dream incorporated in Windows Vista’s Windows Speech Recognition application. This tool tries to understand what you are saying and converts spoken words to machine-readable input such as key presses or Windows commands, thus limiting the need for using the mouse and keyboard. In this tutorial I will show you how to set up Windows Speech Recognition, learn how to use it and give you some information about common issues with this application.

    In order to use Windows Speech Recognition you need a microphone. To learn how to set it up, read our guide on How To Install and Setup a Microphone.
    How to setup Windows Speech Recognition

    Once you have set up your microphone, you need to train Windows Speech Recognition to understand your voice. To do this, open the Control Panel window and click on Ease of Access.

    Windows Speech Recognition

    If you are using the Classic Control Panel, go to Control Panel -> Ease of Access Center.

    When you are in the Ease of Access window, click on Speech Recognition Options.

    Windows Speech Recognition

    In the Speech Recognition Options window, click on Start Speech Recognition.

    Windows Speech Recognition

    A setup wizard will appear. To start the configuration, click on the Next button.

    Windows Speech Recognition

    Choose the microphone device that you currently use and click on the Next button.

    Windows Speech Recognition

    A few indications are given and, if followed, they’ll give you a better experience. In my case, since I have selected the headset microphone, the indications are as shown below. Once you have read and followed the given advice, click the Next button.

    Note: If you accidentally selected the wrong device or you just want to go back to a previous page of the setup, click on the blue Back arrow at the top left corner of the setup wizard window.

    Windows Speech Recognition

    Read the given text aloud and after that, click the Next button.

    Windows Speech Recognition

    This procedure seems to be a bit error prone so you might want to repeat it a couple of times and adjust the position of the microphone and its distance from the speakers.

    Note: If you have already tried a couple of times and the microphone still didn’t seem to work, close the wizard and double check our guide on How To Install and Setup a Microphone. Once the microphone is setup correctly, restart the procedure described in this article.

    Windows Speech Recognition

    If you read the text and click the Next button, the wizard will tell you that the microphone has been setup. Click on the Finishbutton.

    Windows Speech Recognition

    After the microphone is setup, the wizard will try to improve the speech recognition accuracy. The setup wizard will ask your permission to let the application improve itself by using texts from your documents or mail. After you select the option you want, click Next.

    Windows Speech Recognition

    Now the wizard will give you a speech reference card which contains the list of commands the computer will respond to. If you click on View Reference Sheet, you can see the commands and also print them.

    Windows Speech Recognition

    When done, click Next.

    Note: The Reference Sheet can be read and printed at any further time, simply by going to Control Panel -> Ease of Access -> Speech Recognition Options -> Open the Speech Reference Card.

    Windows Speech Recognition

    You can make the application start up every time you start Windows Vista by checking the ‘Run Speech Recognition at startup’option. If you leave it unchecked, the application will have to be started manually each time you want to use it.

    Windows Speech Recognition
    Learn how to use Windows Speech Recognition

    Once you are done with the setup, you will be asked to go through a tutorial and learn how to use it. Click on the Start Tutorialbutton to enter.

    IMPORTANT: We will not give you any indications about the content found in the tutorial. We think that the tutorial is well written and contains all the information you need. Please reserve 10-15 minutes to go through it. Even though it might seem frustrating at first, you will be satisfied with the results.

    If you have finished the tutorial and you think Windows Speech Recognition is not hearing your voice commands well enough, you can take the same tutorial again. To do this, go to Speech Recognition Options and click on Take Speech Tutorial.
    If you have gone through the tutorial, but you still feel the need to improve the way Windows Speech Recognition works, you can take another tutorial based on reading texts. To open and use this text based tutorial, click on ‘Train you computer to better understand you’ located in the Speech Recognition Options window.

    Recommendation: Go through the ‘Train your computer to better understand you’ tutorial more than once. Even if you make mistakes the first couple of times, in less than 3 days with 2 hours a day, you will wonder how you could have lived without this great application. Instead of closing the application, just say stop listening or press the Control + Windows sign from your keyboard.
    Known issues

    Some applications may not work with Windows Speech Recognition. This is because applications must have support for Text Services Framework. The framework was built by Microsoft to enable advanced text input, speech recognition, hand writing and multilingual support into applications. So, if application developers didn’t include the Text Services Framework when they built their application, Windows Speech Recognition will not work properly with their application.

    Windows Speech Recognition is not working when UAC (User Account Control) warnings appear. In such cases, use the mouse or keyboard to select the UAC option you want.

    Powered by WordPress | Theme: by 85ideas. Editor by Khoanguyen