Welcome to GotSpeech.NET Sign in | Join | Help
Getting Started with the Core API

With the introduction of Voice Response Workflows in Speech Server 2007, Microsoft has greatly simplified voice-enabled application development. The entire process is relatively painless; even downright enjoyable. And for most applications it is all you'll need to build outstanding applications.

Sometimes however you find the workflow model just isn't the right fit. It can be cumbersome to work with large application models, they are nearly impossible to diff against prior versions, and they lack much fine-grained control over the engine. For these reasons and more it is sometimes desirable to dig to a lower-level - the Core API.

Even if you never plan to write a real application using the API, I suggest learning how it works. The workflow model is really just driving the API in the background and understanding what is going on under the covers can be very helpful.

Setting Up Your Project

Getting started with the API can be a bit confusing at first. There is very little documentation available and no built-in project templates for it.

We'll start by creating a new Voice Response Workflow Application. We'll use the project that gets generated as our foundation; removing any items we don't need.

image

During the creation process Visual Studio will ask you which Application Resources you wish to generate. We'll uncheck all of them; they are not necessary for our project.

image

Once our project is ready we'll remove the following files:

  • VoiceResponseWorkflow1.cs
  • PromptStrings.resx
  • manifest.xml

Finally we remove all references to the VoiceResponseWorkflow1 class from Class1.cs. The resulting Class1 should look like the following:

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SpeechServer ;
using Microsoft.SpeechServer.Dialog;

namespace CoreAPI_EmptyProject
{
public class Class1 : IHostedSpeechApplication
{
private IApplicationHost _host;

public void Start(IApplicationHost host)
{
if (host != null)
{
_host = host;
_host.TelephonySession.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo("en-US");
}
else
{
throw new ArgumentNullException("host");
}
}

public void Stop(bool immediate)
{

}

public void OnUnhandledException(Exception exception)
{
if (exception != null)
_host.TelephonySession.LoggingManager.LogApplicationError(100, "An unexpected exception occurred: {0}", exception.Message);
else
_host.TelephonySession.LoggingManager.LogApplicationError(100, "An unknown exception occurred: {0}", System.Environment.StackTrace);

_host.OnCompleted();
}
}
}

 

If you would like to download the completed project, it is avilable here

. In future posts I will often use this project as my starting point.

 

NOTE: Some may notice that this post is very similar to one I made on my other blog. Given the nature of this new blog I felt it was worth duplicating it here as a starting point.

Posted: Tuesday, July 22, 2008 9:46 AM by ml_
Filed under: , ,

Comments

Marc LaFleur said:

With the introduction of Voice Response Workflows in Speech Server 2007, Microsoft has greatly simplified

# December 22, 2008 10:37 PM
Anonymous comments are disabled