In this blog you will find the source code (below) to “let NAV speak.” You would have a wide range of possibilities to use this simple Add-in and enlarge this project.
If you want to know more about Client Add-ins you can refer to this MSDN link:
Extending the RoleTailored Client Using Control Add-ins and Microsoft Dynamics NAV 2009 SP1
This simple Client Add-In is based on System.Speech namespace:
Microsoft.Speech.Synthesis Namespace
Step by step creation of the NSpeech Add-In
(Remember the ‘DodgeBall’ rules: Develop, Sign, Place, Register and Develop)
A. Create a New Class Project
B. Create a Strong Name Key (SNK)
C. Add References to the Project
D. Develop your NSpeech Project
(You can simply copy and paste this code into your Class project.)
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
//Add a reference to the Add-in API (see the solution explorer) and all relevant references
//Use all relevant references
using System.Drawing;
using System.Windows.Forms;
using Microsoft.Dynamics.Framework.UI.Extensibility;
using Microsoft.Dynamics.Framework.UI.Extensibility.WinForms;
//this is to let this add-in speech
//http://msdn.microsoft.com/en-us/library/dd146744(v=office.13).aspx
using System.Speech;
using System.Speech.Synthesis;
namespace NSpeech
{
//Develop the control add-in class.
//Assign a name to the control add-in (MyCompany.MyProduct.MyAddIn)
[ControlAddInExport("Cronus.DynamicsNAV.NSpeech")]
[Description("Let this Add-in Speak")]
//Select a base class as a starting point.
//Select interfaces to implement features, such as data binding or event handling.
public class Class1 : StringControlAddInBase
//Implement control creation
protected override Control CreateControl()
//Create a brand new TextBox
TextBox control = new TextBox();
//Define TextBox size
control.MinimumSize = new Size(50, 0);
control.MaximumSize = new Size(500, Int32.MaxValue);
//Add a DoubleClick event for the TextBox
control.DoubleClick += new EventHandler(control_DoubleClick);
return control;
}
//Define a voice synth
private SpeechSynthesizer synth;
private void control_DoubleClick(object sender, EventArgs e)
//create a new speech synth and set default audio device
synth = new SpeechSynthesizer();
synth.SetOutputToDefaultAudioDevice();
//Pass TextBox content in a string variable
string data = this.Control.Text;
//... and let NAV speak it!
synth.SpeakAsync(data);
E. Build the NSpeech.dll
F. Place DLL into Add-in folder
(typically the Add-ins folder is here: C:\Program Files\Microsoft Dynamics NAV\60\RoleTailored Client\Add-ins)
G. Determine the PKT (Public Key Token) of NSpeech
Sn –T “C:\TMP\NSpeech\NSpeech\bin\Debug\NSpeech.dll” In the following example, 250f71f35a467631 is the PKT (Public Key Token) needed to register the Add-in into NAV. (You will have another value.)
Sn –T “C:\TMP\NSpeech\NSpeech\bin\Debug\NSpeech.dll”
In the following example, 250f71f35a467631 is the PKT (Public Key Token) needed to register the Add-in into NAV. (You will have another value.)
H. Register the NSpeech dll
How to Use This Add-in
As an example, you can just let NAV speak the content of the field “Name” in Customer Card page (Page 21).
Now…you are ready to let NAV speak the Customer Name from the customer card by simply double clicking on on the Name!
This simple Client Add-in project may be used in, e.g.
This simple Client Add-in project may be enlarged, e.g.
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
Amazing add-in! :D I saw last week in Madrid and I just install on my computer. Thank you very much
Great post Duilio!
I tested it with an italian version of Nav2009sp1 and it works fine.
I hope Miscosoft people will publish other example about add-in capabilities like this.
Hi Duilio! That's fine!
This example helped me in discovering new opportunities with wonderful NAV!
Dear Duilio,
I am interested to try and test this and have read your latest blog that you published a few days ago on "Let NAV Speak"(31 Dec 2010). However, is it possible to get the control add-in object (NSpeech) from you? Or is there any way for me to download this? Thanks if you could help.
Hi Danny, this Client Add-in is quite simple. Just read the step by step construction and you surely will succeed in develop it your own. From this blog you can then familiarize with the Add-In development. I may suggest you to check
msdn.microsoft.com/.../dd983700.aspx
and Cabell blog too
blogs.msdn.com/.../cabeln
Unfortunately, I am not allowed to attach / redispatch dll files for our internal policy. Also FOB files shouldn't be allowed to be posted from us that is why you find txt object only.
As mentioned, follow the simple example. Is pretty much easy.
Thank you veru much for your prompt reply. If it is the policy to not allow to attach any DLL or FOB files, I will respect that. Thanks again for your help.
Hi DuilioTacconi..
Thanks for your information..
i tested it but i have error when running the page.