Skip to content

.NET Programming

Let NAV Speak! (with .NET Interop and NAV 2009 R2)

In this blog is described a very simple usage of the .NET interoperability feature with Microsoft Dynamics NAV 2009 R2 and can be considered an extension of my previous blog: http://blogs.msdn.com/b/nav/archive/2010/07/09/let-nav-speak-with-a-simple-and-useful-client-add-in.aspx.

It is intended just to familiarize you with this brand new feature proposed with the NAV 2009 R2 release.

If you want to know more about .NET interoperability for NAV 2009 R2, please refer to MSDN link:

Extending Microsoft Dynamics NAV Using Microsoft .NET Framework Interoperability

http://msdn.microsoft.com/en-us/library/gg502499.aspx

The .NET interoperability code snippet in this blog is based on the System.Speech namespace.

http://msdn.microsoft.com/en-us/library/ms554861(v=VS.90).aspx

My ingredients:

  • NAV 2009 R2
  • Windows 7 Enterprise

Create your “Speak it!” action and let NAV speak Customer Names :

1. Open Classic Client

2. Go to the Object Designer

3. Select Page object (alt+g)

4. Select Page 22 “Customer List”

5. Design Page 22 “Customer List” (alt+d)

6. Select View > Page Actions (al+v, o)

7. Create a new Action (F3) in the ActionItems container (see below)

8. Change the properties of the Action as below:

Caption – Speak it !

Image – ViewComments

Promoted – Yes

PromotedCategory – Process

PromotedIsBig – Yes

9. Edit the code in the Speak it! Action (F9)

10. Add those LOCAL variables

dnSpeech

DataType: DotNet

Subtype: System.Speech, Version=3.0.0.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35.System.Speech.Synthesis.SpeechSynthesizer

RUNONCLIENT: Yes
Synth

DataType: DotNet

Subtype: System.Speech, Version=3.0.0.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35.System.Speech.Synthesis.SpeechSynthesizer

RUNONCLIENT: Yes

dnVoiceGender

DataType: DotNet

Subtype: System.Speech, Version=3.0.0.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35.System.Speech.Synthesis.VoiceGender

RUNONCLIENT: Yes

I

DataType: Integer

 

NOTE: RUNONCLIENT is a property of each DotNet variable (shift+f4)

11. Add this code snippet in the OnAction trigger

// Copyright © Microsoft Corporation. All Rights Reserved.

// This code released under the terms of the

// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

// Use the constructor to create a new Synthesizer

Synth := dnSpeech.SpeechSynthesizer();

// http://msdn.microsoft.com/en-us/library/system.speech.synthesis.voicegender(VS.90).aspx

// This is an enumeration assignment:

// 0=NotSet,1=Male,2=Female,3=Netural

dnVoiceGender := 2; //Female

// NOTE: it will take the voice depending on what is

//  installed locally (e.g. Windows 7 has Microsoft Anne voice)

Synth.SelectVoiceByHints(dnVoiceGender);

// Please, speak slowly (range [-10:10])

Synth.Rate := -3;

Synth.SetOutputToDefaultAudioDevice();

Synth.Speak(FORMAT(Name));

// Row below is not needed. Synth is a local variable therefore it will be

// automatically disposed

// Synth.Dispose;

12. Save and compile (ctrl+s) page 22 “Customer List”

Now… you are ready to let NAV speech the Customer Name from the customer list by simply click on the “Speak it!” action.

These postings are provided “AS IS” with no warranties and confer no rights. You assume all risk for your use.

Best Regards,

Duilio Tacconi (dtacconi)

Microsoft Dynamics Italy

Microsoft Customer Service and Support (CSS) EMEA

Be Sociable, Share!

    Add Your Comment (Get a Gravatar)