We help IT Professionals succeed at work.

Speech Application Results from an SQL Server

N2hockey19
N2hockey19 asked
on
Medium Priority
308 Views
Last Modified: 2010-04-16
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.
Comment
Watch Question

Commented:
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.
http://msdn.microsoft.com/academic/techdown/techprod/speech/default.aspx

Andy

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;
      myVoice.WaitUntilDone(System.Threading.Timeout.Infinite);

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)

Author

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?

Commented:
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.

Andy

Author

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.

Author

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.

Commented:
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.

Andy
Commented:
PAQed with points refunded (250)

DarthMod
Community Support Moderator

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.