fredag den 30. marts 2012

Microsoft Speech with non-english languages

I had a horrid time trying to get the Microsoft text-to-speech to work with my native Danish language. So here's how I made it work. Hope it'll help you save a few hours.

The target is a C# .net 3.5 console application. Later I'll work out how to use it from a web-server.

Key is using the same version numbers for all components. Download and install the following, in the same order as below:

- Microsoft Speech platform runtime 11.0 - (select the x86 og x64 platform according to your OS)
- Microsoft Speech platform SDK 11.0 - (again, select the x86 og x64 platform according to your OS)

Having downloaded and installed the above, now's the time to select your language of choice from the language  download section:

Download one or more of the language files with the "TTS" in the filenames (short for 'text-to-speech'). The other runtime languages are for speech recognition, not text-to-speech.

Now, in your Visual Studio, create a new console application.

Important steps:

- Set the deployment target CPU architecture to the same version of the microsoft components you downloaded. So if your OS is x86, and you thus downloaded the x86 microsoft speech components, set the deployment target as 'x86'.
- Reference the Microsoft.speech DLL from the C:\Program Files\Microsoft SDKs\Speech\v11.0\Assembly-folder.

All set, then. Here's a sample Main()-method:

 static void Main(string[] args)
            // Initialize a new instance of the SpeechSynthesizer.
            SpeechSynthesizer synth = new SpeechSynthesizer();
            // select your installed voice
            synth.SelectVoiceByHints(VoiceGender.NotSet, VoiceAge.NotSet, 0, new CultureInfo("da-dk"));
            // important to set the output to the default device, or no sound will be heard.
            // speak a phrase
            synth.Speak("patter der batter");

tirsdag den 27. marts 2012

A powershell printing application

Here's a powershell application (with a winforms GUI) which allows a user to select a number of printers retrieved from an Active Directory server (via ldap) and install them.

Link to zip-file

The code is a mess, there're a lot of references no longer needed and unused functions which should be removed, but maybe it'll be helpful to some.

I used the free PrimalForms 2011 40-days preview to code and debug the application, I recommend it highly.

mandag den 26. marts 2012

A JQuery Mobile mini-survey

Here's a Jquery Mobile mini survey implementation.

It's a C# web-application. Uses Linq-to-Xsd. The survey is defined in an xml-file, with a simple implementation of branching based on the selected response. The survey-pages - one question per page - are formed dynamically from the definition file. 3 different type of questions are offered;  Yes/no on/off-style questions, radio-group questions (single selection), and sliders.

No security is implemented, there's only a cookie write/read to ensure the user doesn't answer the survey twice.

Link to zip-file

Hope it's a starting point for some.

fredag den 23. marts 2012

Bind input type range change event

Took me forever to find out how to bind the input type="range" element's change-handler in JQuery. This is what I came up with, which works for me with JQuery 1.6.4:

  $(document).ready(function () {

  $('[type=range]').each(function () {

                $("#" + $(this).attr("id")).bind("change", function (event, ui) {


Hope this helps somebody.
The official start of my technical blog, with hopefully useful stuff