Speech Application Results from an SQL Server

I am trying to find the best way to retrieve results from an SQL query and read the results back to the caller. They would input their information and it would query the database and check for a record, and if a record existed, read the record back to them. How would this be done? I know ADO.NET, so the actual select clause doesnt matter, the problem I'm having is passing my results back to the speech application as an answer to the customer.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Do you have a speech application that you are using? Or do you need to find one? There is a TTS (text to speech) audio handler distributed with the windows OS. You can create a reference to it from the COM library "Microsoft Speech Object Library" through Visual Studio, or a similar application.

There is also a speech SDK on MSDN to help with things like this, and, for what it's worth, there will be even more extensive support in Vista for all of this.


PS here is a code example for the TTS:

      SpVoice myVoice = new SpVoice();
      ISpeechObjectTokens voices = myVoice.GetVoices(string.Empty, string.Empty);
      myVoice.Voice = voices.Item(0); // just use the first voice returned
      SpAudioFormatClass format = new SpAudioFormatClass();
      format.Type = SpeechAudioFormatType.SAFT11kHz16BitMono; // play with the file types to trade off compression and quality
      mySpeechFileStream.Format = format;

      //      this has to be done using an output stream, so open it and get it ready
      mySpeechFileStream = new SpFileStream();
      mySpeechFileStream.Open(audioFileNameAndPath, SpeechStreamFileMode.SSFMCreateForWrite, false);
      myVoice.AudioOutputStream = mySpeechFileStream;
      myVoice.Speak(stringOfTextToSpeak, SpeechVoiceSpeakFlags.SVSFlagsAsync);
      myVoice.Rate = -5;

From some recent research I did, I think there's also a HIP code example on MSDN that uses this (just search HIP in MSDN and you'll find it)
N2hockey19Author Commented:
Sorry, forgot to add and remembered while I was on the road. I'm using Microsoft Speech Server 2004 Standard with SASDK 1.1. I am trying to create a simple application where the user enters information through a DTMF setup using the information they provide, and the application return the first record to them. I have QA and Natural number controls. I want to take the semantic items and insert them into a select statement to find their record, then return the result back. Building the select statement is easy, but how to get a prompt or QA control to read that result back has got me confused. Can the result be assigned to a variable in the codebehind and then accessed through a prompt function?
Unfortunately I am out of my depth, and someone else needs to help you :-) Sorry. Sounds fascinating though, I'd love to play with something like this.

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

N2hockey19Author Commented:
I think I may have found a temporary fix. I will have to refine my code later if possible. Basically what I did was on my last prompt (a NaturalNumber prompt) was tell it to autopostback and execute a function, this function did a select statement and read the first record, this record was concatenated into a string and the string was assigned to a textbox I have. After the postback, the next QA prompt loads and references to a prompt function which gets the value (via javascript code since that is what a prompt function consists of) and returns the value back to the QA prompt control for voice output. Thats some fine e-duct tape i used. I just have to push out a beta for one of my bosses, the kinks can be ironed out in a tech review.
N2hockey19Author Commented:
Well, after taking off the e-duct tape and understanding the SASDK 1.1 and refining my code, I basically told the last control in the series on a page (questions page) to postback or execute a function that saved the input to Session variables and then to a Server.Transfer over to the results page, where page_load executed a function if postback is false and builds the sql query string and returns the prompt and assigns it to the InlinePrompt of the qaResults control that will say the results back to the user. I'm not sure which way is best to do, but I found my own way out of all the articles I've read (none helping me out on how to query DB data and return it in the manner I wanted.) Sara Rea's example was to build a dynamic grammar file on execute. Well, the records we store are in the hundreds of thousands and I felt that a simple select statement and a datareader to return maybe 10 results at the max was enough since its a read-only operation on the IVR end.
It sounds like you've got a good solution then. Just to check - do you pass the variables between the two pages using Session, or using Context.Items? If you are doing Server.Transfer to get the new page, then I would definitely use Context.Items. Session will leave your data hanging around in the session, and if you have two pages posting back at the same time trying to access the same session variables, you could get strange results. Context.Items is specific to an individual Server.Transfer, and is then discarded when the transfer has returned to the client. Sometimes you need a combination of the two to ensure that the Server.Transfer has its own data, but that the "last postback wins" in the session to keep the data there for future reference.

Given that you've found a solution, I recommend you to ask the mods for this question to be PAQ'd with a refund.

PAQed with points refunded (250)

Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.