To hear prompts in Spanish press 1.

To hear prompts in Spanish press 1.


On the surface this a fairly simple and common prompt. But when you start to think about how to implement this it gets a little more complicated. There are two responses to this prompt. The user can press 1 or simply do nothing.  If the user presses 1 then they should hear the prompts in Spanish but if they do nothing then things should proceed without any user input.


Normally a QuestionAnswer activity has a grammar that expects the user to choose something but the prompt above allows the user to do nothing as one of the responses. If the user does nothing (i.e. silence) then the normal response for a QuestionAnswer activity is to play the silence prompt and wait for a key press.


So how do you handle a prompt doesn’t always require input? Well I’m going to show you one way of doing it. Note that this approach also works for a barge in prompt where you want to give the user the ability to skip a prompt.


First you need to create a new speech application and include a grxml grammar. In the grammar setup a DTMF rule that only accepts a “1” key press.


Drop a SpeechSequence into the designer then add a QuestionAnswer activity and name them using whatever naming conventions you have.  Add text to the QA either using the Property Builder or in the TurnStarting event then attach the DTMF grammar. You now have the basics down and the QA will work if the user presses the “1” key. But how do you handle the “do nothing” choice? To handle that we will need to add some more stuff.


Next add an IfElse with two branches.




Then right click on the SpeechSequence and choose “View SpeechEvents” as shown below.




In the event handler add a ConsecutiveNoInputsSpeechEvent and set MaximumNoInputs to 1. By using a ConsecutiveNoInputsSpeechEvent the event will fire as soon as we get a silence or a noreco on the QA. This will catch the case where the user chooses to “do nothing” or presses any key other than “1”. This doesn’t override the normal behavior of the QA which is to replay the prompts so we need some way of getting out of the QA and we can do this by dropping a GoTo into the handler and setting its target to the IfElse we created earlier. This will get us out of the QA and allow the workflow to continue. Your handler should look like this:



Once we are out of the handler we need to check to see if the user pressed “1” and we do that in the IfElse we created earlier. Here we encounter a slight problem. The normal way an IfElse works is that it checks the branches from left to right until it finds a matching condition, hits the Else branch or runs out of branches. We can’t just use the normal QuestionAnswer.RecognitionResult logic that we are all so used to. Since we have jumped out of the QA when we had a silence or noreco event the QA’s Recognition object is null and we have to handle that case in the first branch or we risk blowing up our code. You can do that like in the first branch conditional code this:


      private void ifSpanishNoInput(object sender, ConditionalEventArgs e)


            if (askSpanish.RecognitionResult == null)

                e.Result = true;


                e.Result = false;




From here it is simple: All you need to do is add a code block to the Else branch and put this code in the _ExecuteEvent


            this.TelephonySession.CurrentUICulture = new CultureInfo(“es-US”);



That’s all there is to it. The QA will now allow the caller to either press the “1” key for Spanish or simply do nothing and the call will continue after setting the TTS to Spanish. You will also need to set your prompts to Spanish but I’ll leave that exercise for you. I will give you a hint though – I use AppendAudio and .wav files for most of my stuff so I just switch from an English directory of .wav files to the Spanish directory and append the prompts from there.


As I said this technique wil work any time you need a prompt that you want to barge in on or a prompt (QA)  that only has one input. I’ve given you enough inormation so that you can get something like this up and running in your code but if you have any questions just let me know.







New Speech Bloggers

I’m excited to  have added 3 new Speech Server bloggers to GotSpeech. I’m really looking forward to their contributions. The new blogs are

  1. Speech From Moscow – Dmitry is a speech programmer from Moscow where he is very active in the local community
  2. Speaking From the Edge – This is Marc LaFleur’s blog and he will be writing about the Core API and other things out there on the “bleeding edge” of speech. Marc’s current blog can be found at
  3. Dszabo Speaks – Will be the speech blog of David Szabo. David is a Microsoft consultant based out of Dublin Ireland. He also has a blog at


These blogs should come on line in the next few days and I’ll let them introduce themselves and fill you in on what they will be blogging about.

Microsoft E-Reference Library Subscription Discount

I received this information recently:

Microsoft Press has created an exclusive discount URL for the E-Reference Library that MVPs can pass along to the broader community without any limitations or restrictions. To create a trial subscription, community referrals should use the Trial URL ( Any community referrals who subscribe to E-Reference Libraries through the Subscription URL ( will receive a 40% discount on a one-year subscription. This discount offer ends on September 30, 2008.


I have a subscription and use it from time to time. Having the books as an online resource sure keeps my office neater and makes my wife happy. I have too many books already and I like having access to the books online. I just wish there were some related to Speech Server.

On the road – In D.C.

Yes, I’m traveling again and this week I’m in our nations’ capitol. If you are around this area then give me a shout.

When I get home next week I’ll blog about my books plans and some new things that are happening around GotSpeech Central. In the meantime keep posting in the forums.

GotSpeech Guy Under attack

Some low life has been using the contact form on my blog to flood me with email spam. In the last 2 days I have received well over 200 emails all with pretty much the same content – bogus links to sites that sell prescription drugs. I’m pretty sure someone has automated the process of sending them. Since they are coming from the email contact form on this blog I can’t block the IP address as I would loose all my email. At first I tried setting up rules in Outlook and that caught most of the stuff but I still had the aggravation of having my spam folder fill up.

So – I’ve removed the contact form from my blog. This has effectively stopped the bombardment. Most readers know my email address and can still send me email. For those who don’t you can send email to marshall at this domain.

I’m sorry if this creates any inconvenience for anyone but sometimes the rotten apples spoil things for everyone else.

If you blog off of GotSpeech and are experiencing the same problem email me and I’ll show you how to remove the contact form.

Dear Marshall Harrison,

I found this in my email inbox this morning.

Dear Marshall Harrison,

Congratulations! We are pleased to present you with the 2008 Microsoft® MVP Award! The MVP Award is our way to say thank you for promoting the spirit of community and improving people’s lives and the industry’s success every day. We appreciate your extraordinary efforts in Communications Server technical communities during the past year….


I’m sure that GotSpeech and the impact it has on the Speech Server community had a lot to do with me being rewarded again (3rd year now). GS has become a very active and thriving community and I am always thrilled to see new members come on board. I am really excited when I see members that started out with lots of questions progress to the point that they are now answering other people’s questions. That is what it is all about.

So, thanks to each of you for the time you spend on GotSpeech and the contributions that you make to the site and the community.


You can find more info the Microsoft MVP program by visiting