Frage

ich muss eine programmatische Äquivalent mit delphi Sprache erstellen ... oder könnte jemand schreiben Sie einen Link auf wie Grammatiken in Peech recogniton mit der delphi zu tun. Oder irgendwelche Beispiele für XML-Grammatik, die programmatische Entsprechung in Delphi hat. sorry für mein Englisch.

**Programmatic Equivalent ** 

Ref: http: // msdn. microsoft.com/en-us/library/ms723634(v=VS.85).aspx

        SPSTATEHANDLE hsHelloWorld;
        hr = cpRecoGrammar->GetRule(L"HelloWorld", NULL,
                        SPRAF_TopLevel | SPRAF_Active, TRUE,
                        &hsHelloWorld);
        hr = cpRecoGrammar->AddWordTransition(hsHelloWorld, NULL,
                L"hello world", L" ",
                SPWT_LEXICAL, NULL, NULL);
        hr = cpRecoGrammar->AddWordTransition(hsHelloWorld, NULL,
                L"hiya|there", L"|",
                SPWT_LEXICAL, NULL, NULL);
        hr = cpRecoGrammar->Commit(NULL);

XML Grammatik Probe (n):

    <GRAMMAR>
        <!-- Create a simple "hello world" rule -->
        <RULE NAME="HelloWorld" TOPLEVEL="ACTIVE">
            <P>hello world</P>
        </RULE>
        <RULE NAME="HelloWorld_Disp" TOPLEVEL="ACTIVE">
            <P DISP="Hiya there!">hello world</P>
        </RULE>
        <RULE NAME="Question_Pron" TOPLEVEL="ACTIVE">
            <P DISP="I don't understand" PRON="eh">what</P>
        </RULE>
        <RULE NAME="NurseryRhyme" TOPLEVEL="ACTIVE">
            <P>hey</P>
            <P MIN="2" MAX="2">diddle</P>
        </RULE>
        <RULE NAME="UseWeights" TOPLEVEL="ACTIVE">
            <LIST>
                <P WEIGHT=".95">recognize speech</P>
                <P WEIGHT=".05">wreck a nice beach</P>
            </LIST>
        </RULE>
        <RULE NAME="UseProps" TOPLEVEL="ACTIVE">
            <P PROPNAME="NOVALUE">one</P>
            <P PROPNAME="NUMBER" VAL="2">two</P>
            <P PROPNAME="STRING" VALSTR="three">three</P>
        </RULE>
    </GRAMMAR>
War es hilfreich?

Lösung 2

Guy ich endlich in der Lage, die Antwort zu bekommen ....
Dies könnte nützlich sein, um andere ... :)
Dies ist die eigentliche Komponente, die ich schuf. ändern Sie es einfach für Ihre Bedürfnisse.

Function TSRRule.AddWord (Word : String; Value : string = ''; Separator : char = '|') : integer;
var
  OleValue : OleVariant;
begin
  result := 0;
  if Fwordlist.IndexOf(Word) = -1 then
     begin
       OleValue := Value;
       Fwordlist.Add(Word);
       FRule.InitialState.AddWordTransition(nil,  word, Separator, SPWT_LEXICAL, FRuleName+'_value',Fwordlist.Count, OleValue, 1.0);
       FWordCount := Fwordlist.Count;
       result := FWordCount;
     end;
end;

aufrufen Funktion ...

FSpRunTimeGrammar := SpInProcRecoContext.CreateGrammar(2); // we assign  another grammr on index 2

   SrRule1 := TSRRule.Create(1,'Rule1',FSpRunTimeGrammar);
   with SrRule1 do
      begin
         AddWord('Maxtor');
         AddWord('Open NotePad','Notepad.exe');
         AddWord('Maxtor Dexter TrandPack','',' ');
         commit;
      end;
   SrRule2 := TSRRule.Create(2,'Rule2',FSpRunTimeGrammar);
   with SrRule1 do
      begin
         AddWord('the box');
         AddWord('WeLcOmE SaPi');
         AddWord('Halo World');
         commit;
      end;
   FSpRunTimeGrammar.CmdSetRuleState('Rule1',SGDSActive);
   FSpRunTimeGrammar.CmdSetRuleState('Rule2',SGDSActive);

Bitte Kommentar hinterlassen für Präzisierungen .... viel Glück!

Andere Tipps

Es gibt eine direkte Wrapper für die Rede api von dem jedi Team getan, sollten Sie in der Lage sein, den Code zu finden, von hier http://www.delphi-jedi.org/apilibrary.html aber ich habe gerade überprüft und der Link zur sapi.zip Datei scheint gebrochen zu werden, vielleicht eine E-Mail an das Team jedi wird es für Sie wieder auftauchen.

Wenn Sie halten den Wrapper erhalten tun, und da diese direkte Windung der API, dann ist die MDSN docs sind, was Sie wollen, nur ersetzen Delphi-Syntax für C ++ Syntax 99% einfach sein wird, dass der nicht , nur die spezifische Frage stellt hier (oder auf den Embarcadero-Newsgroups)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top