Do you want Dynamics AX to speak out messages for you ?(Text to speech) – Dynamics AX 2012 @ X++

Hi friends,

I was just trying my hands on text to speech library and developed a small class which will help to speak out the messages easily for you. This post will explain quickly how to convert text to speech using X++ by using System.Speech Library and you can explore from there Smile 

First, let’s add this library to our references Node. Go to AOT>> References >> Add references


Search for System.Speech in the list of assemblies, select it and click on Ok button


Now, let’s create a simple class by name SRSpeechSynthesizer

class SRSpeechSynthesizer




Add a new static method called speakAsync as shown below


public static void speakAsync(str _textToSpeak)


    System.Speech.Synthesis.SpeechSynthesizer synthesizer = new System.Speech.Synthesis.SpeechSynthesizer();


    synthesizer.set_Volume(100);  // 0…100

    synthesizer.set_Rate(-2);     // -10…10


    // Synchronous

    //you cannot perform any other function in your Windows Form until the "reader" object has completed the speech.



    // Asynchronous




Now, you can use this class and method wherever you want.


For the sake of demo, I have used it in info class >> add method. The reason why I have added here is to speak out all the messages that get added during the any process. I know it’s annoying if there are many messages that gets added to the Infolog stack. (But choice is yours clip_image003 )


You can customize further by parameterizing this option specific to users (in the user options form).

Add the below lines of code to the add method.

if (session.clientKind() == ClientType::Client)






That’s it. You can explore more on the System.Speech Library.

When you create a new SpeechSynthesizer object, it uses the default system voice. To configure the SpeechSynthesizer to use one of the installed speech synthesis (text-to-speech) voices, use the SelectVoice or SelectVoiceByHints method. To get information about which voices are installed, use the GetInstalledVoices method and the VoiceInfo class. (msdn). Also, ensure that audio device is installed and working fine.


Happy Dax6ng,




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: