C++ -> Speech SDK?

Get technical support about the C++ source code and about Lua scripts for maps, entities, GUIs, the console, materials, etc. Also covered are the Cafu libraries and APIs, as well as compiling, linking, and the build system.
Post Reply
MatthiasG.
Posts:21
Joined:2009-01-11, 11:36
Location:Germany
C++ -> Speech SDK?

Post by MatthiasG. » 2009-01-15, 19:55

Hello everybody!

I've got a question about Speech SDK and C++.

I've written this Code in C#:

Code: Select all

using System;
using System.Collections.Generic;
using System.Linq;
using System.Speech;
using System.Speech.Recognition;
using System.Text;

namespace mini_speech_demo
{
    class Program
    {
        // Die main-Funktion wird alle Aufgaben ausführen. In einem größeren Programm würde man das eher auslagern.
        static void Main(string[] args)
        {
            // Hier werden recognition-engine und grammar vorbereitet. SpeechRecognitionEngine bedeutet, dass nur unser Programm auf die Spracherkennung zugreift.
            Console.WriteLine("Firing up speech-demo");
            SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine();
            recognizer.SetInputToDefaultAudioDevice();
            // hier setzen wir einen Event-Handler für das "Recognized"-Event. Es gibt noch eine Menge anderer Events.
            // Die aufgerufene Funktion recognizer_SpeechRecognized wird aufgerufen.
            recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);

            // der try-catch block ist eigentlich optional, aber ich hatte am Anfang so viele Exceptions, dass ich ihn drin gelassen habe.
            try
            {
                Grammar grammar = new Grammar("grammar.xml", "thema");
                recognizer.UnloadAllGrammars();
                recognizer.LoadGrammar(grammar);
                // mit folgender Zeile wird die eigentliche Erkennung gestartet.
                recognizer.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception aufgetreten: " + e.Message);
                return;
            }
            // wenn wir es bis hier geschafft haben, ist alles ok. Das zeigen wir dem Benutzer an...
            Console.WriteLine("Speech-Engine up and running");
            // ... und gehen in eine Schleife, die auf Tastendruck beendet wird (und mit ihr auch das Programm).
            while (!Console.KeyAvailable)
            {
                System.Threading.Thread.Sleep(100);
            }
            Console.WriteLine("terminating.");
            // Jetzt noch schnell aufräumen.
            recognizer.Dispose();
            return;
        }
        // Diese Funktion wird aufgerufen, sobald etwas erkannt wurde.
        // In e.Result.Text steht der erkannte Text.
        private static void recognizer_SpeechRecognized(object sender, System.Speech.Recognition.SpeechRecognizedEventArgs e)
        {
            Console.WriteLine(e.Result.Text + " (" + e.Result.Confidence.ToString() + ")");
        }
    }
}
(Ignore the Comments, they are in German ;) )

The grammar.xml is this:

Code: Select all

<grammar xmlns="http://www.w3.org/2001/06/grammar"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.w3.org/2001/06/grammar
                             http://www.w3.org/TR/speech-grammar/grammar.xsd"
         xml:lang="de-DE" version="1.0">
  <rule id="thema" scope="public">
    <one-of>
      <item>Design</item>
      <item>Wirtschaft</item>
      <item>Informatik</item>
    </one-of>
  </rule>
</grammar>
References are:
  • Systen
  • System.Core
  • System.Data
  • System.Data.DataSetExtensions
  • System.Drawing
  • System.Speech
  • System.Windows.Forms
  • System.Xml
  • System.Xml.Linq
I've made it with Microsoft Visual C# 2008 and Speech SDK. Is it possible to make something like that also in C++ (wouldn't that be an idea for Ca3De (think about the hinders persons))?
Greetings from germany,

MatthiasG.
MatthiasG.
Posts:21
Joined:2009-01-11, 11:36
Location:Germany

Re: C++ -> Speech SDK?

Post by MatthiasG. » 2009-01-19, 15:27

Has nobody an idea??
Greetings from germany,

MatthiasG.
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: C++ -> Speech SDK?

Post by Carsten » 2009-01-19, 19:18

Hi Matthias,

when I developed the VSWM project with Ca3DE for the United States Air Force a while ago (http://www.ca3d-engine.de/forum/viewtop ... 2550#p2550), we employed the Microsoft Speech API with Ca3DE in order to control the simulation:

http://www.microsoft.com/speech/speech2007/default.mspx
http://blogs.msdn.com/chuckop/default.aspx

However, I removed support for speech recognition a while ago again, because it was not portable (no version for Linux) and no other customers and interest besides the USAF contractor.

However, if there is serious interest again, it would be easy to add speech recognition back into Ca3DE, integrating it with the user input systems, and use it for arbitrary simulation (player) control. :up:
Best regards,
Carsten
MatthiasG.
Posts:21
Joined:2009-01-11, 11:36
Location:Germany

Re: C++ -> Speech SDK?

Post by MatthiasG. » 2009-01-20, 18:44

Hello Carsten!

Thank you for your reply!
Carsten wrote: when I developed the VSWM project with Ca3DE for the United States Air Force a while ago (http://www.ca3d-engine.de/forum/viewtop ... 2550#p2550), we employed the Microsoft Speech API with Ca3DE in order to control the simulation:
The US Airforce? :shock:

Have you got a sourcecode, how to use the Speech SDK?
Greetings from germany,

MatthiasG.
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: C++ -> Speech SDK?

Post by Carsten » 2009-01-20, 22:14

MatthiasG. wrote:Have you got a sourcecode, how to use the Speech SDK?
Sorry, no, I removed the SAPI code from Ca3DE a long time ago. Although it is of course still in the older revisions in the repository, today it would not run anymore as too much "environmental" and infrastructure code has changed as well (e.g. DLL handling).

But I'm sure that the SAPI SDK comes with plenty of examples and documentation where you can learn everything you need. In fact, the SAPI SDK would be your primary and preferred place for learning more about the Speech API even if the Ca3DE code was still present. :book:
Best regards,
Carsten
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests