SemanticResultKey 클래스

정의

SemanticResultValue를 정의하기 위해 키 문자열을 SemanticValue와 연결합니다.

public ref class SemanticResultKey
public class SemanticResultKey
type SemanticResultKey = class
Public Class SemanticResultKey
상속
SemanticResultKey

예제

다음 예제에서는 "내 암호는 ..."형식의 암호 입력을 인식하는 을 만듭니다 Grammar . 여기서 실제 입력은 와일드카드와 일치합니다.

와일드카드는 의미 체계 키로 태그가 지정되고 SpeechRecognized 처리기는 이 태그의 존재를 확인하여 암호 입력이 발생했는지 확인합니다.

private void pwdGrammar()
{
  GrammarBuilder pwdBuilder = new GrammarBuilder("My Password is");
  GrammarBuilder wildcardBuilder = new GrammarBuilder();
  wildcardBuilder.AppendWildcard();
  SemanticResultKey wildcardKey= new SemanticResultKey("Password", wildcardBuilder);
  pwdBuilder+=wildcardKey;
  Grammar grammar = new Grammar(pwdBuilder);
  grammar.Name = "Password input";

  grammar.SpeechRecognized += delegate(object sender, SpeechRecognizedEventArgs eventArgs)
  {
    SemanticValue semantics = eventArgs.Result.Semantics;
    RecognitionResult result=eventArgs.Result;

    if (!semantics.ContainsKey("Password"))
    {
      SpeechUI.SendTextFeedback(eventArgs.Result, "No Password Provided", false);
    }
    else
    {
      RecognizedAudio pwdAudio = result.GetAudioForWordRange(result.Words[3], result.Words[result.Words.Count - 1]);
      MemoryStream pwdMemoryStream = new MemoryStream();
      pwdAudio.WriteToAudioStream(pwdMemoryStream);
      if (!IsValidPwd(pwdMemoryStream))
      {
        string badPwd = System.IO.Path.GetTempPath() + "BadPwd" + (new Random()).Next().ToString() + ".wav";
        FileStream waveStream = new FileStream(badPwd, FileMode.Create);
        pwdAudio.WriteToWaveStream(waveStream);
        waveStream.Flush();
        waveStream.Close();
        SpeechUI.SendTextFeedback(eventArgs.Result, "Invalid Password", false);

      }
    }
  };
  grammar.Enabled = true;
  _recognizer.LoadGrammar(grammar);
  UpdateGrammarTree(_grammarTreeView, _recognizer);

}

설명

System.Speech의 의미 체계 식의 기본 단위는 키/값 쌍인 입니다 SemanticValue.

개체를 사용하여 SemanticResultKey 개체 및 문자열에 포함된 인스턴스에 GrammarBuilder 태그 SemanticResultValue 를 지정하여 인식할 때 인스턴스에서 SemanticValue 값에 쉽게 액세스할 수 있도록 합니다.

및 개체를 SemanticResultKeyChoices 개체와 함께 GrammarBuilder 사용하여 SemanticResultValue 음성 인식 문법에 대한 의미 체계 구조를 정의할 수 있습니다. 인식 결과의 의미 체계 정보에 액세스하려면 의 속성을 RecognizedPhrase통해 SemanticsSemanticValue instance 가져옵니다.

생성자

SemanticResultKey(String, GrammarBuilder[])

음성 인식 문법을 만드는 데 사용하는 하나 이상의 GrammarBuilder 개체에 의미 키를 할당합니다.

SemanticResultKey(String, String[])

음성 인식 문법을 만드는 데 사용하는 하나 이상의 String 인스턴스에 의미 키를 할당합니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToGrammarBuilder()

현재 GrammarBuilder 인스턴스에서 생성된 SemanticResultKey의 인스턴스를 반환합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보